2
$\begingroup$

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}]

Error:enter image description here

$\endgroup$
4
$\begingroup$

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][[1]]

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. >>

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.