Using Newton's method, find the root of $x^3+2x-1$ with an accuracy of $5$ decimal places.
I think the solution is $0.45339$. Am I wrong?
Using Newton's method, find the root of $x^3+2x-1$ with an accuracy of $5$ decimal places.
I think the solution is $0.45339$. Am I wrong?
On
$f(x)=x^3+2x-1$ is an increasing function over $\mathbb{R}$, since $f'(x)=3x^2+2$ is always positive.
In a similar way we have that $f(x)$ is convex over $\mathbb{R}^+$. Newton's
iteration
$$ x\to x-\frac{f(x)}{f'(x)} $$
in our case takes the form
$$ x\to \frac{1+2 x^3}{2+3 x^2} $$
and since $f\left(\frac{1}{2}\right)>0$, Newton's iteration with starting point $x_0=\frac{1}{2}$ gives a decreasing sequence that converges quadratically to the only real zero of $f(x)$. Such a sequence is
$$ \frac{1}{2},\quad\frac{5}{11},\quad \frac{1581}{3487},\quad \frac{50302634185}{110945952227} $$
where the last two ratios share the $\color{red}{0.45339}$ part of their decimal representation.
On
- $\displaystyle{\mathrm{f}:\mathbb{R} \to \mathbb{R}\,,\quad\mathrm{f}\left(\,x\,\right) = x^{3} + 2x - 1}$. Since $\,\mathrm{f}$ is a continuous function in $\displaystyle{\left[\,0,1\,\right]}$ and $\displaystyle{\,\mathrm{f}\left(\,0\,\right) \,\mathrm{f}\left(\,1\,\right) < 0}$; there is, at least, a root $r$ $\displaystyle{\in \left(\,0,1\,\right)}$.
- As a 'blind guess' we choose $\displaystyle{g = 0.5 = {0 + 1 \over 2}}$ as our 'starting point'which sets $\displaystyle{\left\vert\,g -r\,\right\vert < 0.25}$.
- With a 'little' $\texttt{C++}$ program ( see below ), I'll get:
Root = 0.4533976515
Iterations = 4
TOL = 1.564621925e-08
// newtonRapson0.cc 30-ag-16 Felix Marin
/*
http://math.stackexchange.com/questions/1908292/using-newtons-method-find-the-root-of-x32x-1-with-an-accuracy-of-5-decim/1908842#190884
*/
#include <cfloat>
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
const double TOL = 1.05*sqrt(DBL_EPSILON);
const double MAXITER = 50U;
inline double dx(double x)
{
return -(x*(x*x + 2.0) - 1.0)/(3.0*x*x + 2.0);
}
int main()
{
double d,tol,xAnt,x = 0.5;
size_t n = 0;
while (n++ < MAXITER) {
xAnt = x;
d = dx(x);
x += d;
tol = abs(xAnt + d/2.0);
tol = (tol > 0) ? (abs(d)/tol):abs(d);
if (tol <= TOL ) break;
}
cout<<setprecision(10)<<" Root = "<<x<<endl;
cout<<"Iterations = "<<n<<endl;
cout<<" TOL = "<<TOL<<endl;
return 0;
}
Does $x^3+2x-1$ have different signs for $x=0.453385$ and $x=0.453395$? If so, that's s root with 5 digits accuracy.
But actually, according to my calculator we have
$$\begin{array}{c|c} x & x^3+2x-1 \\ \hline 0.453385 & \approx -3\times 10^{-5} \\ 0.453395 & \approx -7\times 10^{-6} \\ 0.453400 & \approx +6\times 10^{-6} \end{array} $$ so the root is between $0.453395$ and $0.453400$, and should therefore be given with 5 significant digits as $0.45340$.
Since the exercise specifically asks you to use Newton's method, however, most of what you will be judged on is probably setting up the right expression to iterate, showing your successive approximations, and demonstrating when to stop iterating.