It is a method of computing fixed points and iterated functions. This method is nearly similar to Newton-Raphson method.
Directly mathematica program code is given here.
When you run it by mathematica, you will find the following graphics.
Graphically the root is near 0.5. So we will input
x0 = 1
tol = 0.001
n = 25
The result will be displayed then.
Directly mathematica program code is given here.
Clear["`*"]; f[x_] := 1 - x Exp[x]; Plot[f[x],{x,-5,5}]; x0 = Input["Enter x0"]; tol = Input["Enter tolerance"]; n = Input["Enter total iteration"]; a = x0; g[x_] := Exp[-x]; Do[ If[Abs[g'[x0]]>1, {Print["The method is divergence"] Exit[]}]; x0 = g[a]; Print[i, PaddedForm[N[x0],{10,6}]]; If[Abs[a-x0]<tol, {Print["The solution is: ", N[x0]], Exit[]}]; a = x0; ,{i,1,n}]; Print["Maximum iteration failed"];
When you run it by mathematica, you will find the following graphics.
Graphically the root is near 0.5. So we will input
x0 = 1
tol = 0.001
n = 25
The result will be displayed then.