# How to find a maximum?

FindMaximum[1/2*Abs[(o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2)]^2, {o, u}]


doesn't work. It gave me that :

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.

• A ContourPlot would help at it appears there are two points that result in a maximum: ContourPlot[ 1/2*Abs[(o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2)]^2, {o, -4, 4}, {u, -4, 4}] – JimB Jul 25 '16 at 19:22
• Try NMaximize[ 1/2*Abs[(o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2)]^2, {o, u}]. – Karsten 7. Jul 25 '16 at 19:34
• NMaximize[ 1/2*Abs[(o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2)]^2, {o, u}, Method -> "RandomSearch"] finds the other one. – Karsten 7. Jul 25 '16 at 19:37
• Maximize works as well, giving both solutions – george2079 Jul 25 '16 at 19:37

A DensityPlot helps in picking good starting values for FindMaximum:

DensityPlot[
1/2*Abs[(o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2)]^2, {o, -5, 5},
{u, -5, 5}, PlotRange -> All, PlotPoints -> 50, PlotLegends -> Automatic]


Then using the aproximate values from the DensityPlot FindMaximum locates one of the points

FindMaximum[
1/2*Abs[(o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2)]^2, {{o, -1}, {u, 1}}]


{1., {o -> -0.840896, u -> 0.840896}}

And the other point is at the opposite sign of o and u

Another option is:

NMaximize[
1/2*Abs[(o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2)]^2, {o, u}]

• Alternatively, one could locate the extrema in this way: ContourPlot[Thread[D[((o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2))^2/2, {{o, u}}] == 0] // Evaluate, {o, -5, 5}, {u, -5, 5}] – J. M.'s torpor Jul 25 '16 at 19:41
• thank you so much , it works , i appreciate, thanks again – khalid Jul 25 '16 at 20:11