MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Solving equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17223] Re: Solving equations
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Mon, 26 Apr 1999 01:20:54 -0400
  • Organization: University of Western Australia
  • References: <7f9gh9$539@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Marcos Duarte wrote:
> 
> I'm trying to solve the following equations in Mathematica to find a
> solution for a2 and a1:
> x=d1*Cos[a1]+d2*Cos[a1+a2]
> y=d1*Sin[a1]+d2*Sin[a1+a2]
> These equations express the end-point position (x,y) of a two-link arm for a
> planar case.
> 
> The answer (which are the angles (a1,a2) for a given (x,y)) is
> straightforward:
> a2=ArcCos[(x^2+y^2-d1^2-d2^2)/(2*d1*d2)]
> a1=ArcTan[y/x]-ArcTan[(d2*Sin[a2])/(d1+d2*Cos[a2])]
> 
> But M. gets lost with all possible values that x,y,d1, and d2 can assume and
> because of the use of inverse functions.
> I also imposed the constraint that all the 4 parameters are different from
> zero, but still I don't get anything close to the answer given above.

Here is one possible approach to simplify the solution (which mimics the
solution-by-hand). First use TrigExpand:

In[1]:= eqs = {x == TrigExpand[d1*Cos[a1] + d2*Cos[a1 + a2]], 
   y == TrigExpand[d1*Sin[a1] + d2*Sin[a1 + a2]]}

Out[1]= {x == d1 Cos[a1] + d2 Cos[a1] Cos[a2] - d2 Sin[a1] Sin[a2],  
  y == d1 Sin[a1] + d2 Cos[a2] Sin[a1] + d2 Cos[a1] Sin[a2]}

Then, eliminate Cos[a1]:

In[2]:= Simplify[Eliminate[eqs, {Cos[a1]}]]

Out[2]=
   2     2
(d1  + d2  + 2 d1 d2 Cos[a2]) Sin[a1] + d2 x Sin[a2] == y (d1 + d2
Cos[a2])

which leads to a simple equation for Sin[a1]:

In[3]:= Solve[%, Sin[a1]]

Out[3]=
               -(d1 y) - d2 y Cos[a2] + d2 x Sin[a2]
{{Sin[a1] -> -(-------------------------------------)}}
                      2     2
                    d1  + d2  + 2 d1 d2 Cos[a2]

The solutions for a2 can be obtained directly: 

In[4]:= a2 /. Solve[eqs, {a1, a2}]

Out[4]=
            2     2    2    2
         -d1  - d2  + x  + y
{-ArcCos[--------------------], 
               2 d1 d2
 
             2     2    2    2
          -d1  - d2  + x  + y
  -ArcCos[--------------------], 
                2 d1 d2
 
            2     2    2    2             2     2    2    2
         -d1  - d2  + x  + y           -d1  - d2  + x  + y
  ArcCos[--------------------], ArcCos[--------------------]}
               2 d1 d2                       2 d1 d2

Cheers,
	Paul

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia           
Nedlands WA  6907                     mailto:paul at physics.uwa.edu.au 
AUSTRALIA                        http://www.physics.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________


  • Prev by Date: Re: Keyboard shortcut for switching between open notebooks
  • Next by Date: Re: Saving as Bitmaps
  • Previous by thread: Solving equations
  • Next by thread: re: interface between Mathematica and MS Word 7