Lines & Planes Introduction and Goals: This lab is simply to give you some practice with plotting straight lines and planes and how to do some basic problem solving with them. So the exercises will be mainly mechanical but will contain several well used and needed manipulations. Our goal is to be able to do all of the basic calculations we normally do by hand using Maple and be able to produce graphs of lines and planes in three dimensions. Before You Start: Make sure that you read and understand the mathematics from the corresponding sections in your textbook. It would also help if you looked over the lab on Vectors and Vector Arithmetic. Textbook Correspondence: Stewart 5 th Edition: 1.5. Stewart 5 th Edition Early Transcendentals: 12.5. Thomas Calculus 1 th Edition Early Transcendentals: 1.. Johnston & Mathews Calculus: 8.4 8.6. Maple Commands and Packages Used: Packages: linalg, plots. Commands: evalm, spacecurve, plotd, display, solve, implicitplot, dotprod, seq, implicitplotd. History & Biographies: Maple Commands: Since we will be using several functions that are in the linalg package and the plots package you should load these packages into your worksheet before going any further. Execute the commands, > with(linalg): > with(plots):
Let s begin our investigation with lines. Mathematically we denote lines in threespace as parametric equations, usually written in the form x = x y = y z = z + at + bt + ct where ( x, y z ) is a point on the line and ( a b, c), also common to write this set of points as a vector, specifically,, is the direction vector of the line. It is x at, y + bt z + ct. +, Since Maple s syntax is closer to the vector representation of a line we will use vector 2,, 1 and is in the notation here. So to define the line that goes through the point ( ) direction of 1,2,, we need to define the vector valued function that takes t to 2 + t, + 2t, 1+. To do this definition we simply need to combine the standard function definition syntax with the vector syntax. Define executing the command, > r:=t-> [2+t, +2*t, -1+*t]; r := t [ 2 + t, + 2 t, 1 + t ] r ( t) = 2 + t, + 2t, 1+ by Now we can find the point on the line associated with any value of the parameter t simply using Maple s function evaluation syntax. For example, > r(); > r(1)-r(); > evalm(r(1)-r()); > r(); > r(w); [ 2,, -1] [, 5, 2 ] [ 2,, -1] [ 1, 2, ] [ 5, 9, 8 ] [ 2 + w, + 2 w, 1 + w ] To plot this line we use the spacecurve command. The spacecurve command syntax is similar to all of the other plotting commands in Maple. You need to give it the curve to plot, the range of values for the parameter and a list of all the other plot options you want. For example, if we execute the command,
> spacecurve(r(t),t=..1,axes=boxed); we get the image to the right. In the above syntax we let our parameter t go from to 1, to extend the line further in either direction we would simply alter the bounds. Also note that the default coloring of the line shaded it from dark to light as t went from its lower bound to its upper bound. This is a nice feature since we are frequently interested in a line s orientation, that is, the direction of increasing t. On the other hand, this sometimes makes it more difficult to see what the line or curve is doing near the upper bound. By including the color option in the spacecurve command we can draw the line as a solid color. For example, the command > spacecurve(r(t),t=..1,axes=boxed, color=black); gives the image to the right. We can also mimic the vector form construction of a line in three-space. Recall that the vector form looks like r ( t) = r + vt where r is a point on the line and v is a direction vector. To define the same line as we did above in this framework we execute the following commands, > v:=[1,2,]; > r:=[2,,-1]; > r:=t->r+t*v; v := [ 1, 2, ] r := [ 2,, -1] r := t r + t v Mathematically, the two ways we defined the line are identical but Maple looks at them a bit differently. This means that graphing will be a bit different between the two methods. If we use the same spacecurve command as we did above we get an error because Maple doe not see the line in the correct form. > spacecurve(r(t),t=..1,axes=boxed, color=black); Error, (in spacecurve) first argument must be array, list or set To get the line in the correct form for the spacecurve command we simply use the evalm command on the vector. Doing so gives us the same graph as we had before.
> spacecurve(evalm(r(t)),t=..1,axes=boxed, color=black); As with most of the other graphics commands in Maple you can graph several lines together using a single spacecurve command and you plot several lines, with different parameter ranges, together using separate spacecurve commands pasted together with a display command. For example, say we wanted to plot the lines r ( t) = 2 + t, + 2t, 1, r ( t) = t,4t, 2 t and r ( t) = 2,1 + t, 1 t together using the 1 + same range for t, say to 5. First define the lines, > r1:=t->[2+t,+2*t,-1+*t]; r1 := t [ 2 + t, + 2 t, 1 + t ] > r2:=t->[t,4*t,2-t]; r2 := t [ t, 4 t, 2 t ] > r:=t->[2,1+t,1-t]; r := t [ 2, 1 + t, 1 t ] 2 Then use the spacecurve command with the three lines placed in a list delimited by curly brackets. > spacecurve({r1(t),r2(t),r(t)}, t=..5,axes=boxed,color=black); To plot the lines r ( t) = 2 + t, + 2t, 1, 1 + r ( t) = t,4t, 2 t and r ( t) = 2,1 + t, 1 t together using the ranges to 1, 1 to 2 and 2 to 2 respectively we construct the three spacecurve plots and then paste them together with the display command. Note the use of the colon in the spacecurve commands, if you use the semicolon you will get a lot of unnecessary output. > c1:=spacecurve(r1(t),t=..1,axes=boxed,color=black): > c2:=spacecurve(r2(t),t=1..2,axes=boxed,color=black): > c:=spacecurve(r(t),t=2..,axes=boxed,color=black): > display(c1,c2,c);
Let s move onto planes. From your text you know that like lines there are two main forms for the equation of a plane, linear form and vector form. We will start with linear form. Say we want to define a function to represent the plane z = x 2y + 2. We view z as a function of two variables and hence we will define it as the function f ( x, y) by > f:=(x,y)->*x-2*y+2; f := ( x, y ) x 2 y + 2 Now we can evaluate this function at any point ( y) and y coordinates of interest. For example, x, we wish simply by including the x > f(2,5); > f(,); > f(t,2); > f(4,7*s); -2 2 t 2 14 14 s To graph the plane we use the plotd command. In the plotd command we put the formula to plot, the range of both x and y and any other options we want. For example, > plotd(f(x,y),x=-5..5,y=-5..5,axes=boxed); As with the other plotting commands in Maple we can graph several planes (or surfaces) together on the same set of axes by placing all of the desired equations into a list. For example, to graph z = x 2y + 1, z = 5x + 7y 2 and z = 4 x + y + 5 together we would use the following sequence of commands. > g:=(x,y)->*x-2*y+1; g := ( x, y ) x 2 y + 1 > h:=(x,y)->-5*x+7*y-2; h := ( x, y ) 5 x + 7 y 2 > k:=(x,y)->-4*x+y+5; k := ( x, y ) 4 x + y + 5 > plotd({g(x,y),h(x,y),k(x,y)}, x=-5..5,y=-5..5,axes=boxed);
The vector form of the equation of a plane can be written as ( r r ) normal vector to the plane, r is a point on the plane and plane that passes through the point = ( 2,, 1) r = n where n is the x, y, z =. So to define the r and is normal to n = 4,2, 7 we first define the necessary vectors and then use the dotprod command to define the equation. > r:=[2,,-1]; > r:=[x,y,z]; > n:=[4,2,7]; r := [ 2,, -1] r := [ x, y, z ] n := [ 4, 2, 7 ] > p:=dotprod(n,r-r)=; p := 7 + 4 x + 2 y + 7 z = To plot the plane we can no longer use the plotd command since the plotd command is for plotting explicitly defined functions and since we are trying to plot an equation the function is defined implicitly. Hence, we use the implicitplotd command, giving it the expression to plot along with ranges in x, y and z and any other options we want. For example, > implicitplotd(p,x=-5..5,y=-5..5, z=-5..5,axes=boxed); The implicitplotd command comes in handy when we wish to plot vertical planes. Since a vertical plane is not a function the plotd command will not graph it, but the implicitplotd command will. For example, say we wanted to plot the above plane with the plane x = 2. All we would need to do is define the second plane and then plot them together. > p2:=x=2; p2 := x = 2 > implicitplotd({p,p2},x=-5..5, y=-5..5,z=-5..5,axes=boxed); Note that we can plot an explicitly defined plane, like our first example, using the implicitplotd command by making the expression into an equation and adding a range for z, as below. Due to Maple s graphing methods the image is a little more cluttered
when using the implicitplotd command, which is why you should use the plotd command whenever possible. > implicitplotd(z=f(x,y),x=-5..5,y=-5..5,z=-25..25, axes=boxed); Now that we know how to define and graph lines and planes let s look at the procedures needed to do some basic manipulations and solving. Say we wanted to find the intersection point between the lines r ( t ) = 2 + 2t,4, 7 + t and r ( t) = + t,1,12 5t 2 + 1, if one exists. A point of intersection would be found if there was a value of t for the first line that gave the same point as a value of t (possibly different) for the second line. Since these values are not necessarily the same we must use different variables for the parameters. Hence we will change the second line to r ( s) = + s,1 s,12 5s. Now these two lines have a point of intersection if there 2 + exists an s and a t such that all three of the following equations are satisfied. 2 + 2t 4 7 + t = = = + s 1 s 12 + 5s There are many ways to get Maple to solve this system, we will use one that is as vector oriented as possible. First define the two lines, > r1:=t->[2+2*t,4-*t,7+t]; r1 := t [ 2 + 2 t, 4 t, 7 + t ] > r2:=s->[s+,1-*s,12+5*s]; r2 := s [ s +, 1 s, 12 + 5 s ]
Now if we use the standard solve command syntax we get an error because Maple does not know that we want to set each component equal to each other and then solve the resulting system. > solve(r1(t)=r2(s),{s,t}); Error, (in solve) invalid arguments To put the system in the correct format we need to extract the first component of the first line and set it equal to the first component of the second line and then do the same for the other two components. To extract a component from a vector we simply need to place [n] after the vector, where n is the component to be extracted. For example, > r1(t)[1]; > r1(t)[2]; > r1(t)[]; 2 t + 2 t + 4 t + 7 So the solve command we need is > solve({r1(t)[1]=r2(s)[1],r1(t)[2]=r2(s)[2], r1(t)[]=r2(s)[]},{s,t}); { t =, s = -1} Note that it returns the set of solutions. Checking these, > r1(); > r2(-1); [ 2, 4, 7 ] [ 2, 4, 7 ] we see that we do have a common point between the two lines. We can streamline the above solve command by using the seq function to generate the list of equations. Note the output of the following command. > seq(r1(t)[n]=r2(s)[n],n=1..); 2 t + 2 = s +, t + 4 = s + 1, t + 7 = 5 s + 12 It is a list of the three equations that we wish to solve simultaneously. So if we simply place this command in the solve command we will generate the needed list of equations.
> solve({seq(r1(t)[n]=r2(s)[n],n=1..)},{s,t}); { s = -1, t = } One nice feature of this last method is that it is easier to use if we are working with lines in higher dimensions. In these cases we simply need to increase the upper bound on n. It is also convenient to use in plot commands. For example, say we wanted to graph each of the three lines created from the equations above, to visually see if there is a solution to our system. > implicitplot({seq(r1(t)[n]= r2(s)[n],n=1..)},s=-.., t=-..); If we have two lines that do not intersect then we can use the implicitplot command to see that there is no common point of intersection or we can use the solve command. Using the implicitplot command on the following two lines > l1:=t->[2+2*t,4-*t,7+t]; l1 := t [ 2 + 2 t, 4 t, 7 + t ] > l2:=s->[2+4*s,5-s,9+s]; l2 := s [ 4 s + 2, s + 5, s + 9 ] > implicitplot({seq(l1(t)[n]=l2(s)[n],n=1..)},s=-..,t=-..); shows that there is not common point of intersection of the three equations and hence there are no values for s and t that make the two three space lines intersect as well. If we use the solve command, > solve({seq(l1(t)[n]=l2(s)[n],n=1..)},{s,t});
we see that Maple does not output anything, hence there is no point of intersection. To find the intersection of three planes, if one exists, we simply place the plane equations in the solve command so that the three are set equal to each other, in pairs. For example, > solve({g(x,y)=h(x,y),h(x,y)=k(x,y)},{x,y}); 5 15 { y =, x = } 9 1 checking these verifies that this is indeed the point of intersection. > g(15/1,5/9); > h(15/1,5/9); > k(15/1,5/9); 68 9 68 9 68 9 Finding the parametric equations to the line of intersection of two planes is just as simple. Place the two plane equations in the solve command, both set to z, and solve for x, y and z, as in the command below. > solve({z=g(x,y),z=h(x,y)},{x,y,z}); 9 y 1 11 y { x = +, y = y, z = + } 8 8 8 8 Note that the second equation is y = y. Clearly a correct statement, but in this case it is telling us to let y be the parameter for the equations. Since we tend to use t for the parameter we will change it. Hence our equations are x = z = 8 y = t 11 or in vector form, r ( t) = 9 t t 1 8 + 8,, 8 + 8 t. Frequently, we wish to graph both planes and their lines of intersection. One way to do this is to define the plotd graph of the planes, define the spacecurve graph of the line and then paste them together with the display command, as below. > r:=t->[-/8+9/8*t,t,-1/8+11/8*t]; 1 8 + + 9 8 11 8 t t
r := t + 8 9,, 8 t t 1 + 11 8 8 t > pls:=plotd({g(x,y),h(x,y)},x=-5..5,y=-5..5,axes=boxed): > lne:=spacecurve(r(t),t=-4..4,thickness=4,color=black): > display(pls,lne); Another type of intersection we frequently need to calculate is that between a line and plane. As with all of the other command sequences we mimic the calculations we would do by hand on Maple. Say we want to find the intersection between the line x = 1+ y = 2 4t z = t + and the plane g ( x, y) = x 2y + 1 definition for the function ( x, y) = x 2y + 1. The following commands define the line as v, the g was done above and then graphs the plane and line to visually verify that there is a point of intersection. > v:=t->[1+*t,2-4*t,+t]; v := t [ 1 + t, 2 4 t, t + ] > p:=plotd(g(x,y),x=-5..5,y=-5..5,axes=boxed): > l:=spacecurve(v(t),t=-1..1,thickness=4,color=black): > display(p,l);
If we did not have Maple at our disposal and needed to find the point of intersection we would substitute the x and y equations from the line into the plane equation, set it equal to the z equation from the line and solve the resulting equation for t. As before, we use the [n] syntax to extract the components of v. So > solve(v(t)[]=g(v(t)[1],v(t)[2]),t); 16 tells us that we have an intersection when t = 16. The actual point of intersection can be found simply by evaluating the line at t = 16. > v(/16); 25 5 51,, 16 4 16 Not that it saves us any typing, but we can use the seq command in the above solve command. As below, > solve(v(t)[]=g(seq(v(t)[n],n=1..2)),t); 16 Exercises: 1. Plot the following lines on the same set of axes with the same range for the parameter t, say to.
x = 1+ y = 2 4t x = 2 t y = 7 + 2t z = t + z = 4t 1 z = t 2. Plot the following lines on the same set of axes with the different ranges for the parameter t, say to, to 5 and 1 to 4 respectively. and x = 5 + t y = 7t x = 1+ y = 2 4t z = t + x = 2 t y = 7 + 2t z = 4t 1 and x = 5 + t y = 7t z = t. Plot the following planes on the same set of axes. z = x + y + 5 z = x + 2 y + 1 and z = 2x 7y 2 4. Plot the following planes on the same set of axes. Use plotd whenever possible. z = x + y + 5 x = 2 y + 1 and y = 7 5. Plot the following lines and planes on the same set of axes.. Make sure that the lines are made thick and make the colors of the lines red and green. x = 1+ y = 2 4t z = t + x = 5 + t y = 7t z = t z = x + 2 y +1 and z = 2x 7y 2 6. Find the line of intersection between the two planes z = x + y + 5 and z = 2x 7y 2 and then graph the planes and line on the same set of axes. Make sure that the line is made thick and make the color of the line red. 7. Find the line of intersection between the two planes z = x + y + 5 and x = 2 y + 1 and then graph the planes and line on the same set of axes. Make sure that the line is made thick and make the color of the line black. 8. Write down the process you would go through, without using Maple, if you wanted to find the distance between the two parallel planes z = 2x 7y 2 and z = 2 x 7y + 9. You do not need to do the calculations by hand. Now translate the process you have into a sequence of Maple commands and use Maple to solve this problem.