# How to find the minimum value of the absolute value under this trigonometric function relationship?

Given f[x_]=2Sin[x](Sqrt[3]Cos[x]-Sin[x]),

and f[x1]f[x2]==-3,

find the minimum of Abs[x1-x2]

The following method cannot solve this problem:

Minimize[{RealAbs[x1 - x2],
4 Sin[x1] (Sqrt[3] Cos[x1] - Sin[x1]) Sin[
x2] (Sqrt[3] Cos[x2] - Sin[x2]) == -3}, {x1, x2}]

• NMinimize rapidly finds something suspiciously close to Pi/2. Simplify[Reduce[RealAbs[x1 - x2]==Pi/2&&...]] rapidly finds solutions. Simplify[Reduce[RealAbs[x1 - x2]<Pi/2&&...]] rapidly returns False but with a warning.
– Bill
Commented Mar 30 at 1:55
• It is best to find the exact value. Commented Mar 30 at 1:58
• You used Sqrt[x] in the first line code and then inside Minimize you used Sqrt[3]. What is the correct version of the equation? With Sqrt[x] or Sqrt[3]? Commented Mar 30 at 22:27
• The correct is Sqrt[3] Commented Mar 31 at 0:06

This problem can be simplified by noting that $$f(x)$$ is equivalent to:

f[x_] := 2  Sin[2 x + Pi/6] - 1


This can be seen by:

TrigExpand[f[x]] // Simplify


which yields: 2 (Sqrt[3] Cos[x] - Sin[x]) Sin[x]

This is $$\pi$$ periodic. Let $$g(x,y)=f(x) f(y)$$: then we only need consider domain $$[0,\pi]^2$$. -3 happens to be a minimum in this domain and the solution to the problem involves evaluating 2 points. I will illustrate as possible and compare with NMinimize:

g[x_, y_] := f[x] f[y]
val = {x,
y} /. {ToRules[
Reduce[g[x, y] == -3 && 0 < x < Pi && 0 < y < Pi, {x, y}]]};

Show[Plot3D[g[x, y], {x, 0, 2 Pi}, {y, 0, 2 Pi}, Mesh -> None,
PlotStyle -> Opacity[0.4]],
Plot3D[g[x, y], {x, 0, Pi}, {y, 0, Pi}, Mesh -> None,
PlotStyle -> Blue],
Graphics3D[{Red, PointSize[0.02],
Point[{#1, #2, g[#1, #2]} & @@@ val]}]]
Abs[#1 - #2] & @@@ val


This illustrates fundamental domain and points where $$g(x,y)=-3$$. The minimum is $$\pi/2$$.

This is consistent with numerical assessment:

Sqrt[NMinimize[{(x - y)^2, g[x, y] == -3}, {x, y}][[1]]]


which yields: 1.5708

My answer in this image. I think, minimum of $$|x_1 - x_2|$$ equal to $$\dfrac{\pi}{2}$$.

• Which software is used to edit the formulas and procedures in the picture? Commented Mar 31 at 23:26
• mathpix.com/snipping-tool Commented Apr 1 at 0:09

Considering the condition:

cond[x1_,x2_]=4  Sin[x1]  (Sqrt[3]  Cos[x1] - Sin[x1])  Sin[
x2]  (Sqrt[3]  Cos[x2] - Sin[x2])


we note that we have symmetries:

cond[x1,x2]==cond[x2,x1]== cond[x1+ n1 Pi,x2+n2 Pi]


The target function also has symmetries (c some constant):

tar[x1,x2]===tar[x2,x1]==tar[-x1,-x2]== tar[x1+c,x2+c]


Therefore, we will have multiple solutions:

sol[x1,x2],sol[x2,x1],sol[x1+n1 Pi,x2+ n2 Pi ]


NMinimize can deliver one of those solutions:

NMinimize[{RealAbs[x1 - x2],
4  Sin[x1]  (Sqrt[3]  Cos[x1] - Sin[x1])  Sin[
x2]  (Sqrt[3]  Cos[x2] - Sin[x2]) == -3}, {x1, x2}]

{1.5707, {x1 -> 3.66517, x2 -> 2.09446}}

• Shouldn't the constraint be  4 Sin[x1] (Sqrt[x1] Cos[x1] - Sin[x1]) Sin[ x2] (Sqrt[x2] Cos[x2] - Sin[x2]) == -3 (not Sqrt[3]...) Commented Mar 30 at 12:05
• @Ulrich Neumann Where do you see Sqrt[3]? Commented Mar 30 at 14:39
• See constraint: 4 Sin[x1] ( Sqrt[3] Cos[x1] - Sin[x1]) Sin[ x2] (Sqrt[3] Cos[x2] - Sin[x2]) == -3 in your last NMinimize Commented Mar 30 at 19:38
• @Ulrich Neumann, thank you, but I think it should be Sqrt[3]. Although in the first line it is Sqrt[x], but in his code it is Sqrt[3] and in a comment op confirms it is Sqrt[3]. Anyway, the method how to solve is independent of this. Commented Apr 1 at 15:11

We may replace RealAbs[x1-x2] by (x1-x2)^2 since the minimums of these are attained for the same values of x1 and x2 . Making use of periodicity of Sin and Cos, one obtains

Minimize[{(x1-x2)^2,4 Sin[x1] (Sqrt[3] Cos[x1]-Sin[x1])*
Sin[x2] (Sqrt[3] Cos[x2]-Sin[x2])==-3&&


Minimize::ztest: Unable to decide whether numeric quantities {-4 (<<6>>+2 <<1>> ArcTan[Root[{<<1>>&,<<1>>&,<<1>>&},{<<1>>}]]-ArcTan[Root[{<<3>>},{<<3>>}]]^2),-4 (<<1>>),-4 <<1>>,-4 (ArcTan[<<1>>]^2-<<1>>^2-<<1>>+<<1>>+<<1>>-<<1>>^2),-4 (<<1>>)} are equal to zero. Assuming they are.{\[Pi]^2/4, {x1 -> -((5 \[Pi])/6), x2 -> -(\[Pi]/3)}}

• Why do we need to limit the range of x1 and x2 in order to solve for them? Commented Mar 31 at 0:11
• We may assume those restrictions without loss of generality as explained in the answer. Don't know why Minimize fails without x1>-Pi&&x1<=Pi&&x2>-Pi&&x2<=Pi. Commented Mar 31 at 4:32

I believe the correct version of the equation is with Sqrt[3].

I manually found a solution {x1 -> (7 π)/6, x2 -> (2 π)/3} which seems to coincide with numeric solution in other answers.

Clear[f]

f[x_] := 2 Sin[x] (Sqrt[3] Cos[x] - Sin[x])
f[x1]*f[x2]
{% == -3, x1 - x2} /. {x1 -> (7 π)/6, x2 -> (2 π)/3} // FullSimplify

{x1 -> (7 π)/6, x2 -> (2 π)/3} // N
x1 - x2 /. {x1 -> (7 π)/6, x2 -> (2 π)/3} // N

Clear[f]


4 (Sqrt[3] Cos[x1] - Sin[x1]) Sin[x1] (Sqrt[3] Cos[x2] - Sin[x2]) Sin[x2]

{True, π/2}

{x1 -> 3.66519, x2 -> 2.0944}

1.5708

• Can you ground your claim "I manually found a solution {x1 -> (7 π)/6, x2 -> (2 π)/3}"? Commented Mar 31 at 4:33