MathGroup Archive 2007

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

Search the Archive

Re: How to factor a rational

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78856] Re: How to factor a rational
  • From: Steven Siew <siewsk at bp.com>
  • Date: Wed, 11 Jul 2007 06:12:28 -0400 (EDT)
  • References: <f6vntj$ql7$1@smc.vnet.net>

Thanks to everyone who reply to me via email.

What I was looking for is the way to do a rule replacement to extract
out the rational.

Thanks to your help, I'm able to understand how to do it. For the
record , this is what

I have learned.


$ cat file7.out
Mathematica 5.2 for Students: Microsoft Windows Version
Copyright 1988-2005 Wolfram Research, Inc.

In[1]:=
Out[1]= {stdout}

In[2]:= (* Write your mathematica code below *)

In[3]:= eq1 = (4/3)*L*A - (4/3)*L*B == a*k*t

        4 A L   4 B L
Out[3]= ----- - ----- == a k t
          3       3

In[4]:= FullForm[eq1]

Out[4]//FullForm=

>   Equal[Plus[Times[Rational[4, 3], A, L], Times[Rational[-4, 3], B, L]],

>    Times[a, k, t]]

In[5]:= eq2 = (4/3)*L*(A - B) == a*k*t

        4 (A - B) L
Out[5]= ----------- == a k t
             3

In[6]:= FullForm[eq2]

Out[6]//FullForm=

>   Equal[Times[Rational[4, 3], Plus[A, Times[-1, B]], L], Times[a, k, t]]

In[7]:= eq3 = eq1 /. HoldPattern[Plus[Times[Rational[n_,m_] ,a_,b__] ,
Times[Rational[p_,m_] ,a_,z__]] /; n == -p  ]  :> Rational[n,m] * a *
(b - z)

        4 (A - B) L
Out[7]= ----------- == a k t
             3

In[8]:= FullForm[eq3]

Out[8]//FullForm=

>   Equal[Times[Rational[4, 3], Plus[A, Times[-1, B]], L], Times[a, k, t]]

In[9]:= (* End of mathematica code *)

In[10]:= Quit[];



  • Prev by Date: Re: Is there anything wrong?
  • Next by Date: Re: How to factor a rational
  • Previous by thread: Re: How to factor a rational
  • Next by thread: Re: How to factor a rational