# Unexpected behavior from MaxValue and Maximize

consider the following function

α = 1/Sqrt[(1 - η^2)^2 + 4 D0^2 η^2];
p1 = Plot[{Evaluate[Table[α, {D0, 0, 1, .1}]], 1/(1 + η^2)}, {η, 0, 2},
PlotRange -> {{0, 2}, {0, 3}}] i now wanted to calculate the function that goes through all the maxima of this function for $\eta \in(0,1)$.

Using

MaxValue[α, D0]


gives while

Maximize[α, D0]


yields which are both not what I'm looking for. Using the straight forward approach

max = α /. Solve[D[α, η] == 0] p2 = Plot[max[], {η, 0, 1}, PlotRange -> {{0, 2}, {0, 3}}]
Show[p1, p2] it works. I guess i didn't quite get how MaxValue works. Can someone teach me, what I did wrong?

• You can also get all the maxima with Maximize[\[Alpha], D0]. And from the docs of MaxValue under Details and Options: "MaxValue[\[Ellipsis]] is effectively equivalent to First[Maximize[\[Ellipsis]]]." That explains it. – Marius Ladegård Meyer Feb 17 '17 at 8:32
• I used that too but the correct solution is not under the given results – freddy90 Feb 17 '17 at 8:38
• The behavior you show suggests that D0 has been given a value somewhere at top-level in notebook. If so, that is source of your trouble. – m_goldberg Feb 17 '17 at 9:04
• I checked and D0 hasn't been given any value. – freddy90 Feb 17 '17 at 9:14

Forgive me if this is entirely not what you were asking but your final line:

I guess i didn't quite get how MaxValue works. Can someone teach me, what I did wrong?

suggests that perhaps an example of MaxValue doing something, anything, useful might help.

mv = MaxValue[α, η];

p3 = Plot[Evaluate[Table[mv, {D0, 0, 1, .1}]], {η, 0, 2},
PlotRange -> {{0, 2}, {0, 3}}]

Show[p1, p3] So MaxValue quite handily gives is the maximum value that is reached for each value of D0.

Likewise MaxValue[α, D0] gives us the maximum value that is reached for each value of η, which is the uppermost line in the plot:

mv2 = MaxValue[α, D0]

p4 = Plot[Evaluate[Table[mv2, {D0, 0, 1, .1}]], {η, 0, 2},
PlotRange -> {{0, 2}, {0, 3}}]

Show[p1, p4] • Thank you. I guess my attempt to do this using MaxValue was doomed to fail – freddy90 Feb 17 '17 at 12:26