Interpolating $f$ and approximating its derivative

796 Views Asked by At

We are given $x_0 = 1, x_1 = \frac{4}{3}$ and $x_2 = 2$. Find a parabola which agrees with function $f(x) = (x + 1)\sin(x)$ in the given points. Afterwards derive a formula for the approximation of the $f'$ i.e. the derivative in $x_1$. What is the approximation of $f'(x_1)$ for function f?

I did the first step using interpolation and got the polynomial $p(x) = -1.0647x^2 + 4.2390x - 1.4914.$ Now I do not know how to use this to approximate the derivative. Should I just compute the derivative of the polynomial $p$? What about the approximation then?

3

There are 3 best solutions below

0
On BEST ANSWER

$$ f\left(x \right) = \left(x + 1\right)\sin x \implies \left\lbrace \begin{alignedat}{4} f\left(x_0\right)&= 2\sin \left(1\right) &&\approx 1.68,\qquad &\text{where} \quad x_0&=1 \\ f\left(x_1\right)&= \tfrac{7}{3}\sin \left(\tfrac{4}{3}\right)&\, &\approx 2.27, &\text{where} \quad x_1&=4/3 \\ f\left(x_2\right)&= 3\sin \left(2\right) &&\approx 2.73,& \text{where} \quad x_2&=2& \\ \end{alignedat} \right. $$

The general form of equation of parabola is $$ y-\widehat{y} = k\left(x-\widehat{x}\right)^2\qquad \text{ or }\qquad y\left(x\right) = ax^2+bx+c $$

Substituting known values we get system of equations

$$ \left\lbrace\begin{aligned} y\left(x_0\right) =f\left(x_0\right)\\ y\left(x_1\right) =f\left(x_1\right) \\ y\left(x_2\right) =f\left(x_2\right) \end{aligned}\right. \implies \left\lbrace\begin{aligned} ax_0^2+bx_0+c &= 2\sin \left(1\right) \\ ax_1^2+bx_1+c &= \tfrac{7}{3}\sin \left(\tfrac{4}{3}\right) \\ ax_2^2+bx_2+c &= 3\sin \left(2\right) \\ \end{aligned}\right. \iff \left\lbrace\begin{aligned} a+b+c & \approx 1.68 \\ \tfrac{16}{9}a+\tfrac{4}{3}b+c &\approx 2.27 \\ 4a +2b+c &\approx 2.73\\ \end{aligned}\right. $$

Solving the last system of linear equations for coefficients $a,b$, and $c$ will give you general form of parabola.


As for approximating derivatives, I recommend following advise of @caverac and using Divided differences, or use straightforward Finite difference formula

$$ f'\left(x_1\right)\approx\frac{f\left(x_2\right)-f\left(x_0\right)}{x_2-x_0} = \frac{2\sin 1 -3\sin 2}{1}\approx -1.045 $$

5
On

A quadratic $p$ approximating $f$ satisfies $f(x)=p(x)+O(|x-x_i|^n),\,n\ge 3$ in a sufficiently small neighbourhood of $x_i,\,i\in\left\{0,\,1,\,2\right\}$. Thus $f'(x)=p'(x)+O(|x-x_i|^{n-1})$ in the same neighbourhood. In particular, $p'$ is a linear approximation of $f'$ with an error term $\in o(|x-x_i|)$. So the short answer is yes, you can just differentiate $p$.

The obvious alternative approach would be to seek a line of best fit to the values of $(x_i,\,f(x_i))$; I'll leave it to you to see whether that gives the same result. Another option is $y=p(x_1)+p'(x_1)(x-x_1)$.

3
On

Look at this plot

enter image description here

Even though the interpolation works pretty good for reproducing the value of the function at $x_1$ (by design, of course), it makes a poor job at reproducing the value of the derivative. Probably that's the point of the problem

If you use divided differences you can include information about the derivative when you're interpolating