solution of quadratic equations -- incorrect solution
- Subject: solution of quadratic equations -- incorrect solution
- From: Viktor T. Toth
- Date: Tue, 3 Jul 2012 08:16:49 -0400
If you check your y-solutions, you will find that the differences are due to
trivial algebra and the solutions are, in fact, identical when you set
err=0. You have expressions that are formally just like sqrt(A-B)*sqrt(C-D)
vs. sqrt(B-A)*sqrt(D-C), which may appear different at first but they really
aren't. You can actually verify this using Maxima itself, as well as verify
that the solutions that were obtained indeed solve your system of equations:
(%i1) display2d:false$
(%i2) e1a: x^2+y^2=r1^2$
(%i3) e2a: (x-1)^2+(y-1)^2=r2^2$
(%i4) sola: solve([e1a,e1a-e2a],[x,y])$
(%i5) radcan(ev([e1a,e2a],sola[1]));
(%o5) [r1^2 = r1^2,r2^2 = r2^2]
(%i6) radcan(ev([e1a,e2a],sola[2]));
(%o6) [r1^2 = r1^2,r2^2 = r2^2]
(%i7) e1b: x^2+y^2=(r1-err)^2$
(%i8) e2b:(x-1)^2+(y-1)^2=(r2-err)^2$
(%i9) solb: solve([e1b,e1b-e2b],[x,y])$
(%i10) radcan(ev([e1b,e2b],solb[1]));
(%o10) [r1^2-2*err*r1+err^2 = r1^2-2*err*r1+err^2,
r2^2-2*err*r2+err^2 = r2^2-2*err*r2+err^2]
(%i11) radcan(ev([e1b,e2b],solb[2]));
(%o11) [r1^2-2*err*r1+err^2 = r1^2-2*err*r1+err^2,
r2^2-2*err*r2+err^2 = r2^2-2*err*r2+err^2]
(%i12) radcan(sola[1]-ev(solb[1],err=0));
(%o12) [0 = 0,0 = 0]
(%i13) radcan(sola[2]-ev(solb[2],err=0));
(%o13) [0 = 0,0 = 0]
Viktor
-----Original Message-----
From: maxima-bounces at math.utexas.edu [mailto:maxima-bounces at math.utexas.edu]
On Behalf Of Krishna Myneni
Sent: Monday, July 02, 2012 7:39 PM
To: maxima at math.utexas.edu
Subject: solution of quadratic equations -- incorrect solution
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