Message Boards Message Boards

Symbolically solving a trigonometric system of equation

Posted 3 years ago

Hello I would like to solve following system of equation:

W1 = Lbc Cos[\[Alpha]1] - Lae + Lde Cos[\[Alpha]3] + 

   Lcd Sin[\[Alpha]3];

W2 = Lab + Lbc Sin[\[Alpha]1] + Lde Sin[\[Alpha]3] - 

   Lcd Cos[\[Alpha]3];


SOL = NSolve[{W1 == 0, W2 == 0}, {\[Alpha]3, Lcd}]

Parameters are: Lab = 0.1; Lbc = 0.1; Lae = 0.13; Lde = 0.015;

[Alpha]1 is an input parameter

I get: NSolve::ifun: Inverse functions are being used by NSolve, so some solutions may not be found; use Reduce for complete solution information.

and very long solution

Do you have any suggestions?

POSTED BY: Mateusz Lazarek
7 Replies

At least numerically the solutions are if not equal, but almost equal. The negative values of alpha1 are missing, here for alpha1 = .237:

w1a = W1 /. {Cos[\[Alpha]1] -> c1, Cos[\[Alpha]3] -> c3,  Sin[\[Alpha]3] -> Sqrt[1 - c3^2]};
w2a = W2 /. {Sin[\[Alpha]1] -> s1, Sin[\[Alpha]3] -> Sqrt[1 - c3^2],     Cos[\[Alpha]3] -> c3};
sol = Solve[{w1a == 0, w2a == 0}, {Lcd, c3}];
sol // Length
sol /. {Lab -> .1, Lbc -> .1, Lae -> .13, Lde -> .015,  s1 -> Sin[\[Alpha]1],   c1 -> Cos[\[Alpha]1]} /. \[Alpha]1 -> .237 /. (c3 -> x_) -> \[Alpha]1 -> ArcCos[x]
POSTED BY: Hans Dolhaine

What about this? Having c3 you can calculate alpha3.

w1a = W1 /. {Cos[\[Alpha]1] -> c1, Cos[\[Alpha]3] -> c3, Sin[\[Alpha]3] -> Sqrt[1 - c3^2]}
w2a = W2 /. {Sin[\[Alpha]1] -> s1, Sin[\[Alpha]3] -> Sqrt[1 - c3^2],  Cos[\[Alpha]3] -> c3}
sol = Solve[{w1a == 0, w2a == 0}, {Lcd, c3}]
sol // Length
sol /. {Lab -> .1, Lbc -> .1, Lae -> .13, Lde -> .015, 
s1 -> Sin[\[Alpha]1], c1 -> Cos[\[Alpha]1]} /. \[Alpha]1 -> .237
POSTED BY: Hans Dolhaine
Posted 3 years ago

Hi Mateusz,

It is better to work with exact numbers

sol = Solve[{Rationalize@W1 == 0, Rationalize@W2 == 0}, {\[Alpha]3, Lcd}]

Yes, the solution is "long", but can be verified as correct

W1 /. sol[[1]] /. C[1] -> 0 // Simplify
(* 0 *)

W2 /. sol[[1]] /. C[1] -> 0 // Simplify
(* 0 *)

Similarly for sol[[2]]

POSTED BY: Rohit Namjoshi

Maybe I made a mistake but after substitution I do not get 0 enter image description here

POSTED BY: Mateusz Lazarek

Those results are zero within floating point precision.

POSTED BY: Richard Frost
Posted 3 years ago

Hi Mateusz,

No, it was my mistake, should be

Rationalize@W1 /. sol[[1]] /. C[1] -> 0 // Simplify

Much better would be to Rationalize W1 and W2 first

W1 = Rationalize[Lbc Cos[\[Alpha]1] - Lae + Lde Cos[\[Alpha]3] + Lcd Sin[\[Alpha]3]];
W2 = Rationalize[Lab + Lbc Sin[\[Alpha]1] + Lde Sin[\[Alpha]3] - Lcd Cos[\[Alpha]3]];

sol = Solve[{W1 == 0, W2 == 0}, {\[Alpha]3, Lcd}];

(W1 /. sol[[1]] /. C[1] -> 0 // Simplify) == 
(W2 /. sol[[1]] /. C[1] -> 0 // Simplify) == 
(W1 /. sol[[2]] /. C[1] -> 0 // Simplify) == 
(W2 /. sol[[2]] /. C[1] -> 0 // Simplify) == 0
(* True *)

Or to Rationalize the constants first, then there is no need to Rationalize W1 and W2

Lab = Rationalize@0.1; Lbc = Rationalize@0.1; Lae = Rationalize@0.13; Lde = Rationalize@0.015;
POSTED BY: Rohit Namjoshi

Rohit, Yes to your final sentence. Floating point input led to floating point output.

POSTED BY: Richard Frost
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract