I’m trying to use FindMaximum to maximize a function of the form A F(x). However, FindMaximum gives the wrong answer when A is very small. For example,
FindMaximum[{10^-6 x^2, 0 <= x <= 10}, {x, 0}]
yields
{3.03108*10^-7, {x → 0.550553}}
but the correct answer is x->10.
The problem seems to be related with the accuracy needed for small numbers, but increasing the precision in the options does not help. That is, increasing the values in the following options yields little improvement: FindMaximum[{10^-6 x^2, 0 <= x <= 10}, {x, 0}, AccuracyGoal → 40, PrecisionGoal → 40, WorkingPrecision → 40, MaxIterations → 2000].
Also changing the method is of no help because FindMaximum can only implement Interior Point Algorithm for constrained problems.
Is the a way that FindMaximum yields the right answer with this simple function?
FindMaximum::fmgz: Encountered a gradient that is effectively zero.
The result returned may not be a maximum; it may be a minimum or a
saddle point. >>
Maximize or NMaximize is more suitable for that problem. FindMaximum tries to find a local maximum an uses numarical evaluations. Also see the “Possible Issues” part of the documentation, espacially the part about numerical bumpyness and constraint regions.
which basically uses different initial guesses in the interval. It is as I said above, Maximize is better. But if you absolutely want FindMaximum this does work:
which is really, really inefficient and slow. The Quiet is to ignore all (important) warnings that the method does not converge in the prescribed number of iterations.