Group Abstract Group Abstract

Message Boards Message Boards

0
|
11.1K Views
|
6 Replies
|
1 Total Like
View groups...
Share
Share this post:
GROUPS:

FindMaximum gives wrong answer for simple non-linear function

Posted 12 years ago
6 Replies

Thanks Marco! That solved it!

It get's kind of stuck if you choose unsuitable initial conditions. You can see that when you evaluate:

FindMaximum[{10^(-6) x^2, 0 <= x <= 10}, {x, #}, WorkingPrecision -> 30] & /@ Range[0, 10]

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:

Max[x /. (Quiet[FindMaximum[{10^(-6) x^2, 0 <= x <= 10}, {x, #}, WorkingPrecision -> 30] & /@ Range[0, 10]])[[All, 2]]]

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.

M.

POSTED BY: Marco Thiel

Sorry, that was my mistake. You are right

FindMaximum[{10^-6 x^2, 0 <= x <= 10}, x]

does not work. I copied that wrong. Sorry.

M.

POSTED BY: Marco Thiel
Posted 12 years ago

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.

POSTED BY: Karsten 7.

Thanks Marco. Unfortunately, not giving a starting value doesn't work with my original function (which has a small constant in front):

FindMaximum[{10^-6 x^2, 0 <= x <= 10}, x]

which gives the wrong answer

{1.03645*10^-6, {x -> 1.01806}}

Maximize does work, but Maximize tries to find global optima, and I'm needing to find local optima, which FindMaximum can find.

Thanks again, Mauricio

I guess that this is a numerical artefact. If you set the precision higher you get a warning:

FindMaximum[{SetPrecision[10^(-6 ) x^2, Infinity]}, {x, 0}]

gives

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 does work

Maximize[{10^(-6 ) x^2, 0 <= x <= 10}, x]

Cheers, Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard