# Monitoring the progress of FindRoot during evaluation [closed]

I would like to know whether there is a way to monitor the evaluation of the norm of the error of FindRoot. Sometimes the evaluation of of this for a large system can takes minutes, hours or days, and I would like to see which parameters (e.g., damping factor) can lead to improvement of the performance of FindRoot.

e.g., Suppose I solve the complex system

FindRoot[Equations, Start];


I would like to get an update at every iteration about: 1) the iteration number 2) the norm of error of the function

• Just in case you haven't seen this reference.wolfram.com/mathematica/tutorial/… The package UnconstrainedProblems has a few interesting functions- Sep 9, 2015 at 8:12
• I was not aware of this! The plotting takes time to execute but would provide great intuition for test cases. Thanks! Sep 9, 2015 at 8:24

You can use EvaluationMonitor to print progress. For example:

n = 0;
f[x_] := Cos[x];
FindRoot[f[x], {x, 8}, EvaluationMonitor :> (n++; Print[{n, f[x]^2}])]


Gives:

{1,0.0211703}
{2,1.09558*10^-6}
{3,1.46112*10^-19}
{4,9.3735*10^-32}
{x -> 7.85398}

• works great! Is there any way the stepsize could be influenced? Sep 9, 2015 at 8:41
• @Breugem What do you mean? Only to show the progress every 5 steps, say? or change the internal step size of FindRoot? Sep 9, 2015 at 8:44
• I was referring to the internal step size of Findroot Sep 9, 2015 at 8:47
• @Breugem FindRoot does not use fixed steps! Do you know the Newton method for finding roots? There the step-size depends on the gradient and the function-value. For other methods used by FindRoot the situation is equivalent. Therefore, you can not influence the step-size directly through an option. Sep 9, 2015 at 11:08
• @Breugem Here you get the stepsizes: L = {}; f[x_] = Cos[x]; FindRoot[f[x], {x, 8}, EvaluationMonitor :> (AppendTo[L, x]; Print[Abs[f[x]]])] and then StepSizes = Differences[L] Sep 9, 2015 at 13:32