0
$\begingroup$

Say I want to calculate the maximum value of a simple function of two variables:

f[r_, t_]:= r Cos[t]^3 (1 + r Sin[t]) 

with respect to the variable t. For a specific value of r there is no problem. Executing

MaxValue[{f[.1, t], 0 <= t <= 2 Pi[]}, t]

immediately returns 0.00100166. My problem arises when I want an arbitrary positive real value for r, so as to get a function of one variable. I tried a couple of variations of

Assuming[r > 0, 
 Evaluate@MaxValue[{Num[r, t], 0 <= t <= 2 Pi[]}, t]
]

but all I get in return is the comically unhelpful

MaxValue[{r Cos[t]^3 (1 + r Sin[t]) , 0 <= t <= 2 Pi[]}, t]

I know I can code a simple algorithm that finds the 0s of the derivatives and then looks at the various values to find the biggest. But this is an expensive symbolic manipulation software, I don't think it's too much to ask that some function can do this.

$\endgroup$
3
  • 1
    $\begingroup$ Observe that MaxValue[f[r, t], {r, t}] returns infinite if r can take on any positive value. $\endgroup$
    – bill s
    May 5, 2021 at 15:05
  • 1
    $\begingroup$ I think if you compare Solve[D[r Cos[t]^3 (1 + r Sin[t]), t] == 0, t] and Solve[D[r Cos[t]^3 (1 + r Sin[t]), t] == 0 && 0 <= t <= 2 \[Pi], t] and ponder the dependence of the solution set on r, it might become clearer why Maximize has trouble solving the problem generically. $\endgroup$
    – Michael E2
    May 5, 2021 at 15:19
  • $\begingroup$ It is the situation when you have to help Mathematica. $\endgroup$ May 5, 2021 at 16:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.