2017-01-01 · Mathematics, Approximation
Imagine you are coding an algorithm in a low-level programming language, such as Assembly, which lacks built-in functions for calculating trigonometric and exponential values. Unlike Python, where such calculations are effortless thanks to prebuilt libraries, low-level programming demands a different approach. In this scenario, how can you solve the problem ?
The answer lies in Function Approximation
The Taylor approximation represents a function as a polynomial expanded around a specific point. This method is based on the idea that a smooth function can be closely approximated by a sum of its derivatives at a point.
The Taylor series of a function f(x) around x = a is given by:
For simplicity, if (a = 0), this becomes the Maclaurin series: T_n(x) = f(0) + f'(0)x + \frac{f''(0)}{2!}x^2 + \cdots + \frac{f^{(n)}(0)}{n!}x^n
According to fundamental theorem of calculus (F.T.C), we have:
Expand the F.T.C, we have:
Coin O_1(n) = \int_{x_0}^{x} ... \int_{x_0}^{x_{n-1}} f^{(n)}(x_n)dx_n dx_{n-1}... dx_2 dx_1, O_2(n) = f(x_0) + ... + \frac{1}{n!} f^{(n)}(x - x_0)^n. We have:
The O_1(n), which comprises nested integrals, is a complete nightmare. In contrast, the rest of the equation is quite straightforward. However, the more we expand the equation, the less important is the first term. Let me prove it.
Assume that:
Then,
If we expand it further,
However, in some cases where \vert f^{(n)}(x_n) \vert \leq n^n. Then we will have
This will converge if \vert x - x_0 \vert \leq 1. So you better pick x that is within 1 unit from the x_0.
Approximate f(x) = e^x at x = 0:
For x = 0.5, this gives:
e^{0.5} \approx 1 + 0.5 + \frac{0.5^2}{2} = 1.6458333333333333
(True value: 1.6487, Error: 0.00288).
For x = 1., this gives:
e^{1} \approx 1 + 1 + \frac{1^2}{2} = 2.6666666666666665
(True value: 2.7182, Error: 0.05161)
Padé approximation represents a function as a ratio of two polynomials. Unlike Taylor series, which use a single polynomial, Padé excels at approximating functions with singularities or poles and provides better global accuracy.
A Padé approximation of order (m, n) for f(x) is given by: R_{m,n}(x) = \frac{P_m(x)}{Q_n(x)} where:
The coefficients of P_m(x) and Q_n(x) are chosen such that the Taylor series of R_{m,n}(x) matches f(x) as closely as possible up to x^{m+n}.
The main advantage of Padé approximation over Taylor's is the flexibility. In Taylor's polynomial expansion
and this behaviour is not desireable for functions that never reach \infty such as trigonometric functions. In such cases, Padé can fix this by introducing m=n, which can ensure that the limit of the function will not go to \infty. Furthermore, if the approximated functions will genuinely go to \infty as variables go to \infty, we can also adjust Padé coeffients m>n. Overall, Padé Approximation is a more general approximator of the Taylor's polynomial expansion.
However, when you use Padé approximation, you shold be aware of the domain of the denominator since there are certain values that are not computable.
For f(x) = e^x, the (2,1) Padé approximation is given by: R_{2,1}(x) = \frac{P_1(x)}{Q_1(x)} = \frac{b_0 + b_1x + b_2 x^2}{1 + c_1x}, where:
Our goal is to determine the coefficients b_0, b_1, b_2, and c_1 by matching the Taylor series expansion of R_{2,1}(x) with f(x) up to x^3.
(True value: 2.7182, Error: 0.001278)
(True value: 2.7182, Error: 0.0317)
As you can see, the error of Padé approximation is slightly smaller than that of Taylor approximation. However, in exchange, more computation is used.
Taylor approximation is ideal for smooth functions over a small domain, providing simplicity and ease of computation. However, if the approximated functions do not go to \infty as Taylor series do, consider applying Padé approximation.
With that said, which method will you use for your next problem?
1. A better way to think about Taylor series #SoMEpi - Youtube
2. Derivation of Taylor Series Expansion
Cited as:
Le Hoang Viet. "Explain Taylor và Padé series". Le Hoang Viet's Homepage, January 2017. https://mikyx-1.github.io/blog/taylor-series.html
Or the BibTeX entry:
@misc{le2017taylorseries,
title = {Explain Taylor và Padé series},
author = {Le, Hoang Viet},
journal = {Le Hoang Viet's Homepage},
year = {2017},
month = {January},
url = {https://mikyx-1.github.io/blog/taylor-series.html}
}
← Back to the blog index. Send feedback by email.