10
$\begingroup$

I use NDSolve quite a lot and have noticed that setting values for AccuracyGoal and PrecisionGoal can greatly affect the solution outcome, and can also greatly increase the calculation time required to produce a solution. As such, I have a few questions:

  1. If, for example, I set AccuracyGoal -> 18 and PrecisionGoal -> 10, will this essentially make AccuracyGoal -> 10 due to the limitation in possible decimal places available from the PrecisionGoal setting? Would there be a point in having different values of AccuracyGoal and PrecisionGoal or is it best to set them to the same value?

  2. Where does WorkingPrecision fit into the picture? What I usually do is just set AccuracyGoal and PrecisionGoal as high as possible without making the calculation time "unbearably" slow. When I try and use WorkingPrecision I always get and error saying "The precision of the differential equation ... is less than WorkingPrecision ...", so tend to ignore its use.

  3. If computation time is not an issue, what would be the best way to set AccuracyGoal and PrecisionGoal? Would they be set in such a way that you settle on a value once the NDSolve output solutions from various test values of AccuracyGoal and PrecisionGoal start to converge?

  4. I've noticed that when using NMinimize on the output InterpolatingFunction of an NDSolve solution, setting values for AccuracyGoal and PrecisionGoal in NMinimize doesn't seem to have an effect on the minimized value attained, and only seems to depend of what your AccuracyGoal and PrecisionGoal values were in NDSolve (although using low values of AG and PG in NMinimize does make a large difference). Is it pointless to set values for AccuracyGoal and PrecisionGoal when using NMinimize?

  5. And finally, I know this is a very broad question and most likely has many different ways of attacking the problem based on what you are doing, but are there any tricks or tips that may speed up NDSolve and NMinimize calculations without affecting accuracy too much? This is what I'm struggling with most at the moment.

EDIT:

  1. Is there a way to see how much error has accumulated in your NDSolve output in order to see if you need to up the accuracy and/or precision settings? I see that Mathematica uses "Numerical Precision Tracking" (http://www.ordinate.de/wolfram/TechGuide/EN/technology/offlineguide/precisiontracking.html), could this somehow be used to show error accumulation?
$\endgroup$
8
  • 3
    $\begingroup$ 1. and 2. can be answered by a close reading of the Advanced Documentation for NDSolve[]. $\endgroup$ Jul 12, 2015 at 9:18
  • 1
    $\begingroup$ 3. I'd go with setting AccuracyGoal to Infinity, and tweak PrecisionGoal and WorkingPrecision as needed, with the latter setting being set slightly higher than the former. $\endgroup$ Jul 12, 2015 at 9:20
  • 2
    $\begingroup$ 4. It's the same story with N[2., 25]: you can't ask for precision/accuracy higher than what your data has. $\endgroup$ Jul 12, 2015 at 9:21
  • 1
    $\begingroup$ 5. The obvious tips: don't use a nonstiff method on a stiff problem, and if you have known constraints or good guesses for the optima, use them! $\endgroup$ Jul 12, 2015 at 9:22
  • 1
    $\begingroup$ To 5.: Numerical methods do a lot of objective function evaluations, so it would be wise to speed up the computation time for evaluating the objective function. You might want to consider compiling it. $\endgroup$
    – Wizard
    Jul 12, 2015 at 14:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.