MathGroup Archive 1993

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

Search the Archive

Re: Producing expr == 0 from Eliminate

  • To: sergio at shark.inst.bnl.gov (Sergio Rescia)
  • Subject: Re: Producing expr == 0 from Eliminate
  • From: villegas
  • Date: Mon, 4 Oct 93 01:40:21 -0500
  • Cc: mathgroup at yoda.physics.unc.edu

Sergio Rescia asked:

> I am trying to use Eliminate to eliminate the unknown y in a system
> of 2 equations:
> 

> In[1]:= Eliminate[{ (x-a)^2+(y-b)^2==r^2 , 

>                     x^2+y^2==9 },            {y}]
> 

>            4    2           2      2
> Out[1]= r  + r  (-18 - 2 a  - 2 b  + 4 a x) == 

>  

>                2    4       2      2  2    4               3          2
> >    -81 - 18 a  - a  + 18 b  - 2 a  b  - b  + 36 a x + 4 a  x + 4 a b  x  
- 

>  

>          2  2      2  2
> >     4 a  x  - 4 b  x
> 

> 

> Is there any way to force Eliminate to produce a result in the form:
> 

> 	expr==0
> 

> Or better yet there is any smart way to compute directly the
> discriminant of the second degree equation (in x) Out[1]?


I'm not sure if you can force Eliminate to produce zero on one side of
the equation, but in one line you can manipulate Eliminate's result
to isolate 0.  Getting the discriminant will take just a couple more
lines.  See the session excerpt below.

Robby Villegas

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

In[1]:= elim = Eliminate[{(x-a)^2+(y-b)^2==r^2, x^2+y^2==9}, {y}]

         4    2           2      2
Out[1]= r  + r  (-18 - 2 a  - 2 b  + 4 a x) == 

 

               2    4       2      2  2    4               3
>    -81 - 18 a  - a  + 18 b  - 2 a  b  - b  + 36 a x + 4 a  x + 

 

           2        2  2      2  2
>     4 a b  x - 4 a  x  - 4 b  x


   The equation is stored internally as a data structure

Equal[left, right]

We can replace Equal with the operation Subtract and form a new expression:


In[2]:= eqn = Apply[(Subtract[##] == 0) &, elim]

                 2    4       2      2  2    4    4               3
Out[2]= 81 + 18 a  + a  - 18 b  + 2 a  b  + b  + r  - 36 a x - 4 a  x - 

 

           2        2  2      2  2    2           2      2
>     4 a b  x + 4 a  x  + 4 b  x  + r  (-18 - 2 a  - 2 b  + 4 a x) == 0


Now let's pull out the quadratic in x:


In[3]:= expr = First[eqn]

                 2    4       2      2  2    4    4               3
Out[3]= 81 + 18 a  + a  - 18 b  + 2 a  b  + b  + r  - 36 a x - 4 a  x - 

 

          2        2  2      2  2    2           2      2
>    4 a b  x + 4 a  x  + 4 b  x  + r  (-18 - 2 a  - 2 b  + 4 a x)


CoefficientList will give us the coefficients in x, from order 0 through
order n:


In[4]:= coeffs = CoefficientList[expr, x]

                  2    4       2      2  2    4       2      2  2
Out[4]= {81 + 18 a  + a  - 18 b  + 2 a  b  + b  - 18 r  - 2 a  r  - 

 

         2  2    4             3        2        2     2      2
>     2 b  r  + r , -36 a - 4 a  - 4 a b  + 4 a r , 4 a  + 4 b }


Now we can do an Apply again, this time using the shorthand operator "@@",
to feed the expressions in the list to a formula that expresses the
discriminant.  Throw a Factor around the result to produce a nice form:


In[5]:= d = Factor[(#2^2 - 4 #1 #3)& @@ coeffs]

            2        2    2          2        2    2          2
Out[5]= 16 b  (-9 + a  + b  + 6 r - r ) (9 - a  - b  + 6 r + r )





  • Prev by Date: Double axes in LogPlot?
  • Next by Date: Several Functions on the same graph
  • Previous by thread: Re: Double axes in LogPlot?
  • Next by thread: Re: Producing expr == 0 from Eliminate