# Underdetermined system of equations

Could anyone help me solve this probably simple equation?

Solve[{1 + Cos[s1] Sin[r1] + Cos[s2] Sin[r2] + Sin[r3],
Sin[r1] Sin[s1] + Sin[r2] Sin[s2],
Cos[r1] + Cos[r2] + Cos[r3]} == {0, 0, 0},
{s1, r1, s2, r2,  r3}]


Thanks a lot!

• Three equations and six unknowns? Maybe Reduce could help here. – Gustavo Delfino Jul 6 at 14:47
• Thank you for your comment, but it has been changed to 5 variables now. So can you use Reduce and solve the new equation? Thanks a lot. – Tanger Jul 6 at 14:53

Looking at the equations, there are exact solutions when $$r_1,r_2,r_3 = \pi/2$$ and $$s1=s2=(2n-1)\pi$$ for $$n\in\mathbb{Z}$$:

Table[({e1, e2, e3} /. {
r1 -> π/2, r2 -> π/2, r3 -> π/2,
s1 -> (2 n - 1) π, s2 -> (2 n - 1) π}), {n, 0, 5}]


In fact you can go further. Let $$p_i=(4m_i+1)$$ and $$m_i\in\mathbb{Z}$$ for $$i=1,2,3$$, then it appears solutions exist for any combination of integers $$m_1,m_2,m_3,n_1,n_2$$ where: $$r_1=p_1\pi/2,\ r_2=p_2\pi/2,\ r_3=p_3\pi/2,\ s_1=(2n_1-1)\pi,\ s_2=(2n_2-1)\pi$$

You can generate lots of them like this and all e1,e2,e3 should be zero:

sols = {
r1 -> (4 #[] + 1) π/2,
r2 -> (4 #[] + 1) π/2,
r3 -> (4 #[] + 1) π/2,
s1 -> (2 #[] - 1) π,
s2 -> (2 #[] - 1) π} & /@
RandomInteger[{-20, 20}, {100, 5}];
{e1, e2, e3} /. sols


You can get a numerical one by minimizing the sum of squares of each equation:

{e1, e2, e3} = {
1 + Cos[s1] Sin[r1] + Cos[s2] Sin[r2] + Sin[r3],
Sin[r1] Sin[s1] + Sin[r2] Sin[s2],
Cos[r1] + Cos[r2] + Cos[r3]
};

{error, sol} = NMinimize[e1^2 + e2^2 + e3^2, {r1, r2, r3, s1, s2},
Method -> {"RandomSearch", "RandomSeed" -> 1234}]

{e1, e2, e3} /. sol

(* {3.27531*10^-32, {r1 -> -2.56633, r2 -> 0.575263, r3 -> -1.5708,
s1 -> -0.460101, s2 -> -0.460101}} *)


If you change the "RandomSeed" in NMinimize you can find other solutions. If we use seed 8888 instead we get a different solution:

{6.85631*10^-32, {r1 -> -2.45484, r2 -> 1.77734, r3 -> 0.208308,
s1 -> -0.941719, s2 -> -2.5903}}

• That is some nice thinking. May I ask if you could point to some reference describing the principle behind this ? – Indrasis Mitra Jul 6 at 14:54
• Thank you for your answer, but the solution to the old equation should not be unique. However, could you find all the solutions to the new and simpler equation in the updated question? Thanks a lot! – Tanger Jul 6 at 15:01
• @IndrasisMitra it's intuitive. If you have an equation over the reals $f(x)=0$ then you can also solve by minimizing $(f(x))^2$ because it's never negative. – flinty Jul 6 at 15:02
• Thank you for the update, but could you find any other solution that is significantly different from the one you found? Thanks a lot! – Tanger Jul 6 at 15:12
• @Tanger I've updated it - you can find other solutions by changing the "RandomSeed" in the NMinimize's Method option. However do not expect to be able to find all of the solutions this way - only a sample of them. – flinty Jul 6 at 15:17

You can set any two of the parameters and solve for the other three.

eq = {1 + Cos[s1] Sin[r1] + Cos[s2] Sin[r2] + Sin[r3],
Sin[r1] Sin[s1] + Sin[r2] Sin[s2],
Cos[r1] + Cos[r2] + Cos[r3]} == {0, 0, 0}

Solve[eq /. {s1 -> π, r1 -> 0}, {s2, r2, r3}] Solve[eq /. {s1 -> 1, r1 -> 2}, {s2, r2, r3}] /. {C -> 0, C -> 0, C -> 0} // Simplify 