mnultitool.misc package¶
Submodules¶
mnultitool.misc.approximate module¶
Functions:
|
Approximates the solution to f(x) = 0 in range [a, b] using bisection method |
|
Approximates the solution to f(x) = 0 in range [a, b] using Newton’s method |
|
Approximates the solution to f(x) = 0 in range [a, b] using secant method |
|
Computes an approximation of cos(kx) using the formula: |
|
Computes an approximation of cos(kx) & sin(kx) using the formulas: |
|
Computes an approximation of e^x |
|
Computes an approximate value of Pi, using the formula: |
-
mnultitool.misc.approximate.
approxZeroBisection
(a, b, f, epsilon, iteration)¶ Approximates the solution to f(x) = 0 in range [a, b] using bisection method
- Parameters
a (
Union`[:py:class:`int
,float
]) – left range boundb (
Union`[:py:class:`int
,float
]) – right range boundf (
Callable`[[:py:class:`float
],float
]) – callable function of variable xepsilon (
float
) – the desired precision (stop condition)iteration (
int
) – maximum iterations count limit (to prevent an infinite loop)
- Raises
ValueError – when input types are wrong or f has same signs on both range bounds
- Return type
Tuple`[:py:class:`float
,int
]- Returns
a tuple containing (in order): an approximate solution x, iterations made count
-
mnultitool.misc.approximate.
approxZeroNewton
(f, df, ddf, a, b, epsilon, iteration)¶ Approximates the solution to f(x) = 0 in range [a, b] using Newton’s method
- Parameters
f (
Callable`[[:py:class:`float
],float
]) – callable function of variable xdf (
Callable`[[:py:class:`float
],float
]) – callable derivate of f (f’)ddf (
Callable`[[:py:class:`float
],float
]) – callable second-order derivate of f (f’’)a (
Union`[:py:class:`int
,float
]) – left range boundb (
Union`[:py:class:`int
,float
]) – right range boundepsilon (
float
) – the desired precision (stop condition)iteration (
int
) – maximum iterations count limit (to prevent an infinite loop)
- Raises
ValueError – when input types are wrong or either df or dff has same different on both range bounds
- Return type
Tuple`[:py:class:`float
,int
]- Returns
a tuple containing (in order): an approximate solution x, iterations made count
-
mnultitool.misc.approximate.
approxZeroSecant
(a, b, f, epsilon, iteration)¶ Approximates the solution to f(x) = 0 in range [a, b] using secant method
- Parameters
a (
float
) – left range boundb (
float
) – right range boundf (
Callable`[[:py:class:`float
],float
]) – callable function of variable xepsilon (
float
) – the desired precision (stop condition)iteration (
int
) – maximum iterations count limit (to prevent an infinite loop)
- Raises
ValueError – when input types are wrong or f has same signs on both range bounds
- Return type
Tuple`[:py:class:`float
,int
]- Returns
a tuple containing (in order): an approximate solution x, iterations made count
-
mnultitool.misc.approximate.
coskx1
(k, x)¶ Computes an approximation of cos(kx) using the formula:
- Parameters
x (
Union`[:py:class:`int
,float
]) – xk (
int
) – k
- Return type
float
- Returns
the approximated value
-
mnultitool.misc.approximate.
cossinkx2
(k, x)¶ Computes an approximation of cos(kx) & sin(kx) using the formulas:
- Parameters
x (
Union`[:py:class:`int
,float
]) – xk (
int
) – k
- Return type
Tuple`[:py:class:`float
,float
]- Returns
approximated cos(kx) and sin(kx) values
-
mnultitool.misc.approximate.
exponential
(x, n)¶ Computes an approximation of e^x
- Parameters
x (
Union`[:py:class:`int
,float
]) – xk – k
- Return type
float
- Returns
the approximated value
-
mnultitool.misc.approximate.
pi
(n)¶ Computes an approximate value of Pi, using the formula:
- Parameters
n (
int
) – the amount of sum elements- Return type
float
- Returns
the approximated value of pi
mnultitool.misc.norm module¶
Functions:
|
Computes the max norm (sometimes called the ‘infinity norm’) of scalars or vectors; both arguments’ dimensions must be compatible |
|
Computes the matrix norm of the residues of an equation in a form of Ax = b |
-
mnultitool.misc.norm.
maxNorm
(xr, x)¶ Computes the max norm (sometimes called the ‘infinity norm’) of scalars or vectors; both arguments’ dimensions must be compatible
- Parameters
xr (
Union`[:py:class:`int
,float
,List
,ndarray
]) – precise value, either a scalar or a vector of shape (n, 1)x (
Union`[:py:class:`int
,float
,List
,ndarray
]) – approximate value, either a scalar or a vector of shape (n, 1)
- Return type
float
- Returns
the value of the norm, max(abs(xr - x))
-
mnultitool.misc.norm.
residualNorm
(A, x, b)¶ Computes the matrix norm of the residues of an equation in a form of Ax = b
- Parameters
A (
ndarray
) – matrix A (m, m) containing the equation’s coefficientsx (
ndarray
) – vector x (m, 1) containing the equation’s solutionsb (
ndarray
) – vector b (m, 1) containing the equation’s right hand side’s coefficients
- Return type
float
- Returns
matrix norm value of the equation’s residues
mnultitool.misc.rigid module¶
Functions:
|
Computes the total area of a cylinder |
|
Computes the first n Fibonacci’s sequence elements |
-
mnultitool.misc.rigid.
cylinderArea
(r, h)¶ Computes the total area of a cylinder
- Parameters
r (
float
) – cylinder base radiush (
float
) – cylinder height
- Returns
cylinder area
- Return type
float
-
mnultitool.misc.rigid.
fibonacci
(n)¶ Computes the first n Fibonacci’s sequence elements
Parameters: :type n:
int
:param n: the amount of elements- Returns
n first Fibonacci’s sequence elements
- Return type
np.ndarray
mnultitool.misc.utils module¶
Functions:
|
Calculates an absolute error of two arguments, either scalars, or vectors |
|
Helper that checks if the supplied value |
|
Calculates a relative error of two arguments, either scalars, or vectors |
-
mnultitool.misc.utils.
absoluteError
(v, v_approx)¶ Calculates an absolute error of two arguments, either scalars, or vectors
- Parameters
v (
Union`[:py:class:`int
,float
,List
,ndarray
]) – precise valuev_approx (
Union`[:py:class:`int
,float
,List
,ndarray
]) – approximate value
- Return type
Union`[:py:class:`int
,float
,ndarray
]- Returns
absolute error value or NaN if input data is ill-formed
-
mnultitool.misc.utils.
isType
(val, typeArr)¶ Helper that checks if the supplied value
val
is of a specific type or of a type present intypeArr
- Return type
bool
-
mnultitool.misc.utils.
relativeError
(v, v_approx)¶ Calculates a relative error of two arguments, either scalars, or vectors
- Parameters
v (
Union`[:py:class:`int
,float
,List
,ndarray
]) – precise valuev_approx (
Union`[:py:class:`int
,float
,List
,ndarray
]) – approximate value
- Return type
Union`[:py:class:`int
,float
,ndarray
]- Returns
relative error value or NaN if input data is ill-formed