Find root using fixed point iteration. Can this be right?

Working on old exams in basic numerical modeling, I have gotten confused by the solution proposal.

Problem: Use the fixed point iteration method to find the root for $f(x)=2x-e^{-x}$ in the interval $(0,1.6)$ with an error less than $0.02$.

My thoughts:

$g(x)=\frac{e^{-x}}{2}\$

$x_{i+1}=g(x_i), i=1,2...\$

Convergence criterion (from book):

$|x_{i+1}-g(x_{i+1})| \le \epsilon=0.02$

With $x_1=1$, $x_5=0.3595185038$ would be the root from my calculations. However, an extra computation is done in the solution proposal. Why? What is it I'm missing? Is the extra computation done due to the truncation of decimals?

Solution proposal:

Book:

 i     x_i         g(x_i)       |x_i+1-g(x_i+1)|
1  1.0000000000  0.1839397206   0.2321
2  0.1839397206  0.4159929770   0.0862
3  0.4159929770  0.3298424517   0.0297
4  0.3298424517  0.3595185038   0.0105
5  0.3595185038  0.3490061677

• The exact solution is $W(1/2)=0.35173371124919582602\dots$ so the proposed solution stops exactly when it needs to get the error less than $0.02$. Your $x_5$ doesn't seem to be right – Yuriy S Feb 21 '18 at 10:22
• How do your computations look like? your $x_5$ doesn't seem correct. – user144410 Feb 21 '18 at 10:28
• Added table with computations. – Numerical Newbie Feb 21 '18 at 10:40
• You have a typo in your $x_5$, when you first write it in the post – Yuriy S Feb 21 '18 at 11:10
• Good observation. Corrected. – Numerical Newbie Feb 21 '18 at 11:11

I think this is again some artifact of a manual evaluation of a computation result without "automatic" stopping condition. If the stopping condition were actually implemented, one would get your result. Also, it seems rather disadvantageous to write the step as $i\to i+1$. It makes no sense to compare in step $i$ the sequence elements $x_{i+1}$ and $x_{i+2}$. The algorithm is

repeat
i=i+1
x[i+1] = g(x[i])
until abs(x[i+1]-g(x[i+1]))<eps
return x[i+1]


but should be better implemented as

repeat
i=i+1
x[i+1] = g(x[i])
until abs(x[i+1]-x[i]) < eps
return x[i]


with only half the calls to $g$ and comparing $x_i$ and $x_{i+1}$ in step $i$.

• So if I understand you correctly, the extra step in the solution proposal is unnecessary, meaning that my answer is correct? – Numerical Newbie Feb 21 '18 at 11:07
• Yes, as only $x_6$ is needed for the error estimate, the computation of $x_7=g(x_6)$ is merely illustration for the continuing stabilization in the leading digits. – LutzL Feb 21 '18 at 11:14