Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

General methods for parametric solutions of quadratic and cubic equations explained using examples.

Views: 240
License: GPL3
Kernel: SageMath (Development, Py3)

Solving equations using geometry

Pythagoras' theorem states that

the sum of the squares of the sides of a right-angled triangle is the square of the hypotenuse More algebraically, if XX and YY denote the (lengths of the) sides of a right-angled triangle and ZZ denotes the (length of the) hypotenuse then we have the equation X2+Y2=Z2 X^2+Y^2=Z^2

Equally importantly, the converse is also true. If a triangle has sides of length XX, YY and ZZ that satisfy the above equation, then the corner of the triangle enclosed by XX and YY is a right-angle.

Practical Applications

One of the practical uses of this result is to make right-angles with a piece of rope. (Which can be used to mark out rectangular pieces of land.) Take a piece of circular rope of length 12 and mark off lengths of 3, 4 and 5 on it. If we stretch the rope by three people pulling at these three points, then the person who is at the corner of 3 and 4 is holding a right-angle. This works because 32+42=52 3^2+4^2=5^2

General Solution --- as "magic"!

One could ask how we can write down more such triples like (3,4,5)(3,4,5). One can show that every triple is obtained from a triple of the form (m2n2,2mn,m2+n2)(m^2-n^2,2mn,m^2+n^2); for example we get (3,4,5)(3,4,5) when we take (m,n)=(2,1)(m,n)=(2,1). How does one come up with such a solution? It looks like magic to come up with it!

Algebra for the Solution

First of all, one can divide by ZZ (since, if Z=0Z=0, then XX and YY are 0 which is a "trivial" or pointless solution!) to get the equation x2+y2=1 x^2+y^2=1 which we recognise as a circle. Next, a circle has 1 dimension, so we look for a parametric solution in the form (x(t),y(t))(x(t),y(t)).

Now you may think (if you know too much!) that the natural solution in this form is (cos(t),sin(t))(\cos(t),\sin(t)), but those are complicated functions to define and calculate! A much easier solution is x(t)=1t21+t2 and y(t)=2t1+t2 x(t)= \frac{1-t^2}{1+t^2} ~\text{and}~ y(t)=\frac{2t}{1+t^2} We check easily that x(t)2+y(t)2=1x(t)^2+y(t)^2=1 by some simple algebra. Now, we put any fraction n/mn/m in place of tt to get the point ((m2n2)/(m2+n2),2mn/(m2+n2))((m^2-n^2)/(m^2+n^2),2mn/(m^2+n^2)) on the circle. To get a solution of the original equation we "clear" denominators.

Geometry for the Solution

Of course, there is still some magic left.

How did one write the parametric solution (x(t),y(t))(x(t),y(t))?

This is where geometry comes into play.

We have an "obvious" point on the circle given by (1,0)(1,0). Take a line through it with slope tt, which is given by the equation y=t(x1)y=t(x-1). Now look at the points of intersection of this line with the circle. We already have one such point, which is (1,0)(1,0). What are the co-ordinates of the other point?

p=circle((0,0),1,color="red",figsize=[2,2],axes=False) p+=line([(1,0),(-1,1)],color="blue",figsize=[2,2],axes=False) p
Image in a Jupyter notebook
x,y,t=var('x,y,t') solve([x^2+y^2==1,y==t*(x-1)],x,y)
[[x == 1, y == 0], [x == (t^2 - 1)/(t^2 + 1), y == -2*t/(t^2 + 1)]]

We didn't need to use the computer to solve this! In any case, we see that the solution is the same as the one we got earlier except that tt has been replaced by t-t.

Generalise

There is nothing special about the circle!

We can use this method to solve a quadratic equation in any number of variables, given one solution.

For example, consider x2+y2+yzz2=1 x^2+y^2+yz-z^2 = 1 which has the "obvious" solution (1,0,0)(1,0,0).

A line through the point takes the form (y,z)=(s(x1),t(x1))(y,z)=(s(x-1),t(x-1)). Substituting this in the above equation gives a quadratic equation for xx:

x,y,z,s,t=var('x,y,z,s,t') eqn= x^2+y^2+y*z-z^2-1 quad=eqn.substitute(y=s*(x-1),z=t*(x-1)) quad
s^2*(x - 1)^2 + s*t*(x - 1)^2 - t^2*(x - 1)^2 + x^2 - 1
soln=solve([x^2+y^2+y*z-z^2==1,y==s*(x-1),z==t*(x-1)],x,y,z);soln
[[x == (s^2 + s*t - t^2 - 1)/(s^2 + s*t - t^2 + 1), y == -2*s/(s^2 + s*t - t^2 + 1), z == -2*t/(s^2 + s*t - t^2 + 1)], [x == 1, y == 0, z == 0]]

In other words, the general parametric solution is given by x=s2+stt21s2+stt2+1y=2ss2+stt2+1z=2ts2+stt2+1\begin{align*} x &= \frac{s^{2} + s t - t^{2} - 1}{s^{2} + s t - t^{2} + 1} \\ y &= -\frac{2 \, s}{s^{2} + s t - t^{2} + 1} \\ z &= -\frac{2 \, t}{s^{2} + s t - t^{2} + 1} \end{align*} This method allows us to find many solutions of quadratic equations once we have one solution.

All of it can be seen as a generalisation of the case of 1 variable!

Given a solution α\alpha of the equation ax2bx+c=0ax^2-bx+c=0, the other solution is given by β=baα\beta=\frac{b}{a}-\alpha.

Higher degree equations

Euler proved that the equation X3+Y3=Z3X^3+Y^3=Z^3 has no solutions other than the obvious ones with one of the variables being replaced by 0. However, it is interesting to note that as we increase the number of variables, it is possible to write down non-trivial solutions.

For example, we consider the equation X3+Y3+Z3=W3 X^3+Y^3+Z^3=W^3 As usual we can put W=1W=1 to get x3+y3+z3=1x^3+y^3+z^3=1 and look for solutions in fractions. There are a number of obvious solutions obtained by setting one of the variables to be 1 and the other two variables to be equal. How does one find non-trivial solutions such as solutions which give three positive fractions the sum of whose cubes is 1? Here is an apparently "magical" solution

378881^3+265959^3+2721684^3==2724974^3
True

Note that this is not just a large multiple of a solution!

gcd([378881, 265959, 2721684, 2724974])
1

How does one get solutions like this one? We outline a method below.

First of all we note that the line X+Y=0=ZWX+Y=0=Z-W is contained in the solutions. (We work with the homogeneous system since Sage finds that easier.) We make a change of co-ordinates to (U=X+Y,V=ZW,W,X)(U=X+Y,V=Z-W,W,X) to make this transparent.

var('x,y,z,w,u,v') eqn=x^3+y^3+z^3-w^3 neqn=eqn.substitute(y=u-x,z=v+w) quad3=expand(neqn) quad3
u^3 + v^3 + 3*v^2*w + 3*v*w^2 - 3*u^2*x + 3*u*x^2

We note that this contains the line U=V=0U=V=0.

quad3.substitute(u=0,v=0)
0

We now calculate the tangent plane at the point (U,V,W,X)=(0,0,1,t)(U,V,W,X)=(0,0,1,t) on this line.

var('t') fun=lambda var: derivative(quad3,var).substitute(x=t,w=1,u=0,v=0) fun(x)*(x-t*w)+fun(u)*u+fun(v)*v
3*t^2*u + 3*v

We now find the residual curve on this plane V+t2U=0V+t^2U=0. (Note that U=0U=0 is the equation of the line so we divide that out below.)

quad2=expand(quad3.substitute(v=-t^2*u)/(u)) print(quad2) quad2.substitute(x=t*w,u=0)
-t^6*u^2 + 3*t^4*u*w - 3*t^2*w^2 + u^2 - 3*u*x + 3*x^2
0

and note that the point (U,W,X)=(0:1:t)(U,W,X)=(0:1:t) lies on this curve.

We then find the other point of intersection of this curve with the line X=pU+tWX=pU+tW.

var('p') u1=solve(expand(quad2.substitute(x=p*u+t,w=1)/u)==0,u)[0].right_hand_side() u1
3*(t^4 + (2*p - 1)*t)/(t^6 - 3*p^2 + 3*p - 1)

Take the numerator as UU and the denominator as WW.

u2=numerator(u1) w2=denominator(u1) u2,w2
(3*t^4 + 6*p*t - 3*t, t^6 - 3*p^2 + 3*p - 1)

Now substitute back to get XX.

x2=expand(p*u2+t*w2) x2
t^7 + 3*p*t^4 + 3*p^2*t - t

Check that these satisfy the equation of the curve.

expand(quad2.substitute(x=x2,u=u2,w=w2))
0

Now substitute back to get VV.

v2=expand(-t^2*u2) v2
-3*t^6 - 6*p*t^3 + 3*t^3

Check that the given (U,V,W,X)(U,V,W,X) satisfy the equation.

expand(quad3.substitute(x=x2,u=u2,v=v2,w=w2))
0

Substitute back to get YY and ZZ. Then (X,Y,Z,W)(X,Y,Z,W) is a parametric solution to the original equation.

y2=expand(u2-x2) z2=expand(v2+w2) sol=(x2,y2,z2,w2) sol
(t^7 + 3*p*t^4 + 3*p^2*t - t, -t^7 - 3*p*t^4 + 3*t^4 - 3*p^2*t + 6*p*t - 2*t, -2*t^6 - 6*p*t^3 + 3*t^3 - 3*p^2 + 3*p - 1, t^6 - 3*p^2 + 3*p - 1)

Check that these satisfy the equation.

expand(eqn.substitute(x=x2,y=y2,z=z2,w=w2))
0

Now, we need to use these to find an actual solution with positive values for x=X/Wx=X/W, y=Y/Wy=Y/W, z=Z/Wz=Z/W.

The naive method is to take a random integer dd upto some bound and choose values of tt and pp which are random fractions with this dd as denominator. If we find the required values we stop. Taking the bound to be 10 seems to work. (One could also use a for loop but perhaps this random approach is faster!) We do the checks using floating point numbers for speed and use fractions at the end. This could case errors and yield negative solutions, but is unlikely to do so.

bound=10 found=False while not found: d=randint(1,bound) t0,p0=randint(1,d),randint(1,d) t1=t0/d;p1=p0/d sol1=[pol.substitute(t=t1,p=p1) for pol in [x2,y2,z2,w2]] if sol1[3]==0: continue sol2=(sol1[0]/sol1[3],sol1[1]/sol1[3],sol1[2]/sol1[3]) if sol2[0]<0: continue if sol2[1]<0: continue if sol2[2]<0: continue found=True t1q,p1q=QQ(t0)/d,QQ(p0)/d print((t1q,p1q)) sol1=[pol.substitute(t=t1q,p=p1q) for pol in [x2,y2,z2,w2]] sol2=(sol1[0]/sol1[3],sol1[1]/sol1[3],sol1[2]/sol1[3]) sol2
(1/5, 1/10)
(6719/25345, 9781/25345, 4937/5069)

Clear denominators to get a solution of the original equation.

mul=lcm(denominator(a) for a in sol2) big=[a*mul for a in sol2]+[mul] big
[6719, 9781, 24685, 25345]

Check it!

print(big[0],'^3+',big[1],'^3+',big[2],'^3=',big[3],'^3') print(big[0]^3+big[1]^3+big[2]^3==big[3]^3)
6719 ^3+ 9781 ^3+ 24685 ^3= 25345 ^3 16280842938625 == 16280842938625