A simple python module for approximating any sympy
expression
using the Taylor series and Chebyshev polynomials.
It was created as a project for the DisCont mathematics 2 course at the Faculty of Electrical Engineering and Computing, University of Zagreb.
Requires at least python 3.6
.
pip install -r requirements.txt
The functionality is divided into two submodules:
chebyshev.polynomial
which is used for computing and storing Chebyshev polynomials, as well as some other simple polynomial manipulation.chebyshev.approximation
which is used for approximating anysympy
expression using the Taylor series and Chebyshev polynomials.
Coefficients for exp(x)
on the [0, 1]
interval:
Coefficient | Term |
---|---|
+0.00228989065375017828 |
x6 |
+0.00686967196125053310 |
x5 |
+0.04293544975781583839 |
x4 |
+0.16601707239688789919 |
x3 |
+0.50019798967855455540 |
x2 |
+0.99996662485953080601 |
x |
+1.00000240440099563700 |
1 |
Maximum error on that interval is 2.724750259197606e-06
Coefficients for log(x + 1)
on the [0, 1]
interval:
Coefficient | Term |
---|---|
-1.78206380208333333330 |
x6 |
+1.68432617187500000000 |
x5 |
+1.23596191406250000000 |
x4 |
-0.76288859049479166667 |
x3 |
-0.86048889160156250000 |
x2 |
+1.16706848144531250000 |
x |
+0.01269240000891307044 |
1 |
Maximum error on that interval is 0.026814743150641585
Coefficients for sin(x)/x
on the [-1, 1]
interval:
Coefficient | Term |
---|---|
+0.00000269375975765659 |
x8 |
-0.00019835866408658445 |
x6 |
+0.00833331406945632250 |
x4 |
-0.16666666426123592319 |
x2 |
+0.99999999995192540491 |
1 |
Maximum error on that interval is 4.807454434541114e-11
Coefficients for cos(x)
on the [-1, 1]
interval:
Coefficient | Term |
---|---|
+0.00002412120108317053 |
x8 |
-0.00138829603431854838 |
x6 |
+0.04166645537534185744 |
x4 |
-0.49999997362171781040 |
x2 |
+0.99999999947287565593 |
1 |
Maximum error on that interval is 5.271243441740125e-10