[Date Index]
[Thread Index]
[Author Index]
Re: FindRoot anomaly (example from Mathematica Tutorial)
*To*: mathgroup at smc.vnet.net
*Subject*: [mg72237] Re: FindRoot anomaly (example from Mathematica Tutorial)
*From*: "dimitris" <dimmechan at yahoo.com>
*Date*: Fri, 15 Dec 2006 07:06:45 -0500 (EST)
*References*: <elophb$nie$1@smc.vnet.net>
In my opinion is not an anomaly!
It just happens the implemented algorithm to return a complex number
for this seed choise.
The important is that Mathematica returns the correct answer!
The following cell demonstrates Mathematica's cabability:
f[x_] := 3*Cos[x] - Log[x]
Print[StyleForm["the function", FontColor -> Blue]]; f[x]
Print[StyleForm["a plot of the function", FontColor -> Blue]];
Plot[f[x], {x, 0, 60}]
plot = Plot[f[x], {x, 1, 60}, DisplayFunction -> Identity];
Print[StyleForm["the points used by the Plot function ", FontColor ->
Blue]];
points = Cases[plot, {(x_)?NumberQ, (y_)?NumberQ}, Infinity]
Print[StyleForm["find where the function changes sign", FontColor ->
Blue]];
seeds = Position[Apply[Times, Partition[points[[All,2]], 2, 1], {1}],
x_ /; x <= 0]
Print[StyleForm["between this points in x axis there is a change in
sign of f[x]", FontColor -> Blue]];
samples = Extract[Partition[points[[All,1]], 2, 1], seeds]
Print[StyleForm["the roots, at last!", FontColor -> Blue]];
(FindRoot[f[x] == 0, {x, #1[[1]], #1[[2]]}] & ) /@ samples
Regards
Dimitris
Ï/Ç howardfink at gmail.com Ýãñáøå:
> FindRoot[3Cos[x] == Log[x], {x, 1}] is on page 12 of the tutorial that
> starts up in Mathematica 5.
> I was interested in how the seed affects the answer, so I made a table
>
> sol = Table[FindRoot[3Cos[x] == Log[x], {x, b}], {b, 100}];
>
> and then plotted the solutions
>
> ListPlot[x /. sol]
>
> I got a nice table, but the seed of 22 returns {x -> -207.932 +
> 1.39227 i]}
>
> so the plot returns the error:
> Graphics::gptn: Coordinate -207.932 + 1.39227\\[ImaginaryI] in {22,
> -207.932 \
> + 1.39227\\[ImaginaryI]} is not a floating-point number.
>
> The other 99 results make a nice plot.
Prev by Date:
**Re: circular infinity**
Next by Date:
**RE: Combining ListPlot3D with Show[]**
Previous by thread:
**Re: Re: FindRoot anomaly (example from Mathematica**
Next by thread:
**How to use the max value from the solution of NDSolve ?**
| |