Message Boards Message Boards

[✓] Solve systems of equations with trigonometric expressions?

GROUPS:

I am fairly new to Mathematica, so this may be a simplistic question, but I want to learn. I know how to use the Solve function to solve a single equation like this:

Solve[Cot[c Degree] == 5.792, c]

and I know how to use Solve to solve a system of multiple equations like this:

Solve[{5*j + 2*r == 5, 6*j - 3*r == 9}, {j, r}]

However, when I try to solve a system of multiple equations that involves trigonometric expressions like this (some variables previously defined):

Solve[{Fr == Cos[phi Degree]*Fb + Sin[theta Degree]*Fa, 
   0 == Cos[theta Degree]*Fa - Sin[phi Degree]*Fb}, {Fa, theta}] // N

I get only a partially correct answer along with some results that are difficult to understand:

{{Fa -> -883.103, 
  theta -> ConditionalExpression[57.2958 (-2.10618 + 6.28319 C[1]), 
    C[1] \[Element] Integers]}, {Fa -> 883.103, 
  theta -> ConditionalExpression[57.2958 (1.03541 + 6.28319 C[1]), 
    C[1] \[Element] Integers]}}

What do I need to do to get Mathematica to give me a value of theta in degrees? I am sure there is a straightforward solution, but I just can't seem to find it. Thank you!

POSTED BY: Brett Stone
Answer
6 months ago

A ConditionalExpression is valid only if the given condition is satisfied. In this case, C[1] must be an integer coefficient. The solution don't seem problematic to me:

eqs = {Fr == Cos[phi Degree] Fb + Sin[theta Degree] Fa, 
   0 == Cos[theta Degree] Fa - Sin[phi Degree] Fb};
sol = Simplify@Solve[eqs, {Fa, theta}];
Simplify[eqs /. sol, Element[C[1], Integers]]

You get single solutions by giving integer numerical values to C[1]:

Simplify[sol /. C[1] -> 3]
POSTED BY: Gianluca Gorni
Answer
6 months ago

Thank you, Gianluca. I appreciate you taking the time to respond. I am not able to get that work for me. It makes sense to me that theta would be valid over a certain given range. The problem these equations I am trying to solve represent is a basic statics/physics problem, so the angels are definitely between 0 and 360 degrees. Does your statement that I can get single solutions by giving integer numerical values to C[1] somehow tell Mathematica to only consider values of theta (and phi for that matter) that are between 0 and 360? I apologize for my novice understanding of Mathematica and its terminology.

POSTED BY: Brett Stone
Answer
6 months ago

Although I don't really understand what you want to do I think there is another possible approach. For the time being I forget the Degrees, any angles may be easily converted to degrees later on.

Your second equation is easily solved for Sin [ phi ]

In[1]:= Fr1 = Fb  Cos[phi] + Fa Sin[theta];
lsg = Solve[0 == Fa Cos[theta] - Fb Sin[phi], Sin[phi]] // Flatten

Out[2]= {Sin[phi] -> (Fa Cos[theta])/Fb}

In your first equation convert Cos [ phi ] to a Sin-expression and and put the solution for Sin [ phi ] in

In[3]:= Fr2 = Fr1 /. Cos[phi] -> Sqrt[1 - Sin[phi]^2]

Out[3]= Fb Sqrt[1 - Sin[phi]^2] + Fa Sin[theta]

In[4]:= Fr3 = Fr2 /. lsg

Out[4]= Fb Sqrt[1 - (Fa^2 Cos[theta]^2)/Fb^2] + Fa Sin[theta]

Simplify this a bit

In[5]:= Fr4 = Simplify[Fr3 /. a_ Sqrt[x_] -> Sqrt[a^2 x]]

Out[5]= Sqrt[Fb^2 - Fa^2 Cos[theta]^2] + Fa Sin[theta]

and solve for theta

In[6]:= Solve[Fr4 == Fr, theta]

During evaluation of In[6]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may not be found; use Reduce for complete solution information. >>

Out[6]= {
{theta -> -ArcCos[-( Sqrt[-Fa^4 + 2 Fa^2 Fb^2 - Fb^4 + 2 Fa^2 Fr^2 + 2 Fb^2 Fr^2 - Fr^4]/(2 Fa Fr))]}, 
{theta -> ArcCos[-(Sqrt[-Fa^4 + 2 Fa^2 Fb^2 - Fb^4 + 2 Fa^2 Fr^2 + 2 Fb^2 Fr^2 - Fr^4]/(2 Fa Fr))]}, 
{theta -> -ArcCos[ Sqrt[-Fa^4 + 2 Fa^2 Fb^2 - Fb^4 + 2 Fa^2 Fr^2 + 2 Fb^2 Fr^2 - Fr^4]/(2 Fa Fr)]}, 
{theta -> ArcCos[Sqrt[-Fa^4 + 2 Fa^2 Fb^2 - Fb^4 + 2 Fa^2 Fr^2 + 2 Fb^2 Fr^2 - Fr^4]/(2 Fa Fr)]}}

To get real solutions you should consider the expression under the square root, which in this case must be > 0

In[10]:= Factor[-Fa^4 + 2 Fa^2 Fb^2 - Fb^4 + 2 Fa^2 Fr^2 + 2 Fb^2 Fr^2 - Fr^4]

Out[10]= -(Fa - Fb - Fr) (Fa + Fb - Fr) (Fa - Fb + Fr) (Fa + Fb + Fr)

Showing that one or three factors must be negative.

POSTED BY: Hans Dolhaine
Answer
6 months ago

Group Abstract Group Abstract