# [Maxima] solution of quadratic equations -- incorrect solution

Krishna Myneni krishna.myneni at ccreweb.org
Mon Jul 2 18:38:35 CDT 2012

Previously, I posted that Maxima's solve() was unable to solve a system
of two quadratic equations directly. Several workarounds were suggested
to find the solution to the following system of equations:

e1:   (x - a)^2 + (y - b)^2 = r1^2

e2:  (x - c)^2 + (y - d)^2 = r2^2

While the workarounds permit Maxima's solve() to obtain analytic
solutions to the above equations, we have found that Maxima gives an
incorrect solution to a slight variant of the above equations. Instead
of the general equations above, it is simpler to illustrate the problem
with the following eqns:

e1:  x^2 + y^2 = (r1 - err)^2

e2: (x - 1)^2 + (y - 1)^2 = (r2 - err)^2

If we first find the analytic solutions to the set, [x^2 + y^2 = r1^2,
(x-1)^2 + (y-1)^2 = r2^2], and then find the solutions to the above
equations with "err", substituting err=0 into the latter gives solutions
which are not the same as the former, as shown below. Comparing the
algebraic expressions with err=0 show that the x-solutions are the same,
but the y-solutions have a sign error in product terms r1*r2.

(%i1) e1: x^2  + y^2  = r1^2;
2    2     2
(%o1)                            y  + x  = r1
(%i2) e2: (x-1)^2  + (y-1)^2  = r2^2;
2          2     2
(%o2)                      (y - 1)  + (x - 1)  = r2

(%i4) solve([e1,e1-e2],[x,y]);

4        2        2     4       2          2     2
sqrt(- r2  + (2 r1  + 4) r2  - r1  + 4 r1  - 4) + r2  - r1  - 2
(%o4) [[x = - ---------------------------------------------------------------,
4

2               2             2               2          2     2
y = (sqrt(- r2  + 2 r1 r2 - r1  + 2) sqrt(r2  + 2 r1 r2 + r1  - 2) - r2  + r1 + 2)/4],

[x =
4        2        2     4       2          2     2
sqrt(- r2  + (2 r1  + 4) r2  - r1  + 4 r1  - 4) - r2  + r1  + 2
---------------------------------------------------------------,
4

2               2             2               2          2
y = - (sqrt(- r2  + 2 r1 r2 - r1  + 2) sqrt(r2  + 2 r1 r2 + r1  - 2) + r2

2
- r1  - 2)/4]

]

Generalizing these equations slightly, and finding the new solutions, we have,

(%i15) e1: x^2  + y^2  = (r1-err)^2;
2    2             2
(%o15)                       y  + x  = (r1 - err)
(%i16) e2: (x-1)^2  + (y-1)^2  = (r2-err)^2;
2          2             2
(%o16)                 (y - 1)  + (x - 1)  = (r2 - err)
(%i17) sol: solve([e1,e1-e2],[x,y]);

(%o17) [[x = - (sqrt(- r2  + 4 err r2  + (2 r1  - 4 err r1 - 4 err  + 4) r2
2        2                    4           3             2    2
+ (- 4 err r1  + 8 err  r1 - 8 err) r2 - r1  + 4 err r1  + (4 - 4 err ) r1
2          2                2
- 8 err r1 + 8 err  - 4) + r2  - 2 err r2 - r1  + 2 err r1 - 2)/4,

2                          2                   2
y = (sqrt(- r2  - 2 r1 r2 + 4 err r2 - r1  + 4 err r1 - 4 err  + 2)
2               2          2                2
sqrt(r2  - 2 r1 r2 + r1  - 2) - r2  + 2 err r2 + r1  - 2 err r1 + 2)/4],

4           3        2                   2        2
[x = (sqrt(- r2  + 4 err r2  + (2 r1  - 4 err r1 - 4 err  + 4) r2
2        2                    4           3             2    2
+ (- 4 err r1  + 8 err  r1 - 8 err) r2 - r1  + 4 err r1  + (4 - 4 err ) r1
2          2                2
- 8 err r1 + 8 err  - 4) - r2  + 2 err r2 + r1  - 2 err r1 + 2)/4,

2                          2                   2
y = - (sqrt(- r2  - 2 r1 r2 + 4 err r2 - r1  + 4 err r1 - 4 err  + 2)
2               2          2                2
sqrt(r2  - 2 r1 r2 + r1  - 2) + r2  - 2 err r2 - r1  + 2 err r1 - 2)/4]]

If we set err = 0, the equations to be solved are identical to the original equations. However, setting err = 0 in the solutions does not give the same results as before. The x-solutions are the same, but the y-solutions have product terms r1*r2 which have a different sign from the solutions of the original equations. The solutions to the problem are incorrect.

Krishna

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20120702/79892316/attachment-0001.html>