This project implements a Python program to compute the exponential function
-
Implement Taylor Series: Calculate
$e^x$ using the Taylor series formula up to$n$ terms, where$x$ and$n$ are user inputs. -
Handling Negative Values: Evaluate
$e^x$ in two ways for$x < 0$ :- Directly using the series.
- Using the transformation
$y = -x$ and computing:$e^x = \frac{1}{e^{-x}}$
- Avoiding Overflow: Optimize factorial calculations to prevent overflow by performing intermediate divisions.
- Convergence Criterion: Determine the appropriate stopping condition for the Taylor series expansion.
- Numerical vs Analytical Methods: Analyze the differences and types of errors in the results.
- Symbolic Computation: Explore symbolic computation to verify results and analyze performance.
- Python 3.x
- Libraries:
math
(for numerical operations)sympy
(for symbolic computation)
The exponential function
For negative
- Direct calculation using
$x$ in the series. - Transforming
$x$ to$y = -x$ and using:$e^x = \frac{1}{e^{-x}}$
The factorial
This avoids explicit computation of
The series calculation terminates when the relative change between consecutive terms becomes negligibly small:
threshold
is a small predefined value, e.g.,
Aspect | Analytical Method | Numerical Method |
---|---|---|
Definition | Exact solutions derived from formulas. | Approximations using iterative calculations. |
Nature | Symbolic and exact. | Approximate and dependent on precision. |
Example | Taylor series expansion for |
This project is licensed under the MIT License.
You can read the full terms of the license in the LICENSE file or visit: