Points on Graph¶
- coordinate_pairs(equation_type, coefficients, inputs, point_type='point', precision=4)¶
Creates a list of coordinate pairs from a set of inputs
- Parameters
equation_type (str) – Name of the type of function for which coordinate pairs must be determined (e.g., ‘linear’, ‘quadratic’)
coefficients (list of int or float) – Coefficients to use to generate the equation to investigate
inputs (list of int or float or str) – X-coordinates to use to generate the y-coordinates for each coordinate pair
point_type (str, default='point') – Name of the type of point that describes all points which must be generated (e.g., ‘intercepts’, ‘maxima’)
precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the results
- Raises
ValueError – First argument must be either ‘linear’, ‘quadratic’, ‘cubic’, ‘hyperbolic’, ‘exponential’, ‘logarithmic’, ‘logistic’, or ‘sinusoidal’
TypeError – Second argument must be a 1-dimensional list containing elements that are integers or floats
TypeError – Third argument must be a 1-dimensional list containing elements that are integers, floats, strings, or None
ValueError – Fourth argument must be either ‘point’, ‘intercepts’, ‘maxima’, ‘minima’, or ‘inflections’
ValueError – Last argument must be a positive integer
- Returns
points – List containing lists of coordinate pairs, in which the second element of the inner lists are floats and the first elements of the inner lists are either floats or strings (the latter for general forms); may return a list of None if inputs list contained None
- Return type
list of float or str
See also
Notes
Set of x-coordinates of points: \(x_i = \{ x_1, x_2, \cdots, x_n \}\)
Set of y-coordinates of points: \(y_i = \{ y_1, y_2, \cdots, y_n \}\)
Set of coordinate pairs of points: \(p_i = \{ (x_1, y_1), (x_2, y_2), \cdots, (x_n, y_n) \}\)
Examples
- Import coordinate_pairs function from regressions library
>>> from regressions.analyses.points import coordinate_pairs
- Generate a list of coordinate pairs for a cubic function with coefficients 2, 3, 5, and 7 based off x-coordinates of 1, 2, 3, and 4
>>> points_cubic = coordinate_pairs('cubic', [2, 3, 5, 7], [1, 2, 3, 4]) >>> print(points_cubic) [[1.0, 17.0], [2.0, 45.0], [3.0, 103.0], [4.0, 203.0]]
- Generate a list of coordinate pairs for a sinusoidal function with coefficients 2, 3, 5, and 7 based off x-coordinates of 1, 2, 3, and 4
>>> points_sinusoidal = coordinate_pairs('sinusoidal', [2, 3, 5, 7], [1, 2, 3, 4]) >>> print(points_sinusoidal) [[1.0, 8.0731], [2.0, 6.1758], [3.0, 7.5588], [4.0, 6.7178]]
- Generate a list of coordinate pairs for a quadratic function with coefficients 1, -5, and 6 based off x-coordinates of 2 and 3 (given that the resultant coordinates will be x-intercepts)
>>> points_quadratic = coordinate_pairs('quadratic', [1, -5, 6], [2, 3], 'intercepts') >>> print(points_quadratic) [[2.0, 0.0], [3.0, 0.0]]
- key_coordinates(equation_type, coefficients, precision=4)¶
Calculates the key points of a specific function
- Parameters
equation_type (str) – Name of the type of function for which key points must be determined (e.g., ‘linear’, ‘quadratic’)
coefficients (list of int or float) – Coefficients to use to generate the equation to investigate
precision (int, default=4) – Maximum number of digits that can appear after the decimal place of the results
- Raises
ValueError – First argument must be either ‘linear’, ‘quadratic’, ‘cubic’, ‘hyperbolic’, ‘exponential’, ‘logarithmic’, ‘logistic’, or ‘sinusoidal’
TypeError – Second argument must be a 1-dimensional list containing elements that are integers or floats
ValueError – Last argument must be a positive integer
- Returns
points[‘roots’] (list of float or str) – List containing two-element lists for each point; first elements of those lists will be the value of the x-coordinate at which the original function has a root; second elements of those lists will be 0; if the function is sinusoidal, then only the initial results within a four-period interval will be listed, but general forms will also be included; if the function has no roots, then it will return a list of None
points[‘maxima’] (list of float or str) – List containing two-element lists for each point; first elements of those lists will be the value of the x-coordinate at which the original function has a relative maximum; second elements of those lists will be the y-coordinate of that maximum; if the function is sinusoidal, then only the initial results within a two-period interval will be listed, but a general form will also be included; if the function has no maxima, then it will return a list of None
points[‘minima’] (list of float or str) – List containing two-element lists for each point; first elements of those lists will be the value of the x-coordinate at which the original function has a relative minimum; second elements of those lists will be the y-coordinate of that minimum; if the function is sinusoidal, then only the initial results within a two-period interval will be listed, but a general form will also be included; if the function has no minima, then it will return a list of None
points[‘inflections’] (list of float or str) – List containing two-element lists for each point; first elements of those lists will be the value of the x-coordinate at which the original function has an inflection; second elements of those lists will be the y-coordinate of that inflection; if the function is sinusoidal, then only the initial results within a two-period interval will be listed, but a general form will also be included; if the function has no inflection points, then it will return a list of None
See also
Roots for key functions:
linear_roots(),quadratic_roots(),cubic_roots(),hyperbolic_roots(),exponential_roots(),logarithmic_roots(),logistic_roots(),sinusoidal_roots()Graphical analysis:
critical_points(),sign_chart(),maxima_points(),minima_points(),extrema_points(),inflection_points()
Notes
Key points include x-intercepts, maxima, minima, and points of inflection
Examples
- Import key_coordinates function from regressions library
>>> from regressions.analyses.points import key_coordinates
- Calculate the key points of a cubic function with coefficients 1, -15, 63, and -7
>>> points_cubic = key_coordinates('cubic', [1, -15, 63, -7]) >>> print(points_cubic['roots']) [[0.1142, 0.0]] >>> print(points_cubic['maxima']) [[3.0, 74.0]] >>> print(points_cubic['minima']) [[7.0, 42.0]] >>> print(points_cubic['inflections']) [[5.0, 58.0]]
- Calculate the key points of a sinusoidal function with coefficients 2, 3, 5, and 1
>>> points_sinusoidal = key_coordinates('sinusoidal', [2, 3, 5, 1]) >>> print(points_sinusoidal['roots']) [[4.8255, 0.0], [6.2217, 0.0], [6.9199, 0.0], [8.3161, 0.0], [9.0143, 0.0], [10.4105, 0.0], [11.1087, 0.0], [12.5049, 0.0], [13.203, 0.0], [14.5993, 0.0], ['4.8255 + 2.0944k', 0.0], ['6.2217 + 2.0944k', 0.0]] >>> print(points_sinusoidal['maxima']) [[5.5236, 3.0], [7.618, 3.0], [9.7124, 3.0], ['5.5236 + 2.0944k', 3.0]] >>> print(points_sinusoidal['minima']) [[6.5708, -1.0], [8.6652, -1.0], ['6.5708 + 2.0944k', -1.0]] >>> print(points_sinusoidal['inflections']) [[5.0, 1.0], [6.0472, 1.0], [7.0944, 1.0], [8.1416, 1.0], [9.1888, 1.0001], ['5.0 + 1.0472k', 1.0]]
- points_within_range(points, start, end)¶
Eliminates all values from a set of points that fall below a lower bound or above an upper bound
- Parameters
points (list of int or float or str) – Set of points to narrow down to only those within a certain range
start (int or float) – Lower bound of range into which the initial value must be adjusted (final value should be greater than or equal to start)
end (int or float) – Upper bound of range into which the initial value must be adjusted (final value should be less than or equal to end)
- Raises
TypeError – First argument must be a 1-dimensional list containing elements that are integers, floats, strings, or None
TypeError – Second and third arguments must be integers or floats
ValueError – Second argument must be less than or equal to third argument
- Returns
selected_points – List of all values from original list that fall within specified range; may return a list of None if no points from the original list fall within range or if original list only contained None
- Return type
list of int or float or str
Notes
Initial set of points: \(p_i = \{ p_1, p_2, \cdots, p_n \}\)
Lower bound of range: \(b_l\)
Upper bound of range: \(b_u\)
Adjusted set of points within range: \(r_i = \{ r \mid r \in p_i, r \geq b_l, r \leq b_u \}\)
Examples
- Import points_within_range function from regressions library
>>> from regressions.analyses.points import points_within_range
- Eliminate all points above 19 or below 6 in the set [1, 5, 6, 7, 18, 20, 50, 127]
>>> selected_points_int = points_within_range([1, 5, 6, 7, 18, 20, 50, 127], 6, 19) >>> print(selected_points_int) [6, 7, 18]
- Eliminate all points above 243.7821 or below 198.1735 in the set [542.1234, 237.9109, -129.3214, 199.4321, 129.3214]
>>> selected_points_float = points_within_range([542.1234, 237.9109, -129.3214, 199.4321, 129.3214], 198.1735, 243.7821) >>> print(selected_points_float) [237.9109, 199.4321]