Taylor Series Calculator
Compute Taylor/Maclaurin series approximation for common functions.
Series Formula
sin(x) = x - x³/3! + x⁵/5! - x⁷/7! + ...About this tool
A Taylor series is one of mathematics' most powerful tools for approximating complex functions using only polynomials and arithmetic. Instead of computing transcendental functions like sine, cosine, or exponential directly, a Taylor series breaks them down into infinite sums of simple algebraic terms, each term involving only factorials and powers. This technique transforms problems that are hard to solve analytically into ones that a calculator—or your browser—can handle efficiently.
This calculator lets you explore how Taylor and Maclaurin series work by selecting a function (sine, cosine, exponential, natural logarithm, arctangent, square root, or geometric series), specifying a center point and an approximation point, and watching in real time as the series converges toward the true value. With each additional term you add, you'll see the partial sum get closer to the exact answer, and the error shrink dramatically. This hands-on exploration helps solidify your understanding of convergence and how series accuracy depends on distance from the center point.
Taylor series are indispensable in numerical analysis, physics simulations, and computer graphics, where computing transcendental functions without lookup tables saves memory and speed. Engineers and scientists use them to linearize complex nonlinear systems, physicists apply them in perturbation theory, and machine learning practitioners rely on them for approximating activation functions. Whether you're studying calculus, preparing for advanced mathematics, or building software that needs efficient function evaluation, this tool gives you a visual window into one of mathematics' most elegant and practical ideas.
Frequently Asked Questions
Code Implementation
import math
def factorial(n: int) -> int:
return math.factorial(n)
def taylor_sin(x: float, n_terms: int) -> list[float]:
"""sin(x) = sum(-1)^n * x^(2n+1) / (2n+1)!"""
terms = []
partial_sum = 0
for n in range(n_terms):
term = ((-1)**n * x**(2*n+1)) / factorial(2*n+1)
partial_sum += term
terms.append({'n': n, 'term': term, 'partial_sum': partial_sum})
return terms
def taylor_exp(x: float, n_terms: int) -> list[float]:
"""e^x = sum x^n / n!"""
terms = []
partial_sum = 0
for n in range(n_terms):
term = x**n / factorial(n)
partial_sum += term
terms.append({'n': n, 'term': term, 'partial_sum': partial_sum})
return terms
def taylor_cos(x: float, n_terms: int) -> list[float]:
"""cos(x) = sum(-1)^n * x^(2n) / (2n)!"""
terms = []
partial_sum = 0
for n in range(n_terms):
term = ((-1)**n * x**(2*n)) / factorial(2*n)
partial_sum += term
terms.append({'n': n, 'term': term, 'partial_sum': partial_sum})
return terms
# Example: sin(0.5)
x = 0.5
n_terms = 6
result = taylor_sin(x, n_terms)
approx = result[-1]['partial_sum']
exact = math.sin(x)
print(f"sin({x}) approximation with {n_terms} terms:")
for r in result:
print(f" n={r['n']}: term={r['term']:.8f}, sum={r['partial_sum']:.10f}")
print(f"Exact: {exact:.10f}")
print(f"Error: {abs(approx - exact):.2e}")
Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.