Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

FindRoot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70356] FindRoot
  • From: dimmechan at yahoo.com
  • Date: Sat, 14 Oct 2006 03:06:53 -0400 (EDT)

Hello.

Let me deal with something elementary but yet confusing for me.

Consider the equation cos(x)=x.

FindRoot[Cos[x] == x, {x, 5}]
{x -> 0.7390851332151607}

This prints the value of x every time a step is taken.

FindRoot[Cos[x] == x, {x, 5}, StepMonitor :> Print[x]]

This gives a list of the steps taken.

Reap[FindRoot[Cos[x] == x, {x, 5}, StepMonitor :> Sow[x]]]
{{x -> 0.7390851332151607}, {{-1., -0.02837830412204312,
1.0296174587519653, 0.7525886779802748, 0.7391248287000711,
0.7390851335630761, 0.7390851332151607}}}

This counts the steps.

Block[{st = 0}, {FindRoot[Cos[x] == x, {x, 5}, StepMonitor :> st++],
st}]
{{x -> 0.7390851332151607}, 7}

I want to know what exactly the following command gives.

Reap[FindRoot[Cos[x] == x, {x, 5}, EvaluationMonitor :> Sow[x]]]
{{x -> 0.7390851332151607}, {{5., -54.99999999999999, -1.,
8.716216958779569,
 -0.02837830412204312, 1.0296174587519653, 0.7525886779802748,
 0.7391248287000711, 0.7390851335630761, 0.7390851332151607}}}

In versions earlier than 5.0 you could use the following command

FindRoot[Print[x]; Cos[x] == x, {x, 5}]

Why it cannot be used now?

Thanks in advance for any help.


  • Follow-Ups:
  • Prev by Date: Re: On order of options to Graphics
  • Next by Date: Re: IntervalComplement
  • Previous by thread: RE: Re: Functions inside list
  • Next by thread: Re: FindRoot