# Nested maximum function not working

I am trying to maximize a function which is itself a maximized function. For example, see the below.

Can someone explain this error:

Rev[p_, theta_, I_, a_, c1_] := theta*p*Min[I, a*p^c1]

V2ces[p_, theta_, I_, a_, c1_]  :=
FindMaximum[{Rev[p, theta, I, a, c1]}, p]

VDPces[p_, theta_, I_, a_, c1_] :=
Rev[p, theta, I, a, c1] + V2ces[p, theta, I, a, c1]

FindMaximum[VDPces[p, 1, 2, 2.5, -2], {p, 0.1, 5}]


From the FindMaximum documentation

FindMaximum returns a list of the form {fmax,{x->xmax,y->ymax,…}}...

So Rev[p, theta, I, a, c1] + V2ces[p, theta, I, a, c1] tries to add together a scalar (from Rev) and a list that has the structure {_, {...}}, which isn't how addition works.

So I believe you actually want FindMaxValue which returns the actual maximum value that's given in FindMaximum.

So basically change V2ces to

FindMaxValue[{Rev[p, theta, I, a, c1]}, p]


or

FindMaximum[{Rev[p, theta, I, a, c1]}, p][]


and you get

FindMaximum[VDPces[p, 1, 2, 2.5, -2], {p, 0.1, 5}]


{4.47214, {p -> 1.11803}}

albeit with the warning

FindMaxValue::lstol: The line search decreased the step size to within the tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient increase in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances. >>

• Ah got it! I am fairly new to mathematica, thank you for this explanation! – wolfsatthedoor Jan 19 at 21:19