# Solving three equations with two unknowns with constant parameters

I have the following two equations: 'r1andr2. Here,n, x, y, mpandmm are real constants. I tried the following solution, but it does not work.

Solve[{r1 (-n r2 + r1 x) - r2 (n r1 - r2 y) ==
mp, -r2 (n r1 - r2 x) + r1 (-n r2 + r1 y) ==
mm}, {r1, r2}]


Update:

r1 = Sin[a]; r2 = cos[a];


Number of equations now two.

• What is the meaning of your Update? Is this expected answer from Solve[] ? What is "a" ? Commented Jun 19 at 3:03
• @A.Kato: r1 and r2 are related by 'a' Commented Jun 19 at 13:57

You can use Reduce or the following:

Solve[{r1  (-n  r2 + r1  x) - r2  (n  r1 - r2  y) ==
mp, -r2  (n  r1 - r2  x) + r1  (-n  r2 + r1  y) ==
mm, -r2  (-n  r2 + r1  x) + r1  (n  r1 - r2  y) == 0}, {r1, r2},
MaxExtraConditions -> All]
(*  < 26 conditional solutions and a warning about a degenerate case > *)

• @Micheal E2: How to handle so many conditions!. I have only one condition that all constants are real. Commented Jun 18 at 16:47
• @SciJewel You have an overdetermined nonlinear system, so there are solutions only when the constants satisfy certain extra conditions. If you add that everything is real, that might generate more conditions and eliminate some. Solve[system, {r1, r2}, {mm}, Reals, MaxExtraConditions -> All] yields 38 solutions, some with simpler conditions. What sort of handling do you need to do? In a given specific situation, the conditions will evaluate on their own, and some solutions that are not valid under those conditions will evaluate to Undefined. Should we expect it to be less complicated? Commented Jun 18 at 17:16
• @Micheal E2: Please check the update. And n,x,y, mp, mm are all positive non-zero real numbers. Commented Jun 18 at 17:19
• @SciJewel That seems to make it worse, as far as conditions go. sol2 = Solve[{r1 (-n r2 + r1 x) - r2 (n r1 - r2 y) == mp, -r2 (n r1 - r2 x) + r1 (-n r2 + r1 y) == mm, -r2 (-n r2 + r1 x) + r1 (n r1 - r2 y) == 0, r1^2 + r2^2 == 1}, {r1, r2}, {mm}, Reals, MaxExtraConditions -> All] returns 44 solutions; some are quite complicated; but should be consistent with sine/cosine. Reduces the size by half: sol2b = ParallelMap[TimeConstrained[Simplify[# /. r_Root :> Simplify@ToRadicals@r, TimeConstraint -> 0.1], 30, #] &, sol2] /. r_Root :> Simplify@ToRadicals@r Commented Jun 18 at 17:39
• The system, with so many parameters, seems inherently complicated to me. But that doesn't mean all uses of the solution are forbidden. Depends on what you want to do. Commented Jun 18 at 17:41
\$Version

(* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *)

Clear["Global*"]

eqns = {r1  (-n  r2 + r1  x) - r2  (n  r1 - r2  y) ==
mp, -r2  (n  r1 - r2  x) + r1  (-n  r2 + r1  y) ==
mm, -r2  (-n  r2 + r1  x) + r1  (n  r1 - r2  y) == 0};


Alternatively, eliminate one of the constants.

Assuming that you want real solutions,

sol[const_Symbol] := Solve[eqns, {r1, r2}, {const}, Reals] // Simplify

(sol1 = sol[mm] // ToRadicals // Simplify)[[1]]


Length@sol1

(* 8 *)


EDIT: Either parameterize sol1 or use a replacement rule to assign values to the constants.

sol1ex = Select[
sol1 /. {mm -> 1, mp -> 2, n -> 3, x -> 4, y -> 5} // Simplify,
FreeQ[#, Undefined] &]

(* {{r1 -> Sqrt[1/55 (25 - 9 Sqrt[5])],
r2 -> 1/110 Sqrt[275 - 99 Sqrt[5]] (5 + 3 Sqrt[5])}, {r1 -> -Sqrt[
1/55 (25 - 9 Sqrt[5])],
r2 -> -(1/110) Sqrt[275 - 99 Sqrt[5]] (5 + 3 Sqrt[5])}, {r1 -> Sqrt[
1/55 (25 + 9 Sqrt[5])],
r2 -> 1/10 (5 + 3 Sqrt[5]) Sqrt[1/11 (25 + 9 Sqrt[5])]}, {r1 -> -Sqrt[
1/55 (25 + 9 Sqrt[5])],
r2 -> -(1/10) (5 + 3 Sqrt[5]) Sqrt[1/11 (25 + 9 Sqrt[5])]}} *)

sol1ex // N

(* {{r1 -> 0.29773, r2 -> 0.779468}, {r1 -> -0.29773,
r2 -> -0.779468}, {r1 -> 0.905786, r2 -> 2.37138}, {r1 -> -0.905786,
r2 -> -2.37138}} *)


EDIT 2: If r1 and r2 are related by r1 = Sin[a]; r2 = cos[a] then two constants must be eliminated. For example, given positive constants

eqns2 = {r1  (-n  r2 + r1  x) - r2  (n  r1 - r2  y) == mp,
-r2  (n  r1 - r2  x) + r1  (-n  r2 + r1  y) == mm,
-r2  (-n  r2 + r1  x) + r1  (n  r1 - r2  y) == 0,
mp > 0, mm > 0, x > 0, y > 0, n > 0} /.
{r1 -> Sin[a], r2 -> Cos[a]};

sol2 = Assuming[{mp > 0, mm > 0, x > 0, y > 0, n > 0},
Solve[eqns2, a, {mp, mm}] // Simplify]


Assuming[{x > 0, y > 0, n > 0},
{r1 -> Sin[a],  r2 -> Cos[a]} /. sol2 // FullSimplify]


• Hanton: How to handle so many conditions here. Commented Jun 18 at 16:48
• Please check for another update. Commented Jun 18 at 22:17
• You have been shown how to approach this. What have you tried? What specific problem are you having now? Commented Jun 18 at 22:33