# Making an ellipse look like an ellipse # # Suppose we have a dog in a yard. We know, or should know, that if we # tie his leash down at one point and let him roam freely, he can reach # any point which lies in a circle whose radius is the length of the # leash, and the center is the point it is tied at. # # Now, suppose we tie the leash at both ends, but allow the collar to # slip along the rope. What set of points can the dog get to? Well, if # we give the points the leash is attached at coordinates [x[1],y[1]and # [x[2],y[2] and let the leash have length c, then the set of points # which are accessible are given by the inequality > dist([x[1],y[1]],[x,y])+dist([x[2],y[2]],[x,y])=c# # However, we need only consider the case of equality. Furthermore, # using the distance formula, this becomes the set of points [x,y] which # satisfy > dogEqn:= sqrt( (x-x[1])^2 + (y-y[1])^2) + sqrt( (x-x[2])^2 + > (y-y[2])^2) = c: # If you don't already know that this is an ellipse, we can use # implicitplot to see that. Let us take our points to be (-1,0) and # (1,0), and c=4. (The points are called the foci of the ellipse). > myDogEqn := subs(x[1]=-1,y[1]=0,x[2]=1,y[2]=0,c=3,dogEqn); 2 2 1/2 2 2 1/2 myDogEqn := (x + 2 x + 1 + y ) + (x - 2 x + 1 + y ) = 3 > with(plots): > implicitplot(myDogEqn, x=-2..2, y=-2..2, > scaling=constrained,axes=boxed); # That surely looks like an ellipse to me. But how do we know it is an # ellipse? From high school, I seem to remember (and maybe you do too) # that the equation of an ellipse is of the form x^2/a^2+y^2/b^2=1, and # this doesn't look like that. So now we get to make it look like that. # # But how? By algebraic messing around. This is, in fact, a little # easier to do by hand on paper, but we will coerce maple into doing it # anyway. # WARNING: most of this would be much easier to do on paper, with # maple's assistance. but we are doing this for pedagogical reasons, and # out of sheer meanness. # # First, so that we can keep track of what is going on, let's replace # the complicated stuff inside the square roots with something simpler. # Then after we are done, we will put it back in. > dogEqn1 := sqrt(e)+sqrt(f)=c; 1/2 1/2 dogEqn1 := e + f = c # We need to manipulate the left and right sides of the equation # independantly, so lets give them names. The maple functions rhs and # lhs give us the right and left sides of an equation: > dogEqn1r := rhs(dogEqn1); dogEqn1l := lhs(dogEqn1); dogEqn1r := c 1/2 1/2 dogEqn1l := e + f # Now we square both sides, in hopes that the square roots will go away # (they won't). > expand((dogEqn1l)^2) = (dogEqn1r)^2; 1/2 1/2 2 e + 2 e f + f = c # Doesn't look much better, huh? But notice that if we move the terms # without a square root over to the other side, and then square both # sides again, it will get rid of the roots. > expand((dogEqn1l)^2-(e+f)) = (dogEqn1r)^2 - (e+f); 1/2 1/2 2 2 e f = c - e - f > expand(((dogEqn1l)^2-(e+f)))^2 = ((dogEqn1r)^2 - (e+f))^2; 2 2 4 e f = (c - e - f) # The roots are gone. So that is what we want. Lets put everything on # one side: > dogFunc := expand( ((dogEqn1l)^2-(e+f))^2 - ((dogEqn1r)^2 - (e+f))^2); 4 2 2 2 2 dogFunc := 2 e f - c + 2 c e + 2 c f - e - f # Finally, we can substitute the real values of e and f back in. > dogMess := expand( > subs(e=(x-x[1])^2 + (y-y[1])^2, f=(x-x[2])^2 + (y-y[2])^2, dogFunc)); 2 2 2 dogMess := -4 x x[1] y[2] - 4 x[1] y y[2] - 4 y[1] y y[2] 2 2 2 2 - 4 c x x[2] - 4 y y[1] x[2] - 4 x[1] x x[2] - 4 y[1] x x[2] 2 2 2 2 - 4 y y[1] y[2] + 8 y y[1] y[2] - 4 x x[1] x[2] - 4 c x x[1] 2 4 2 + 8 x x[1] x[2] + 8 x x[1] y y[2] - c - 4 c y y[1] 2 2 2 2 - 4 c y y[2] + 4 x x[1] y[1] + 4 x[1] y y[1] + 4 x x[2] y[2] 2 2 2 2 2 4 4 4 + 4 x[2] y y[2] + 4 c x + 4 c y - x[1] - y[1] - x[2] 4 2 2 2 2 2 2 - y[2] - 4 x x[2] - 4 x[1] x + 2 x[1] x[2] 2 2 2 2 2 2 2 2 + 2 x[1] y[2] - 4 y y[2] + 2 y[1] x[2] - 4 y[1] y 2 2 2 2 2 2 2 2 + 2 y[1] y[2] + 2 c x[1] + 2 c y[1] + 2 c x[2] 2 2 3 2 2 3 3 + 2 c y[2] + 4 x x[1] - 2 x[1] y[1] + 4 y y[1] + 4 x x[2] 2 2 3 - 2 x[2] y[2] + 4 y y[2] + 8 y y[1] x x[2] - 8 x x[2] y y[2] - 8 x x[1] y y[1] # Well, that looks awful. Lets see what we get when we put in our # specific values of c, [x[1],y[1]and [x[2],y[2]], though: > myDogMess := subs(x[1]=-1,y[1]=0,x[2]=1,y[2]=0,c=3,dogMess); 2 2 myDogMess := 20 x - 45 + 36 y # Not bad. Looks just like we'd expect an ellipse to look like. Let's # plot it: > implicitplot(myDogMess,x=-2..2, y=-2..2, > scaling=constrained,axes=boxed); # Yes, that is the same thing, and it is clearly the expected form. # But, after that work, we have more: we have the general form of an # ellips with foci at [x[1],y[1] and [x[2],y[2] with constant c. For # example, a tilted ellipse: > sort(subs(x[1]=-1,y[1]=-1,x[2]=1,y[2]=0,c=3,dogMess)); > implicitplot(",x=-2..2, y=-2..2, scaling=constrained,axes=boxed); 2 2 20 x - 16 x y + 32 y - 8 x + 32 y - 28 # But let's see if we can neaten up this apparent mess a bit, collecting # terms in x and y. > collect(dogMess,[x,y],distributed); 4 2 2 2 2 2 2 2 2 4 -c + 2 c x[1] + 2 c y[1] + 2 c x[2] + 2 c y[2] - x[1] 2 2 2 2 2 2 4 - 2 x[1] y[1] + 2 x[1] x[2] + 2 x[1] y[2] - y[1] 2 2 2 2 4 2 2 4 + 2 y[1] x[2] + 2 y[1] y[2] - x[2] - 2 x[2] y[2] - y[2] 2 2 2 2 + (4 c - 4 x[1] + 8 x[1] x[2] - 4 x[2] ) x + (-8 x[1] y[1] + 8 x[1] y[2] + 8 y[1] x[2] - 8 x[2] y[2]) x y 2 2 2 2 2 + (4 c - 4 y[1] + 8 y[1] y[2] - 4 y[2] ) y + (-4 c x[1] 2 3 2 2 - 4 c x[2] + 4 x[1] - 4 x[1] x[2] + 4 x[1] y[1] 2 2 2 3 - 4 x[1] x[2] - 4 x[1] y[2] - 4 y[1] x[2] + 4 x[2] 2 2 2 2 + 4 x[2] y[2] ) x + (-4 c y[1] - 4 c y[2] + 4 x[1] y[1] 2 3 2 2 - 4 x[1] y[2] + 4 y[1] - 4 y[1] y[2] - 4 y[1] x[2] 2 2 3 - 4 y[1] y[2] + 4 x[2] y[2] + 4 y[2] ) y # Still pretty dreadful. Oh well. But we can make a general ellipse # function out of it quite easily. Note that we will specify the two # foci as A and B, so we need to have A=[x[1],y[1]], and B=[x[2],y[2]], # so it looks like I made a mistake in the subs command. But I didn't. > GenEllipse := (A,B,k) -> > simplify(subs(x[1]=A[1],y[1]=A[2], x[2]=B[1], y[2]=B[2], c=k, > dogMess)); GenEllipse := (A, B, k) -> simplify(subs(x[1] = A[1], y[1] = A[2], x[2] = B[1], y[2] = B[2], c = k, dogMess)) > GenEllipse([0,0],[1,5],6); 2 2 -40 x - 100 - 200 y + 140 x + 44 y - 40 x y > implicitplot(GenEllipse([0,0],[1,5],6)=0,x=-2..3,y=-1..6,scaling=const > rained); # # The real question is: was it worth the trouble? (probably not).