In TI-Nspire CX CAS, writing:

exp▶list(fMax(sin(x),x,0,10),x)

I get:

{((π)/(2)),((5*π)/(2))}

while in Wolfram Mathematica, writing:

Maximize[{Sin[x], 0 <= x <= 10}, x]

I get:

{1, {x -> π/2}}

Is there a way to get the result above?

up vote 4 down vote accepted
Reduce[{Sin'[x] == 0, Sin''[x] <= 0, 0 <= x <= 10}, x, Reals]

x == π/2 || x == (5 π)/2

List @@ %

{x == π/2, x == (5 π)/2}

Alternatively,

Solve[{Sin'[x] == 0, Sin''[x] <= 0, 0 <= x <= 10}, x, Reals]

{{x -> π/2}, {x -> (5 π)/2}}

 x /. %

{π/2, (5 π)/2}

or

x /. {ToRules[Reduce[{Sin'[x] == 0, Sin''[x] <= 0, 0 <= x <= 10}, x, Reals]]}

{π/2, (5 π)/2}

I would use MaxValue in combination with Solve:

maxima[{expr_, cond_}, v_] := With[{m = MaxValue[{expr, cond}, v]},
    DeleteDuplicates @ Solve[expr == m && cond, v]
]

For your example:

maxima[{Sin[x], 0<=x<=10}, x]

{{x -> π/2}, {x -> (5 π)/2}}

Contrast this with the approach in kglr's answer that only looks at critical points:

maxima[{Sin[x], -1 <= x <= 1}, x]

Reduce[{Sin'[x]==0,Sin''[x]<=0,-1<=x<=1},x,Reals]

{{x -> 1}}

False

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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