kitpylib.PyMath package#
Module contents#
Submodules#
kitpylib.PyMath.findroot module#
- kitpylib.PyMath.findroot.bisection(f, a, b, e, showtimes=False)[source]#
BISECTION#
A function to find roots of f(x)=0 by bisection method. f(a) and f(b) cannot have the same signs.
Parameters#
- ffunc
f must be continuous. Python function returning a number.
- afloat
Start of the bracketing interval [a,b].
- bfloat
End of the bracketing interval [a,b].
- efloat
Accuracy
- showtimesbool. The default is False.
Show how many times the calculator use to find the root.
Returns#
- iterations:
Returns if showtimes is True.
- rootfloat
Root of f between a and b.
Examples#
Precise value:
>>> f = lambda x: x**2-1 >>> root = bisection(f, 0, 2, 0.01) >>> root 1.0
Errors:
>>> root = bisection(f, -2, 2, 0.01) ValueError: Incorrect input!
Approximate value:
>>> g = lambda x: -x**3-3*x+5 >>> root = bisection(g, 1, 2, 0.01) >>> root 1.1484375
showtimes is True:
>>> bisection(g, 1, 2, 0.01, showtimes=True) Finding root in 7 times. 1.1484375
kitpylib.PyMath.mathfuncs module#
kitpylib.PyMath.spf1d module#
- class kitpylib.PyMath.spf1d.PC(f, px1, py1)[source]#
Bases:
object== This is a class of the calculation of pedal curves.
Parameters#
f(function), px1, py1(x, y of the point)
Returns#
a, b: x, y of the function
x, y: x, y of pedal curves
Example#
>>> f = lambda x: x**2-1 >>> a = PC(f, 0, 0) >>> a.a array([-5. , -4.9989999, -4.9979998, ..., 4.9979998, 4.9989999, 5. ])
kitpylib.PyMath.spf2d module#
A module for 2d special functions.
kitpylib.PyMath.spf3d module#
A module for 3d special functions.