I'm new to numerical methods and trying to find best element of continuous approximation for the $$f(x) = \sin(x) \text{ for } x \in [0, \pi/4]\text{.}$$ How I can solve this problem ?
Best approximation element
329 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 4 best solutions below
On
You can get a polynomial approximation optimal in the minmax sense (smallest error on the whole interval) using the Remez algorithm, which uses the Chebyshev polynomials. https://en.wikipedia.org/wiki/Remez_algorithm
Or an approximation in the least-square sense (smallest average squared error) by means of the Legendre polynomials and numerical integration. Least square fit using Legendre polynomials
A non-optimal but simple solution is given by the Taylor development
$$\sin x\approx\sum_{k=0}^n(-1)^k\frac{x^{2k+1}}{(2k+1)!}$$ which converges reasonably fast.
On
Seeing the graph of $f (x)=\sin (x) $ we see that we can have create a 3 degree which almost fits with the curve of $\sin (x) $ so we take a general 3degree .let $g(x)=ax^3+bx^2+cx+d$ at $x=0$ for $\sin (x) $ we have $f (0)=0$ thus $g (x) $ should also be $0$ this implies $d=0$. Then we take derivative of $f (x),g (x) $ their slopes should match at given point . We take slope at 0. From this we have $c=1$. Then we go for second and third derivative at $x=0$ and find that we have $a=\frac {-1}{6},b=0$ thus a numerical approximation around $0$ for $\sin (x) $ is $\sin (x)\approx x-\frac {x^3}{6} $ . Note that its still not very accurate for good accuracy look up for taylor series.
On
The Taylor series of $\sin(x)$ about a point $x=a$ is given by
$$\begin{align} \sin(x)&=\sin(a)+\cos(a)x-\frac{\sin(a)}{2!}x^2-\frac{\cos(a)}{3!}x^3+...\\ &=\sum_{k=0}^\infty \frac{\sin\left(a+k\dfrac{\pi}{2}\right)}{k!}x^k \end{align}$$
Choosing $a=0$ and truncation to third order yields the approximation $$\sin(x)\approx x-\dfrac{x^3}{6}$$
with exact match at $x=0$ but the error growing as $x\to \dfrac{\pi}{4}$.
In this problem, choosing $a=\dfrac{0+\dfrac{\pi}{4}}{2}=\dfrac{\pi}{8}$ distributes the error more evenly along the interval. $$\sin(x)\approx \sin\left(\frac{\pi}{8}\right)+\cos\left(\frac{\pi}{8}\right)\left(x-\frac{\pi}{8}\right)-\left(\frac{1}{2}\right)\sin\left(\frac{\pi}{8}\right)\left(x-\frac{\pi}{8}\right)^2-\left(\frac{1}{6}\right)\cos\left(\frac{\pi}{8}\right)\left(x-\frac{\pi}{8}\right)^3$$
This polynomial matches the function and its derivatives up to the third order in $x=\frac{\pi}{8}$.
Another approach is fitting the function and first derivative at both extremes of the interval $[0,\dfrac{\pi}{4}]$ with a third order polynomial $$f(x)=a+bx+cx^2+dx^3$$
The solution is $$\sin(x) \approx \frac{8 (-8 \sqrt{2} + (2 + \sqrt{2})\pi)}{\pi^3} x^3 + \frac{(24 \sqrt{2} - 2 (4 + \sqrt{2}) π)}{\pi^2} x^2 + x$$
and its quadratic error as defined in the answer by Claude Leibovici lies between $10^{-7}$ and $10^{-9}$, at about $4.5·10^{-8}$.
If you want the "best" approximation of $\sin(x)$ for $x_1 \leq x \leq x_2$ using (say) a cubic polynomial, you could minimize with respect to $(a,b)$ $$I=\int_{x_1}^{x_2} \left(\sin(x)-(ax+bx^3) \right)^2$$ This would correspond to a linear regression with an infinite number of data points.
Using $x_1=0$ and $x_2=\frac \pi 4$, this would lead to $$a=\frac {80640 \sqrt{2}-20160 \sqrt{2} \pi -1920 \sqrt{2} \pi ^2+60 \sqrt{2} \pi ^3 }{\pi^5}\approx 0.999259$$ $$b=-\frac {2150400 \sqrt{2}-537600 \sqrt{2} \pi -53760 \sqrt{2} \pi ^2+2240 \sqrt{2} \pi ^3 }{\pi^7}\approx -0.161035$$ For these values $I\approx 6.81 \times 10^{-9}$ while using Taylor coefficients $(a=1,b=-\frac 16)$ we should get $I\approx 4 32\times 10^{-7}$ that is to say almost $64$ times larger.