# How to find the maximum value of this trigonometric function?

The known conditions are:

Sin[2 α + β] ==
2 Sin[β], 0 < α < π/2, 0 < β < π/2


Find the maximum value of Tan [β]

Maximize[{Tan[β], Sin[2 α + β] == 2 Sin[β],
0 < α < π/2, 0 < β < π/2,
0 < α + β < π}, {α, β}] // FullSimplify

Solve[{TrigFactor[
SubtractSides[Sin[2 α + β]] == 2 Sin[β]],
0 < α < π/2, 0 < β < π/2,
0 < α + β < π}, α]


• Solve for $\beta$ in terms of $\alpha$ and then find the value of $\alpha$ that maximizies $\tan(\beta)$. Plotting the known condition as a contour plot will give you the range of possible values for $\beta$ and give you another approach to find the maximum of $\tan(\beta)$ which I think is $\tan \left(\frac{\sqrt{3}}{3}\right)$.
– JimB
May 18 at 23:22
• Sqrt/3 .= 0.57735 is the maximum of Tan[β],but I don't how to use MMA to get this. May 19 at 2:43
• Oops! Thanks, @cvgmt. You are correct. I mistakenly put in the maximum in $\tan$ rather than the associated value of $\beta$.
– JimB
May 19 at 3:44
• The syntax TrigFactor[SubtractSides[Sin[2 α + β]] == 2 Sin[β]] returns a syntax error (and I'm not sure what you're actually trying to do with it, so I don't know how to correct it.) May 19 at 17:19
• @MichaelSeifert Find the relationship between these two angles May 20 at 1:02

use NMaximize

NMaximize[{Tan[β], Sin[2 α + β] == 2 Sin[β], 0 < α < π/2 && 0 < β < π/2 &&
0 < α + β < π}, {α, β}]
{0.57735, {\[Alpha] -> 0.523599, \[Beta] -> 0.523599}}


If the exact result is absolutely necessary, then one can build on the numerical result:

Maximize[{Tan[β], Sin[2 α + β] == 2 Sin[β], 4/10 < α < 6/10 &&
4/10 < β < 6/10}, {α, β}]
{1/Sqrt, {α -> π/6, β -> π/6}}


supplement

Maximize[{Tan[β], Sin[2 α + β] == 2 Sin[β], 0 < α < π/2 &&
0 < β < π/2}, {α, β}] // Simplify
{1/Sqrt, {β -> π/6, α -> π/6}}


f = Tan[β];
g = Sin[2 α + β] - 2 Sin[β];
L = f + λ g;
sol = First @ Solve[{Grad[L, {α, β}] == 0 && g == 0 && 0 < α < π/2 && 0 < β < π/2 && 0 < α + β < π}, {α, β}, {λ}]
{α -> π/6, β -> π/6}

f /. sol
1/Sqrt


It seems Maximize is buggy.

• This method is also very good, it can calculate the maximum value. But it's best to calculate the exact value of its maximum value! May 20 at 0:59
• 4/10 < α < 6/10 && 4/10 < β < 6/10How did these two ranges come from? May 22 at 0:09
• As already mentioned, from the numerical calculation.
– rmw
May 22 at 8:34
• Maximize[{Tan[\[Beta]], And[Sin[2 \[Alpha] + \[Beta]] == 2 Sin[\[Beta]], 0 < \[Alpha] < \[Pi]/2, 0 < \[Beta] < \[Pi]/2]}, {\[Alpha], \[Beta]}] // FullSimplify May 22 at 21:46
• Maximize[{Tan[\[Beta]], Sin[2 \[Alpha] + \[Beta]] == 2 Sin[\[Beta]] && 0 < \[Alpha] < \[Pi]/2 && 0 < \[Beta] < \[Pi]/2}, {\[Alpha], \[Beta]}] // FullSimplify May 22 at 21:46

A contour plot of the condition shows that $$\beta$$ will need to be between 0 and around 0.5:

ContourPlot[Sin[2 α + β] == 2 Sin[β], {α, 0, π/2}, {β, 0, π/2},
FrameLabel -> (Style[#, Bold, 24, Italic] &) /@ {"α", "β"}] We can solve for $$\beta$$ in terms of $$\alpha$$:

(sol = Simplify[Solve[Sin[2 α + β] == 2 Sin[β], β],
Assumptions -> 0 < α < π/2]) // TableForm Now plot $$\beta$$ over the values of $$\alpha$$ for each of the 4 solutions to find legitimate solutions:

Plot[β /. #, {α, 0, π/2}, Frame -> True,
FrameLabel -> (Style[#, Bold, 18, Italic] &) /@ {"α", "β"}] & /@ sol We see that only the second solution results in the required values for $$\beta$$.

Maximize[{Tan[β], 0 < α < π/2} /. sol[], α]
(* {1/Sqrt, {α -> π/6}} *)


And so the value of $$\beta$$ that maximizes $$\tan(\beta)$$ given the equality condition is

β /. sol[] /. α -> π/6
(* {π/6} *)


### Update 2

Using a custom DisplayFunction we can display the three-way relation between α, β and Tan[β] in a single ContourPlot with multiple vertical axes (displayFunction and options2 defined below):

ContourPlot[Sin[2 α + β] == 2 Sin[β], {α, 0, π/2}, {β, 0, π/2},
DisplayFunction -> displayFunction, Evaluate @ options2] displayFunction:

displayFunction = Show[#, Graphics[{ColorData @ 2,
Cases[Normal @ #, Line[x_] :>
{PointSize[Large], Line[{#, Tan@#2} & @@@ x],
ColorData@1, Point@MaximalBy[Last]@x,
Dashed,
Graphics[{Text[Style[π/6, 14], Offset[{-10, 0}, {0, 0}], {1, 0}]}]}}],
Arrow[{{0, 1} #, #} &@First[MaximalBy[Last]@x]],
ColorData@2,
Point@{#, Tan@#2} & @@@ MaximalBy[Tan@*Last]@x,
Graphics[{Text[Style[1/√3, 14], Offset[{10, 0}, {0, 0}], {-1, 0}]}]}}],
Arrow[{{#, Tan@#2}, {π/2, Tan@#2}} & @@ First[MaximalBy[Tan @* Last]@x]]},
All]}]] &;


options2:

options2 = {
FrameStyle -> {ColorData /@ {1, 2}, Automatic},
PlotPoints -> 100,
PlotRange -> {{0, Pi/2}, {0, .8}},
PlotRangeClipping -> False,
FrameLabel -> {Style[#, 18] & /@ {"β", "tan(β)"}, {Style["α", 18], None}},
FrameTicksStyle -> FontSize -> 14,
FrameTicks -> {
{ChartingScaledTicks[{Identity, Identity},
"TicksLength" -> {.03, .015}][##, 6] &,
ChartingScaledTicks[{Tan, ArcTan},
"TicksLength" -> {.03, .015}][##, 6] &},
{{0, π/6, π/2}, Automatic}},
GridLines -> {{Pi/6}, None},
ImageSize -> Large};


### Update 1

cp = ContourPlot[Sin[2 α + β] == 2 Sin[β], {α, 0, π/2}, {β, 0, π/2}];


For a visual analysis, we can construct a BSplineFunction using the coordinates of the contour line in cp:

BSF = First @ Cases[Normal @ cp, Line[x_] :> BSplineFunction[x], All];


We can use BSF with ParametricPlot3D to display α, β and Tan[β] on the three axes:

ParametricPlot3D[{#, #2, v Tan@#2} & @@ BSF[t], {t, 0, 1}, {v, 0, 1},
BoxRatios -> 1, Mesh -> None,
BoundaryStyle -> Directive[Thick, Red],
AxesLabel -> (Style[#, 16] & /@ {"α", "β", Tan@β}),
ImageSize -> Large, Lighting -> "Neutral", ViewPoint -> {2, -2, 1.5}] We can also use BSF with ParametricPlot to display the relations between α, β and Tan[β] in a 4-panel plot with shared axes (see below for the definitions of legends and options):

Legended[#, legends] & @
ParametricPlot[{BSF[t],
{-Tan[t π/2 ], t π/2  },
{-Tan[t π/2 ], -Tan[t π/2 ]  },
{#, -Tan @ #2} & @@ BSF[t]},
{t, 0, 1},
Evaluate @ options] Legends:

labels = {Sin[2 α + β] == 2 Sin[β],
Tan @ β,
Defer[Tan @ β == Tan @ β],
Sin[2 α + Tan@β] == 2 Sin[Tan@β]};

legends = MapThread[Placed[LineLegend[#, #2, LabelStyle -> 16], #3] &]@
{List /@ ColorData /@ Range,
List /@ labels,
{{.75, .95}, {.1, .95}, {.15, .05}, {.75, .05}}};


Axis annotations:

ClearAll[axisAnnotations]

axisAnnotations[{lbl1_, lbl2_}] := Arrowheads[{{-Large, 0}, {Large, 1},
Sequence @@ MapThread[{Small, #2 /. -1 -> 0,
Graphics[{Text[#, Offset[{#2 10, 0}, {0, 0}], {-#2, 0}]}]} &,
{{lbl1, lbl2}, {-1, 1}}]}];

axesstyle = {axisAnnotations[Style[#, 14] & /@ {"tan(β)", "α"}],
axisAnnotations[Style[Rotate[#, -Pi/2], 14] & /@ {"tan(β)", "β"}]};


Ticks:

ClearAll[framed]
framed = Framed[ #, Background -> White, FrameStyle -> None] &;

ticks = {{{-π/2, π/2}, {-1/Sqrt, framed[1/Sqrt]},
0, {π/6, framed[π/6]}, π/2},
{{-π/2, π/2}, {-1/Sqrt, framed[1/Sqrt]}, {π/6, framed[π/6]}, π/2}};


Prolog:

prolog = {Arrowheads[{{.025, .85}}], Dashed,
Arrow @ Partition[{{π/6, π/6},
{-1/Sqrt, π/6},
{-1/Sqrt, -1/Sqrt},
{π/6, -1/Sqrt}}, 2, 1, 1],
Gray, Arrow /@
(Partition[{{##},
{-Tan@#2, #2}, {-Tan@#2, -Tan@#2}, {#, -Tan@#2}} & @@
BSF[#], 2, 1, 1] & /@ {.15, .75})};


Options:

options = {RegionFunction -> (-π/3 <= # < π/2 &),
MeshFunctions -> {# &}, Mesh -> {{π/6}},
MeshStyle -> Directive[Red, PointSize@Large],
GridLines -> {{-1/Sqrt, π/6}, {π/6, -1/Sqrt}},
PlotRange -> {{-π/3, π/2}, {-π/3, π/3}},
AxesOrigin -> {0, 0},
AxesStyle -> (Directive[AbsoluteThickness, #] & /@ axesstyle),
Prolog -> prolog,
Ticks -> ticks,
TicksStyle -> 12,
ImageSize -> 700};


Tan @ b is monotonic over 0 < b < π/2 as can be verified using FullSimplify or FunctionMonotonicity

FullSimplify[0 < Tan' @ b , 0 <= b < π / 2]

True

FunctionMonotonicity[{Tan @ b, 0 <= b < π / 2}, b]

1


Thus, we can replace Tan @ b with b in the first argument of Maximize[...] in OP to get an exact (and fast) result:

FullSimplify @
Maximize[{b,
And[Sin[2 a + b] == 2 Sin[b], 0 < a < π/2, 0 < b < π/2,
0 < a + b < π]}, {a, b}]

 {π/6, {a -> π/6, b -> π/6}}


Then, simply take the Tan of the first argument of the solution

Tan[First @ %]

1/Sqrt

• FullSimplify @ Maximize[{b, And[Sin[2 a + b] == 2 Sin[b], 0 < a < π/2, 0 < b < π/2, 0 < a + b < π]}, {a, b}]Why is And connected in the middle of this sentence? May 22 at 0:15
• @csn899, ti works the same with or without using And to wrap all constraints. (I had a separate line defining constraints with constraints = And[....] and copy/pasted its rhs into Maximize[{b, ...},...] to save a line when I posted)
– kglr
May 22 at 1:44
• Maximize[{\[Beta], 2 Sin[\[Beta]] == Sin[2 \[Alpha] + \[Beta]], 0 < \[Alpha] < \[Pi]/2, 0 < \[Beta] < \[Pi]/2, 0 < \[Alpha] + \[Beta] < \[Pi]}, {\[Alpha], \[Beta]}] // \ FullSimplifyWhy can't we get the correct result for this? May 22 at 4:27
• @csn899, interesting -- And[...] is needed after all and FullSimplify works in myterious ways.
– kglr
May 22 at 4:39
• What is the real difference between And? May 22 at 4:43

Any algebraic equation in trigonometrics with integer multiples transformes into an algebraic equation by the stereographic projection

  t<->tan phi/2


In this case

the hopefully correct transform

      Maximize[{y, (2 x + y)/(1 + (2 x + y)^2) == (4 y)/(1 + y^2),
0 <= {x, y} <= 1}, y, Reals] /.
{x -> Tan[\[Alpha]/2],  y -> Tan[\[Beta]/2]}


results

       {\[Piecewise] -Root[3 #1^3+2 Tan[\[Alpha]/2]-14 #1^2
Tan[\[Alpha]/2]+#1 (3+16 Tan[\[Alpha]/2]^2)&,1]
0<=Tan[\[Alpha]/2]<=1

-\[Infinity]    True

,{Tan[\[Beta]/2]->\[Piecewise]  -Root[3 #1^3+2
Tan[\[Alpha]/2]-14 #1^2 Tan[\[Alpha]/2]+#1
(3+16 Tan[\[Alpha]/2]^2)&,1]    0<=Tan[\[Alpha]/2]<=1

Indeterminate    True


No comment, verification left to the reader.

• How did these replace with x and y？ May 20 at 1:04
• The easiest and obviously failsafe way is, to not change the names of the variables. Mathematicians get headaches about this way, because it only works with twosided double bookkeeping. This is the central point of all calculus and algorithmical mappings: In practice local variables are not kept in different name spaces. The old school of Euler, Lagrange and Jacobi generally used Latin and Greek characters or a tick. Both technics are not Mathematica style , one because 26 characters are a too small set, the other, Wolfram did not differentiate between superscript and Power but had an y' May 20 at 4:23
• A right idea, but badly realized. The true way is 2 Cos[\[Alpha]] Cos[\[Beta]] Sin[\[Alpha]] + Cos[\[Alpha]]^2 Sin[\[Beta]] - Sin[\[Alpha]]^2 Sin[\[Beta]] == 2 Sin[\[Beta]] /. {Sin[\[Alpha]] -> 2 x/(1 + x^2), Cos[\[Alpha]] -> (1 - x^2)/(1 + x^2), Sin[\[Beta]] -> 2 y/(1 + y^2), Cos[\[Beta]] -> (1 - y^2)/(1 + y^2)} and then Maximize[{2 y/(1 - y^2), -((8 x^2 y)/((1 + x^2)^2 (1 + y^2))) + ( 2 (1 - x^2)^2 y)/((1 + x^2)^2 (1 + y^2)) + ( 4 x (1 - x^2) (1 - y^2))/((1 + x^2)^2 (1 + y^2)) == (4 y)/( 1 + y^2), 0 <= {x, y}}, {x, y}]. Jun 16 at 18:10

Making use of TrigExpand, this can be done in 13.2.1 on Windows 10 in such a way.

Maximize[{Tan[\[Beta]], TrigExpand[Sin[2 \[Alpha] + \[Beta]] == 2 Sin[\[Beta]]],
0 <= \[Alpha] <= \[Pi]/2, 0 <= \[Beta] <= \[Pi]/2}, {\[Alpha], \[Beta]}]


{1/Sqrt, {\[Beta] -> \[Pi]/6, \[Alpha] -> \[Pi]/6}}

and a warning

Maximize::ztest: Unable to decide whether numeric quantities {-5 [Pi]-24 ArcTan[Root[1+Times[<<2>>]+Times[<<2>>]+Times[<<2>>]+Power[<<2>>]&,1,0]],7 [Pi]-24 ArcTan[Root[1+Times[<<2>>]+Times[<<2>>]+Times[<<2>>]+Power[<<2>>]&,3,0]],-11 [Pi]-24 <<1>>,[Pi]-24 ArcTan[Root[1+Times[<<2>>]+Times[<<2>>]+Times[<<2>>]+Power[<<2>>]&,3,0]],Sqrt-3 Tan[4 ArcTan[Root[<<1>>&,3,0]]]} are equal to zero. Assuming they are.