2
$\begingroup$

Solving a minimization problem in version 13 on Windows 10, I obtain

Maximize[{Sin[x + Sin[x]] + Sin[x - Sin[x]] + (Pi/2 - 2)*Sin[Sin[x]], 
x >= 0 && x < 2*Pi}, x]//FullSimplify

{2 Cos[Sin[Root[{Pi Cos[Sin[#]] - 4 Sin[Sin[#]] Sin[#]& , 0.9033391107665128473590217051048716426220.300104378161908}]]]\ Sin[Root[{Pi Cos[Sin[#]] - 4 Sin[Sin[#]] Sin[#]& , 0.9033391107665128473590217051048716426220.300104378161908}]] + 1/2 (-4 + \[Pi]) Sin[Sin[Root[{Pi Cos[Sin[#]] - 4 Sin[Sin[#]] Sin[#]& , 0.9033391107665128473590217051048716426220.300104378161908}]]]\ , {x -> Root[{Pi Cos[Sin[#]] - 4 Sin[Sin[#]] Sin[#]& , 0.9033391107665128473590217051048716426220.300104378161908}]}}

which is not very useful as a symbolic solution.

Along with that, Mathematica is able to find an optimal solution in a closed form and this is its achievement. Indeed,

Maximize[Sin[x+Sin[x]]+Sin[x-Sin[x]]+(Pi/2-2)*Sin[Sin[x]],x]

{1/2 (-2 Sqrt[2] + Sqrt[2] \[Pi]), {x -> -47 \[Pi] - ArcSin[\[Pi]/4]}}

Since the objective function has 2*Pi as its minimal positive period, the same value is taken at

Mod[-47 \[Pi] - ArcSin[\[Pi]/4], 2*Pi]

\[Pi] - ArcSin[\[Pi]/4]

N[%]

2.23825

and

Plot[Sin[x + Sin[x]] + Sin[x - Sin[x]] + (Pi/2 - 2)*Sin[Sin[x]], {x,0, 2*Pi}]

enter image description here confirms it.

How to obtain {1/2 (-2 Sqrt[2] + Sqrt[2] \[Pi]), {x -> Pi-ArcSin[Pi/4]}} programmatically?

$\endgroup$
1
  • $\begingroup$ BTW, FunctionPeriod[ Sin[x + Sin[x]] + Sin[x - Sin[x]] + (Pi/2 - 2)*Sin[Sin[x]], x] performs 0. One more a bug. $\endgroup$
    – user64494
    Apr 28 at 15:44

1 Answer 1

6
$\begingroup$
Clear["Global`*"]

expr = Sin[x + Sin[x]] + Sin[x - Sin[x]] + (Pi/2 - 2)*Sin[Sin[x]];

{max, arg} = 
 Maximize[{expr, 0 <= x < 2 Pi}, x] // FullSimplify // Quiet

enter image description here

Maximize will have a much easier time if you simplify the expression first.

expr2 = Simplify[expr, 0 <= x < 2 Pi]

(* 2 Cos[Sin[x]] Sin[x] + 1/2 (-4 + π) Sin[Sin[x]] *)

{max2, arg2} = Maximize[{expr2, 0 <= x < 2 Pi}, x] // FullSimplify

(* {(-2 + π)/Sqrt[2], {x -> ArcSin[π/4]}} *)

max - max2 // N[#, 20] & // Quiet

(* 0.*10^-69 *)

(x /. arg) - (x /. arg2) // N[#, 20] & // Quiet

(* 0.*10^-70 *)

EDIT: Likewise with FunctionPeriod

FunctionPeriod[expr2, x]

(* 2 π *)
$\endgroup$
3
  • $\begingroup$ Quiet is not needed: Mathematica produces a warning, not an error. $\endgroup$
    – user64494
    Apr 28 at 16:18
  • 5
    $\begingroup$ Quiet should only be used for warnings and never for error messages. It removes the clutter of the warning after it has been reviewed and determined to be of no import. $\endgroup$
    – Bob Hanlon
    Apr 28 at 16:21
  • $\begingroup$ Also expr2 = Simplify[expr] works. $\endgroup$
    – user64494
    Apr 28 at 16:21

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.