pyTaylor is a Python package that explores classical mathematical functions through series expansions and analytical approximations. It aims to provide a research-oriented framework for studying, comparing, and visualizing functions like sine, cosine, exponential, logarithm, and square roots, highlighting the accuracy and convergence of Taylor series and other mathematical formulas.
This package includes:
sin(x)– Sine function using Taylor series.cos(x)– Cosine function using Taylor series.tan(x)– Tangent function using Taylor series.exp(x)– Exponential function using Taylor series.log(x)– Natural logarithm using Taylor series.sqrt(x)– Square root function using series approximation.factorial(n)– Factorial using Stirling's approximation.constants.py– Common mathematical constants.utils.py– Utility functions such as argument normalization.
from mymath.sin import sin
from mymath.cos import cos
from mymath.factorial import factorial
print(sin(30)) # sine in degrees
print(cos(60)) # cosine in degrees
print(factorial(10)) # approximate factorialYou can also visualize the functions and compare them with Python's math library using matplotlib examples in the examples/ folder.
The following plots illustrate the comparison between the Taylor series approximations implemented in this package and the standard Python math library functions. These visualizations help to understand the accuracy and behavior of the approximations.

Comparison of mymath.sin vs math.sin.

Comparison of mymath.cos vs math.cos.

Comparison of mymath.tan vs math.tan.

Comparison of mymath.exp vs math.exp.

Comparison of mymath.log vs math.log.

Comparison of mymath.sqrt vs math.sqrt.
These plots demonstrate the effectiveness of Taylor series and classical approximations for common mathematical functions over typical ranges.
This project is licensed under the MIT License.
- Input angles are in degrees and normalized internally to radians.
- For factorials, Stirling's formula provides fast approximation, especially useful for large numbers.
- This project is intended for educational and research purposes.