-
Notifications
You must be signed in to change notification settings - Fork 0
analysis
The avmath.analysis
submodule provides functionalities for
analysis. It can be imported in the following way:
# pip install avmath
from avmath import analysis
The Point class is the return type of some Function
methods. It inherites from
algebra.Tuple
and defines this extra method:
Implemented in v1.0.0 | Last change v3.0.0
Initialisation of point.
Implemented in v3.1.0 | Last change v3.1.0
Returns point with negative y coordinate.
The Function class provides functionalities for mathematical functions.
It has got the following attributes and methods:
Attribute | Usage | Implemented in | Last change |
---|---|---|---|
self.term | Stores the function term as string | v1.0.0 | v3.0.0 |
self._arg_scope | Stores the scope given to eval
|
v2.0.0 | v2.0.0 |
Implemented in v1.0.0 | Last change in v3.0.0
The constructor takes a string argument. This shall be the function
term. Because of the _arg_scope
there can be given functions
of avmath
without the module name. As definition variable
x must be used. It also provides some easy to use coefficient
and polynom features.
from avmath import analysis
# Polynoms can be given in intentional form
f1 = analysis.Function("2*x**2 + 3*x - 4")
f2 = analysis.Function("2x^2 + 3x - 4")
# avmath functions
g = analysis.Function("sin(x)")
h = analysis.Function("artanh(x)")
Implemented in v1.0.0 | Last change in v3.0.0
Gives string representation of function.
from avmath import analysis
f = analysis.Function("3x^2 + sin(x)")
print(f)
gives the output
f(x) = 3x^2 + sin(x)
Implemented in v1.0.0 | Last change in v3.1.0
Adds two formulas.
Implemented in v1.0.0 | Last change in v3.0.0
Subtracts two formulas. The entire second formula is set in brackets.
Implemented in v1.0.0 | Last change in v3.1.0
Multiplies two formulas or Function with REAL. Both are set in brackets.
Implemented in v1.0.0 | Last change in v3.1.0
Divides two formulas or a formula by a REAL. Both are set in brackets.
Implemented in v3.1.0 | Last change in v3.1.0
Divides a REAL by a formula. Both are set in brackets.
Implemented in v1.0.0 | Last change in v3.0.0
Returns negative formula. Formula is just set in brackets
and preceded by a -
sign.
Implemented in v1.0.0 | Last change in v3.1.0
Function replacing the intuitive elements (shown in __init__
)
with the correct syntax and setting given value for x.
from avmath import analysis
f = analysis.Function("3x^2 + sin(x)")
print(f.replace(5))
gives the output
3*(-5)**2 + sin((-5))
Implemented in v2.0.0 | Last change in v3.0.0
Sets new scope for eval
.
Implemented in v2.0.0 | Last change in v3.0.0
Appends scope dictionary to scope.
Implemented in v1.0.0 | Last change in v3.0.0
Returns the y-value of a function at a given x-value.
Implemented in v2.0.0 | Last change in v3.1.0
Function returning the maxima of a function in a given x domain.
steps
are the iterative steps made to find a change in the signum. Than uses
Newton-method derivative to find the maxima. Returns list
of Point values.
Implemented in v2.0.0 | Last change in v3.1.0
Opposite of max. Returns minima in a given x domain.
Implemented in v3.0.0 | Last change in v3.0.0
Returns the roots of function in given x domain. Uses Newton-method to approach roots. Gives list of x-values back.
! WARNING: Due to backward compatibility last parameter remains step
not steps
like in max and min.
Implemented in v3.0.0 | Last change in v3.1.0
Returns result of steps
times executed Newton-method.
Implemented in v3.1.0 | Last change in v3.1.0
Executes derivative of Newton method: x_{n+1} = f'(x_n) / f''(x_n).
Implemented in v3.1.0 | Last change in v3.1.1
Returns the derivative of the function at a given x. If no h
specified,
calculates a height, but this may not be the optimal one.
Implemented in v3.1.0 | Last change in v3.1.0
Returns second derivative of the function at given x. h
is set to 1e-5
what is mostly a good compromise of arithmetic error and numeric error.
Implemented in v3.1.0 | Last change in v3.1.0
Calculates the integral of the function between a
and b
with n
steps.
With no option specified, uses rectangular formula. If option="trapeze"
, uses
trapeze formula.
Implemented in v1.0.0 | Last change in v3.0.0
Returns numeric differentiation of the function at given x.
! WARNING: INACTIVE: Use Function.derivative instead.
Implemented in v3.0.0 | Last change in v3.0.0
Returns numerically calculated second differentiation at given x.
! WARNING: INACTIVE: Use Function.second_derivative instead.
Implemented in v1.0.0 | Last change in v3.1.0
Numerically calculated integral between a
and b
with n
steps.
! WARNING: INACTIVE: Use Function.integral instead.
Implemented in v3.1.0 | Last change in v3.1.0
Returns a linear function in the form y = ax + b that lies tangent to the function graph at a given x.
Implemented in v3.1.0 | Last change in v3.1.0
Returns a linear function in the form y = ax + b that lies normal to the function graph at a given x.