We have the equation $x^3+2x-1=0$.Find the solution of this equation correct to $5$ decimal places using Newton's method.
Could anyone help me how to use the newton's method when we want to find the solution with correct to five decimal places?
We have the equation $x^3+2x-1=0$.Find the solution of this equation correct to $5$ decimal places using Newton's method.
Could anyone help me how to use the newton's method when we want to find the solution with correct to five decimal places?
On
Make an initial guess. My guess would be $x=0$, so that $f(x) = -1$. Note that $f'(x) = 3x^2+2$.
Now, by the Newton Raphson method, let us start our process:
$x_0=0$
$x_1=0 - \frac{f(0)}{f'(0)} = 0.5$.
$x_2=0.5- \frac{f(0.5)}{f'(0.5)} = 0.5-\frac{1}{22} = \frac{5}{11}=0.45454545$.
$x_2=0.45454545-\frac{f(0.45454545)}{f'(0.454545)} = 0.453398$.
$x_2=0.453398-\frac{f(0.453398)}{f'(0.453398)} = 0.453398$.
Hence my answer is coming to $0.453398$, which when rounded to five decimal places comes to $0.453340$.
On
The equation $x^3+2x=1$ has a unique real solution since the derivative of $f(x)=x^3+2x-1$ is always positive, hence $f(x)$ is an increasing function. Since $f\left(\frac{1}{2}\right)=\frac{1}{8}>0$ and $f$ is convex over $\mathbb{R}^+$, Newton's method with starting point $x_0=\frac{1}{2}$ converges quadratically to the root of $f$. Newton's iteration in this case is $$ x \mapsto \frac{1+2x^3}{2+3x^2} $$ so the sequence of approximations is given by $$ \frac{1}{2},\;\frac{5}{11},\; \frac{1581}{3487},\; \frac{50302634185}{110945952227} $$ and the last two terms yet differ by less than $7\cdot 10^{-7}$. It is not difficult to bound $f'$ on $\left(0,\frac{1}{2}\right)$ and deduce that the last term gives the wanted digits: $$ \frac{50302634185}{110945952227}=\color{red}{0.45339}76515\ldots $$ If we replace the starting point $x_0=\frac{1}{2}$ with the starting point $x_0=\frac{4}{9}$ suggested by the secant method, we achieve the same accuracy in just $\color{red}{\large 2}$ steps.
By the (hyperbolic) trigonometric form of the roots of a cubic polynomial, the exact root is given by $$ \sqrt{\frac{8}{3}}\,\sinh\left(\frac{1}{3}\text{arcsinh}\sqrt{\frac{27}{32}}\right).$$
On
$\newcommand{\angles}[1]{\left\langle\,{#1}\,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{\mathrm{i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\Li}[1]{\,\mathrm{Li}_{#1}} \newcommand{\mc}[1]{\mathcal{#1}} \newcommand{\mrm}[1]{\mathrm{#1}} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$ Yesterday, I posted this answer in another question of $\texttt{@Mantol Inis}$, who is the current OP. However, that question was related to the Bisection Method and I had to delete it. $\texttt{@Claude Leibovici}$ calls this question to my attention by remarking that my answer was in the wrong post. Anyway, I just moved it to the right place.
Since $\ds{\verts{x^{3} + 2x - 1}_{\ x\ =\ 0}\,\,\,\,\, =\,\, 1}$ and $\ds{\expo{\ic\theta}}$, with $\ds{\theta \in \mathbb{R}}$, is not a root; there is a root $\ds{z \in \mathbb{C}}$ with $\ds{\verts{z} < 1}$. Anyway, we can check that $$ \left.\vphantom{\Large A}x^{3} + 2x - 1\right\vert_{\ x\ =\ -1} = -4 < 0 \qquad\mbox{and}\qquad \left.\vphantom{\Large A}x^{3} + 2x - 1\right\vert_{\ x\ =\ 1} = 2 > 0 $$ You can start with the guess $\ds{x = 0}$. $\texttt{Newton-Rapson}$ finds a real root with $\ds{5}$ decimal places in $\ds{\large\color{#f00}{3\ !!!}}$ steps.
This is a 'short $\texttt{javascript}$ code':
/* javascript example */
"use strict";
var maxIter = 4; // Iterations
var n = 0; // Iteration index
var x = 0; // Guess
var x2 = null;
while (n < maxIter) {
document.write(x + "\n");
x2 = x*x;
x -= (x*(x2 + 2.0) - 1.0)/(3.0*x2 + 2.0); // Newton-Rapson
++n;
}
document.write(x + "\n");
The result is given by:
\begin{align}
&0
\\
&0.5
\\
&0.454545
\\
\imp\quad &\color{#f00}{0.45339}83366790937769
\\
&\color{#f00}{0.45339}76515166477918
\end{align}
and
$\ds{\quad\left.\vphantom{\Large A}x^{3} + 2x - 1\right\vert_{\ x\ =\ 0.45339}\,\,\,\,\,\, =\,\,\,\,\,\, -2.00217 \times 10^{-5}}$.
We can modify the code to check the 'tolerance' ( with some definition ) in each iteration. The present example used ( to be brief ) the old 'by inspection method".
Try an initial guess: $x_0=1$. Now the derivative of the equation is $3x^2+2$, so the iteration we use is $$x\leftarrow x-\frac{x^3+2x-1}{3x^2+2}$$ (x by itself is on the left, subtracted by function over derivative.) Iterating this we find $$x_1=0.6$$ $$x_2=0.464935\dots$$ $$x_3=0.453467\dots$$ $$x_4=0.453397\dots$$ $$x_5=0.453397\dots$$ and so we find the root of the equation to 5 decimal places as 0.45340.