If I use FindMinimum on a function of one variable, AccuracyGoal and PrecisionGoal will find a solution to the required accuracy/precision, which will be quicker as it requires less evaluations:
test1[a_?NumericQ] := Module[{},
Abs[x[1]]/.NDSolve[{x''[t] == a x[t], x[0] == 1, x'[0] == 0},x, {t, 0, 1}][[1]] ]
Block[{c=0}, {FindMinimum[test1[a], {a,1}, AccuracyGoal -> 1,
PrecisionGoal -> 1, Method -> "PrincipalAxis", EvaluationMonitor :> c++], c}]
{{0.000711985, {a -> -2.46516}}, 17}
Block[{c=0}, {FindMinimum[test1[a], {a,1}, Method -> "PrincipalAxis", EvaluationMonitor :> c++], c}]
{{7.55525*10^-15, {a -> -2.4674}}, 35}
However, when I have a function of two variables, it seems to ignore the goals:
test2[a_?NumericQ, b_?NumericQ] := Module[{},
Abs[x[1]] /.NDSolve[{x'[t] == a + b x[t], x[0] == 1}, x, {t, 0, 1}][[1]] ]
Block[{c = 0}, {FindMinimum[test2[a, b], {a, 1}, {b, 1},
AccuracyGoal -> 1, PrecisionGoal -> 1, EvaluationMonitor :> c++],c}]
{{1.72234*10^-9, {a -> -0.611427, b -> -0.914679}}, 232}
Block[{c = 0}, {FindMinimum[test2[a, b], {a, 1}, {b, 1},
EvaluationMonitor :> c++], c}]
{{1.72234*10^-9, {a -> -0.611427, b -> -0.914679}}, 232}
As my function takes about 5 seconds to evaluate and I only care about getting the values to ~2 decimal places, this makes a big difference to how long it takes for the FindMinimum to terminate. Is there a way to get FindMinimum to respect my goals? Or a workaround to get it to stop when it keeps evaluating around the same point to get closer to the root.
I'm using v11.0.0, but it does the same on v9.