Mathematica Lesson 4: Lines and Planes
Mathematica Lesson 4: Lines and Planes
In the menu at the top, click Make Your Own Copy to work in Mathematica Online, or click Download to use it in Mathematica.
When asked "Do you want to automatically evaluate all the initialization cells in the notebook...?" I recommend "No" so that you can work through each cell one-at-a-time.
In the menu at the top, click Make Your Own Copy to work in Mathematica Online, or click Download to use it in Mathematica.
When asked "Do you want to automatically evaluate all the initialization cells in the notebook...?" I recommend "No" so that you can work through each cell one-at-a-time.
When asked "Do you want to automatically evaluate all the initialization cells in the notebook...?" I recommend "No" so that you can work through each cell one-at-a-time.
Lines and planes
Lines and planes
Question 1
Question 1
In Unit 1, we learned three ways to specify a line:
(1) Have two points on the line.
(2) Have a point and a sense of direction.
(3) Have two intersecting planes.
We will work with (1) and (2) together first... Suppose the points P(3,1,5) and Q(6,−1,0) both lie on a line. Define their position vectors in Mathematica:
OP={3,1,5};
OQ={6,-1,0};
Use these to fill in a command (or formula) that creates the direction vector v⃗ from point P to point Q.
(The question in Moodle is not looking for you to compute the actual vector and provide directly, but rather, how would you tell Mathematica to compute it?)
(1) Have two points on the line.
(2) Have a point and a sense of direction.
(3) Have two intersecting planes.
We will work with (1) and (2) together first... Suppose the points P(3,1,5) and Q(6,−1,0) both lie on a line. Define their position vectors in Mathematica:
OP={3,1,5};
OQ={6,-1,0};
Use these to fill in a command (or formula) that creates the direction vector v⃗ from point P to point Q.
(The question in Moodle is not looking for you to compute the actual vector and provide directly, but rather, how would you tell Mathematica to compute it?)
OP={3,1,5};OQ={6,-1,0};(* Now use these to compute the vector from P to Q. The computation (and not the vector itself) is what you will enter into Moodle. *)
Question 2
Question 2
Let's find the equation through a line containing the point P (from the question above) and which goes in the direction indicated by v⃗ =⟨3,−2,−5⟩.This means we will use the position vector for the point P as the term " r⃗0" in the parametric form for the line: r⃗(t)=r⃗0 + t v⃗.In Mathematica, you have OP defined from the question above. Now create v⃗
v={Answer,Answer,Answer}
and then define the line as a function via
r[t_]:=OP+t*v
Note the underscore, colon, and * symbol are all necessary!
To compute r⃗(0), just do r[0]:
To compute r⃗(0), just do r[0]:
r[0]
You should get {3,1,5}. Your turn: what is r⃗(−1)?
(As a vector, we can think of this as the position vector that starts at the origin and points to the point in space with the same coordinates.)
Question 3
Question 3
I claim the point (18,−9,−20) is on this line. To find the t value that would map us to that point, use the Solve command:
Solve[r[t] == {18, -9, -20}]
What is the t value? (Enter in Moodle.)
Question 4
Question 4
In lecture, we asked "Does the point (−1,8,5) lie on the line r⃗(t)=⟨1,0,1⟩+t⟨−1,4,2⟩? Does (6,2,3)?
Set this line up in Mathematica:
Set this line up in Mathematica:
r[t_]:={1,0,1}+t{-1,4,2}
Now use the Solve command to check our answers for that question:
New point! Is (9,−32,−15) on the line?
Question 5
Question 5
Two intersecting planes determines a line as well. In Mathematica, we can ask for a description of this intersection by asking Mathematica to solve both plane equations simultaneously:
Solve[3x+y-z==5 && x+y+z==1]
The returned answer is
{{y->3-2x, z->-2+x}}
What we can do now (on paper): Consider the first scalar parametric equation as x=t. Thus wherever we see x above, we'll replace it with the parameter t, so that y=3−2t and z=−2+t.
Now group like terms (those with and without t):
x = 0+t
y = 3−2t
z = −2+t
Thus ⟨x,y,z⟩ = ⟨0,3,−2⟩ + t⟨1,−2,1⟩. The intersection between these two planes is the line r⃗(t)=⟨0,3,−2⟩+t⟨1,−2,1⟩.
{{y->3-2x, z->-2+x}}
What we can do now (on paper): Consider the first scalar parametric equation as x=t. Thus wherever we see x above, we'll replace it with the parameter t, so that y=3−2t and z=−2+t.
Now group like terms (those with and without t):
x = 0+t
y = 3−2t
z = −2+t
Thus ⟨x,y,z⟩ = ⟨0,3,−2⟩ + t⟨1,−2,1⟩. The intersection between these two planes is the line r⃗(t)=⟨0,3,−2⟩+t⟨1,−2,1⟩.
Question 10
Question 10
We are going to reuse some variable names in this problem. Start by clearing them:
Clear[v,r]
and any others you may have created)
We'll finish with a quick look at planes. Suppose the points P(3,0,−1), Q(2,2,5), and R(1,1,0) lie on the same plane. Set these points up in Mathematica.
P={3,0,-1} (* Notice this is also "OP" *)
Then in your notebook, create the vectors u⃗ =OQ−OP and v⃗ =OR−OP.
u=Q-P
Next, use the Cross command to create n⃗ = u⃗ ×v⃗.
Now we have enough information for the vector form of the plane: n⃗ ⋅(⟨x,y,z⟩−OP)=0.To convert this form to general form in Mathematica, try
Solve[n.({x,y,z}-P)==0]
This should return an equation of the form z=⋯. On paper, rearrange terms to get the general form. Notice the right-hand side in Moodle is 15.
Information
Information
The graphs of lines and planes are not that impressive in Mathematica, but here is how you can do it. Given the vector parametric equation for a line, e.g.
r[t_]:={3,0,3}+t{2,-1,1}
You can do a "parametric plot" (and set it in ℝ³) via
ParametricPlot3D[r[t],{t,-2,2}]
Not too interesting... If you want some extra styling commands, try
ParametricPlot3D[r[t],{t,-2,2},BoxedFalse,AxesOrigin{0,0,0},AxesLabel{x,y,z}]
Remove those extra commands one-at-a-time to see the effect of each.
To plot the plane 3x−y+z=1, here are two options: 1. Interpret it as the function z=1−3x+y, and do
Plot3D[1-3x+y,{x,-3,3},{y,-3,3},AxesLabel{x,y,z}]
2. View it as a "contour" (the contour level 1 for the quantity 3x−y+z=1):
ContourPlot3D[3x-y+z==1,{x,-3,3},{y,-3,3},{z,-3,3},AxesLabel{x,y,z}]
Note I chose to have each variable go from −3 to 3, it should be simple to alter that.
To put multiple plots together, save the plots and then ask Mathematica to "show" them:
To put multiple plots together, save the plots and then ask Mathematica to "show" them:
g1=ParametricPlot3D[r[t],{t,-2,2},BoxedFalse,AxesOrigin{0,0,0},AxesLabel{x,y,z}];g2=Plot3D[1-3x+y,{x,-3,3},{y,-3,3},AxesLabel{x,y,z}];Show[g1,g2]