Re: Producing expr == 0 from Eliminate

• To: mathgroup at yoda.physics.unc.edu
• Subject: Re: Producing expr == 0 from Eliminate
• From: villegas
• Date: Fri, 8 Oct 93 08:34:43 -0500

```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: Re: Eigensystem Misbehavior
• Next by Date: 3-Day Hands-On Mathematica Workshops in Santa Clara
• Previous by thread: Re: Producing expr == 0 from Eliminate
• Next by thread: Several Functions on the same graph