Successive Approximation
- To: mathgroup at smc.vnet.net
- Subject: [mg37081] Successive Approximation
- From: "Flurchick, Kenneth M" <FLURCHICKK at MAIL.ECU.EDU>
- Date: Wed, 9 Oct 2002 05:25:24 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
GentleBeings
I have a straightforward implementation of successive approximations
but I cannot seem to froce the code to find the correct solution when I have
trig or exponentials involved. Can the assembled wisdom point to
straghtforward fixes I know FindRoot works the object is to teach
programming and successive approx, tho.
Thanks
kenf
Below is the code
Clear[f, g, gi, lim, r, rr, fr, \ gir, a, b, c, d, conv];
Plot[{x * ((x + 3)), 10*Sin[x]}, {x, 0.01, 2.4},
PlotStyle -> {{RGBColor[1, 0, 0], Thickness[ .006]},
{RGBColor[0, 0, 1], Thickness[ .006]}}
];
rr = FindRoot[x * ((x + 3)) == 10*Sin[x], {x, 2, 0.01, 2.4}];
f[a_] := a * ((a + 3)) /; a > 0;
g[b_] := 10. * Sin[b] /; b > 0;
gi[c_] := ArcSin[0.1*c] /; c > 0;
Print["Actual root is ", rr];
lim = 10;
r = 2.0;
conv = 10^-4;
For[i = 1, i < lim, i++,
{
fr = f[r];
gir = gi[fr];
d = Abs[N[gir] - r]; i
If[d < conv, Break[]];
r = gir;
Print["The value of x = ", r, " found after ", i, " iterations,",
" with a tolerence ", d, "\n"]
}
]
Print["The value of x = ", r, " found after ", i, " iterations,",
" with a tolerence ", d, "\n"]
"Every man, woman and responsible child has an unalienable individual,
civil, Constitutional and human right to obtain, own, and carry, openly or
concealed, any weapon -- rifle, shotgun, handgun, machine gun, anything --
any time, any place, without asking anyone's permission."
L. Neil Smith