jmath.approximation package¶
Submodules¶
jmath.approximation.differentiation module¶
Approximations of the results of differential equations.
- jmath.approximation.differentiation.differentiate(f, x, h=1e-06, n=1)¶
Numerically differentiate the given function at a point x. Uses the symmetric difference quotient to approximate. Recurses for n-th derivative.
- Parameters
f (Callable[[float], float]) – The function to numerically differentiate.
x (float) – The point at which to differentiate at.
h (float) – The change in x to approximate with.
n (int) – Order of derivative.
- Return type
Notes
Occasional accuracy issues for n > 1, investigation ongoing.
- jmath.approximation.differentiation.second_partials_test(f, crit_points)¶
Second Partials Test. Classifies the critical points of a function of two variables.
- Parameters
f (Callable[[float, float], float]) – The function to classify the critical points of.
crit_points (List[Tuple[float, float]]) – The critical points of the function.
- Return type
A dictionary mapping critical point tuples to descriptions of the points.
jmath.approximation.euler_method module¶
jmath/approximation/euler_method.py
Author: Jordan Hay Date: 2021-07-23
Euler method for approximate differntial equations
- jmath.approximation.euler_method.euler_step(f, t_k, y_k, h)¶
Computes the euler step function for a given function
Parameters:
f (function) - The derivate to approximate the integral of t_k (float) y_k (float) h (float) - Step size
- Parameters
f (Callable[[float, float], float]) –
t_k (float) –
y_k (float) –
h (float) –
- Return type
float
- jmath.approximation.euler_method.euler_step_interval(f, t_0, y_0, t_f, n)¶
Iterates euler step function using its own timestep
f (function) - Function to approximate the integral of t_0 (float) - Starting t value y_0 (float) - Starting y value t_f (float) - Final t value n (int) - Number of steps
- Parameters
f (Callable[[float, float], float]) –
t_0 (float) –
y_0 (float) –
t_f (float) –
n (int) –
- Return type
Dict[float, float]
- jmath.approximation.euler_method.iterate_euler_step(f, t_0, y_0, n, h)¶
Iterates upon the euler step function returning a dict of t values mapped to y values
f (function) - The derivate to approximate the integral of t_0 (float) - The starting t value y_0 (float) - The starting y value n (int) - Number of steps to do h (float) - Step size
- Parameters
f (Callable[[float, float], float]) –
t_0 (float) –
y_0 (float) –
n (int) –
h (float) –
- Return type
Dict[float, float]
jmath.approximation.integration module¶
Approximations of definite integrals
- jmath.approximation.integration.discrete_trapezium_rule(x, y)¶
Performs the trapezium rule on discrete sets of data
- Parameters
x (Iterable[float]) – Data associated with the x-axis
y (Iterable[float]) – Data associated with the y-axis
- Return type
float
Notes
x and y should be of the same length.
- jmath.approximation.integration.left_hand_rule(f, start, end, divisions)¶
Approximates area under curve with the left hand rule.
- Parameters
f (Callable[[float], float]) – The function to approximate the area under
start (float) – The lower limit of the definite integral.
end (float) – The upper limit of the definite integral.
divisions (int) – The amount of divisions to use.
- Return type
float
- jmath.approximation.integration.partition(f, start, end, divisions)¶
Partitions a function, returning the start and end points of each partition
- Parameters
f (Callable[[float], float]) – The function to partition
start (float) – Lower limit
end (float) – Upper limit
divisions (int) – Amount of divisions to cut the function into
- Return type
Generator[float, None, None]
- jmath.approximation.integration.right_hand_rule(f, start, end, divisions)¶
Approximates area under curve with the right hand rule.
- Parameters
f (Callable[[float], float]) – The function to approximate the area under
start (float) – The lower limit of the definite integral.
end (float) – The upper limit of the definite integral.
divisions (int) – The amount of divisions to use.
- Return type
float
- jmath.approximation.integration.trapezium_rule(f, start, end, divisions)¶
Approximates area under curve with the trapezium hand rule.
- Parameters
f (Callable[[float], float]) – The function to approximate the area under
start (float) – The lower limit of the definite integral.
end (float) – The upper limit of the definite integral.
divisions (int) – The amount of divisions to use.
- Return type
float
jmath.approximation.newton_method module¶
Newton’s method for approximating the roots of equations.
- jmath.approximation.newton_method.newton_method(f, f_prime, x_0, threshold=5e-07, max_iter=100)¶
Newton’s Method for approximation of the root of an equation.
- Parameters
f (Callable[[float], float]) – The function to determine the root of.
f_prime (Callable[[float], float]) – The derivative of the function to determine the root of.
x_0 (float) – The starting point for determining the root from.
threshold (float) – The threshold error to approximate the root to.
max_iter (int) – The maximum iterations to apply.
- Return type
- jmath.approximation.newton_method.newton_sqrt(n)¶
Uses Newton’s Method to compute square roots.
- Parameters
n (float) – The number to approximate the square root of.
- Return type
- jmath.approximation.newton_method.newton_step(f, f_prime, x_0)¶
Performs a single iteration of Newton’s Method
- Parameters
f (Callable[[float], float]) – The function to determine the root of.
f_prime (Callable[[float], float]) – The derivative of the function to determine the root of.
x_0 (float) – The starting point for determining the root from.
- Return type
float
Module contents¶
jmath/approximation/__init__.py
Tools for approximating mathematical equations.
Default Packages¶
- jmath.approximation.euler_method
The Euler Method for approximating the integrals of differential equations.
- jmath.approximation.newton_method
The Newton Method for approximating the roots of an equation.
- jmath.approximation.differentiation
Numerical method for approximating differentials of functions.
- jmath.approximation.integration
Numerical methods for approximating definite integrals.