# Using Reduce to solve trig equations. Error: unable to decide whether numeric quantity .. is zero

I'm trying to find solutions to a fairly simple pair of simultaneous equations in variables $$\phi_1, \phi_2$$ using Reduce.

θ = Pi/8; (* e.g. 3.14 also doesn't work *)
points = Solve[
Reduce[{Sin[ϕ1] + 0.1 Sin[θ + ϕ1 + ϕ2] ==
0 && ϕ1 > -Pi && ϕ1 <= π &&
0.1 Sin[ϕ2] + 0.1 Sin[θ + ϕ1 + ϕ2] ==
0 && ϕ2 > -Pi && ϕ2 <= π} , {ϕ1, ϕ2}]]


However, Reduce seems to run into trouble when an external parameter $$\theta$$ in the equations is set to some decimal expansion, say 3.14 as opposed to $$\pi$$, and also when set to numbers around $$\pi/8$$. Reduce returns the empty list, while we know there are solutions. There are errors Reduce::ratnz and Reduce::ztest1:

PS: I will be scanning through many values of $$\theta$$ and also coefficients of the Sine functions so I need a fail proof way of finding all solutions in order to automate it.

A lot of trigonometric equation solving problems seem to work better if one uses the Weierstrass substitution.

With[{θ = π/8, φ1 = 2 ArcTan[u1], φ2 = 2 ArcTan[u2]},
eqs = RootReduce[GroebnerBasis[{Sin[φ1] + Sin[θ + φ1 + φ2]/10 == 0,
Sin[φ2]/10 + Sin[θ + φ1 + φ2]/10 == 0} // TrigExpand,
{u1, u2}]]];

{2 ArcTan[u1], 2 ArcTan[u2]} /. NSolve[Thread[eqs == 0], {u1, u2}, Reals]
{{-3.0444244788667807, -1.8157299550057586},
{3.0425062641101692, 1.4239899806853435},
{0.020515491894360593, 2.934985366795896},
{-0.018597277132295528, -0.1870509022832146}}


You can replace NSolve[] with Solve[] if you want to see exact solutions, but that might take you a while.

• If you omit RootReduce, Solve is relatively quick, about 1 sec. – Michael E2 Feb 2 '20 at 15:15
• Indeed, I just tried it out now, but the result will now need to be massaged with (Full)Simplify[]. Eep. – J. M.'s ennui Feb 2 '20 at 15:17
• @Rudyard, yes, inexact numbers like 0.1 often do not play nice here, so you either use fractions and exact numbers, or use something like Rationalize[]. – J. M.'s ennui Feb 2 '20 at 15:39
• @Rudyard, it looks like you found a case where preprocessing the set of equations to a Gröbner basis does not help. In that specific case, you can do this instead: With[{θ = π/6, φ1 = 2 ArcTan[u1], φ2 = 2 ArcTan[u2]}, eqs = Numerator[Simplify[{Sin[φ1] + 97/100 Sin[θ + φ1 + φ2], 97/100 Sin[φ2] + 97/100 Sin[θ + φ1 + φ2]} // TrigExpand]]]; {2 ArcTan[u1], 2 ArcTan[u2]} /. NSolve[Thread[eqs == 0], {u1, u2}, Reals] – J. M.'s ennui Feb 4 '20 at 11:57
• @Rudyard, the latter one is more general, but if it is taking too long to evaluate, that is where one might consider preprocessing with GroebnerBasis[]. – J. M.'s ennui Feb 4 '20 at 14:21
θ = Pi/8;(*e.g.3.14 also doesn't work*)
points =
Solve[{Sin[ϕ1] + 1/10 Sin[θ + ϕ1 + ϕ2] ==
0 && ϕ1 > -Pi && ϕ1 <= π &&
1/10 Sin[ϕ2] + 1/10 Sin[θ + ϕ1 + ϕ2] ==
0 && ϕ2 > -Pi && ϕ2 <= π}, {ϕ1, ϕ2}] //
N // Values


is this what you want?

{{-3.04442, -1.81573}, {0.0205155, 2.93499}, {3.04251, 1.42399}, {-0.0185973, -0.187051}}

• That's much better thanks! It still seems to have problems in some cases, say, $\theta = 3.001$ ? – Rudyard Feb 2 '20 at 15:03
• @Rudyard well, since it seems doesn't matter, you can just ignore the warning. (It happens because you use a Floating point number instead of exact number in Solve.) .If you don't want to see it, use //Quiet. – wuyudi Feb 2 '20 at 15:06
• Oh I don't mind errors; I meant it's not actually able to solve it. Another example, try:  Solve[{Sin[[Phi]1] + 0.3 Sin[ [Phi]1 + [Phi]2] == 0 && [Phi]1 > -Pi && [Phi]1 <= [Pi] && 0.1 Sin[[Phi]2] + 0.3 Sin[ [Phi]1 + [Phi]2] == 0 && [Phi]2 > -Pi && [Phi]2 <= [Pi]}, {[Phi]1, [Phi]2}] // N // Values  – Rudyard Feb 2 '20 at 15:30
• @Rudyard first , in comment , type \\ to type \ , single \ will disappear. second, you could use 3/10 instead of 0.3 . third, Solve is unable to solve this equation directly. fourth , use   to contain code. – wuyudi Feb 2 '20 at 15:49
• Thanks. Another example with coefficients rationalised below. You're saying Solve simply can't handle these? Solve[{Sin[\\[Phi]1] + 1/100 Sin[\[Phi]1 + \\[Phi]2] == 0 && \\[Phi]1 > -Pi && \\[Phi]1 <= Pi && 40/100 Sin[\\[Phi]2] + 1/100 Sin[\\[Phi]1 + \\[Phi]2] == 0. && \\[Phi]2 > -Pi && \\[Phi]2 <= Pi}, {\\[Phi]1, \\[Phi]2}] // N // Values  – Rudyard Feb 3 '20 at 15:35