Finding an approximation of a function's root

98 Views Asked by At

I have the polynomial function $f (x) = x^5+2x^2+1$.

I am trying to find an approximation to its root in $[-2,-1]$, with the precision of $0.1$, and with a minimal number of steps. The answer I was given was $-17/16$. I find it incorrect, and I wish to ask for your assistance.

I have calculated $f(-2)$ and $f(-1)$, and found different signs. I then took $f(-1.5)$, $f(-1.25)$ and so on. I found that $f(-1.34375)=0.23$ and $f(-1.359375)=0.054$. Therefore, my calculations show that a precision of $0.1$ cannot be reached, and that the answer is incorrect.

What am I doing wrong ? Thank you.

3

There are 3 best solutions below

0
On

As you appear to be using the bisection method you should have:

Step1

a=-2, b=-1, c=-1.5; f(a)=-23, f(b)=+2, f(c)=-2.0938

Step2:

a=-1.5, b=-1, c=-1.25; f(a)=-2.0938, f(b)=+2, f(c)=1.0732

Step3:

a=-1.5, b=-1.25, c=-1.375; f(a)=-2.0938, f(b)=+1.07324, f(c)=-0.13364

So we now have the root is in the interval $(-1.375,-1.25)$ and the mid point of this interval $-1.3125$ is within $0.0625$ of the end points and so within $0.1$ of the root.

4
On

We can use Newton's method

$$x_{k+1} = x_k - \dfrac{f (x_k)}{f' (x_k)} = x_k - \dfrac{x_k^5 + 2 x_k^2 + 1}{5 x_k^4 + 4 x_k}$$

with initial guess, say, $x_0 = -2$. In Haskell:

λ take 10 $ iterate (\x->x-(x**5+2*x**2+1)/(5*x**4+4*x)) (-2)
[-2.0,-1.6805555555555556,-1.4768055489926624,-1.383795516323458,-1.364705763354018,-1.363965683835678,-1.3639646021027603,-1.3639646021004521,-1.3639646021004521,-1.3639646021004521]

Evaluating $f$ and $f'$ at $x_9 = -1.3639646021004521$,

λ (\x->x**5+2*x**2+1) (-1.3639646021004521)
-4.440892098500626e-16
λ (\x->5*x**4+4*x) (-1.3639646021004521)
11.849571894907545

It can also be shown that

$$\min_{x \in [-2,-1]} |f' (x)| = 1$$

If $|\Delta y| < 5 \cdot 10^{-16}$ and $\min |f'| = 1$, then the magnitude of the error can be bounded as follows

$$|\Delta x| < \frac{5 \cdot 10^{-16}}{1} = 5 \cdot 10^{-16}$$

Thus, in only $9$ iterations we get closer to the root than required.

0
On

By dichotomy, every iteration halves the uncertainty. Hence four iterations will be enough, requiring six function evaluations (five if the presence of a root is guaranteed in the initial interval).

  • $f(-2)=-23<0,f(-1)=2>0\implies x\in(-2,-1),$

  • $f(-\frac32)=-2.09375<0\implies x\in(-\frac32,-1),$

  • $f(-\frac54)=1.07324>0\implies x\in(-\frac32,-\frac54),$

  • $f(-\frac{11}8)=-0.13363<0\implies x\in(-\frac{11}8,-\frac54),$

  • $f(-\frac{21}{16})=0.550410>0\implies x\in(-\frac{11}8,-\frac{21}{16}).$