Practice / Linear algebra
Vectors in 3-D: dot and cross products, lines and planes
Before you start
Two products do most of the geometry in three dimensions. The dot product measures how much two vectors point the same way: it gives lengths, angles, projections and the work done by a force, and a zero dot product means perpendicular. The cross product builds a third vector perpendicular to both, whose length is the area of the parallelogram they span. A plane is described by a point and a normal vector, a line by a point and a direction, and every distance between them is a dot product with a unit vector. The same formulas reach machine learning unchanged: cosine similarity is the angle formula, and a linear classifier's decision boundary is a plane with normal . These ten problems compute angles, areas and volumes, write lines and planes, find where they meet and how far apart they are, and end with the signed distance of a point to a decision boundary.
- For and : and .
- Angle. , so , with . exactly when (or one of them is ).
- Component and projection. The component of along is and the projection is .
- Cross product. . It is perpendicular to and , follows the right-hand rule, , and is the area of the parallelogram on and .
- Triple product. , the determinant with as rows, and is the volume of the parallelepiped on .
- Lines and planes. The line through with direction is . The plane through with normal is , that is . The distance from a point to the plane is .
Problems
- ·
For and , find , , and the angle between them.
- ·
A force moves an object along the displacement . Find the work done, the component of along and the projection of onto .
- ·
For and , find , check that it is perpendicular to both, and find the area of the parallelogram and of the triangle on and .
- ··
Find the area of the triangle with vertices , , , and the equation of the plane through them.
- ··
Find the volume of the parallelepiped on , , , and the volume of the tetrahedron with the same three edges from one vertex.
- ··
Find the line through and , and the point where it meets the plane .
- ··
Find the distance from to the plane , and the point of the plane nearest to .
- ··
Find the angle between the planes and , and their line of intersection.
- ···
Show that the lines and do not meet and are not parallel, and find the distance between them.
- ···
A linear classifier predicts the positive class when , with and . Find the signed distances of and to the decision boundary, and the point of the boundary nearest to .
Answers
- , , ,
- , component , projection
- ; parallelogram area , triangle area
- Area ; plane
- Parallelepiped , tetrahedron
- ; it meets the plane at
- Distance ; nearest point
- ; line
- Distance
- Signed distances and ; nearest boundary point
Worked solutions
Problem 1
For and , find , , and the angle between them.
- and Square, add, take the root.
- Multiply matching entries and add.
- Divide by the product of the lengths, not their squares.
- radA positive dot product means an acute angle.
- , , , In machine learning would be the cosine similarity of and . Dividing by instead gives (Mistake 2).
Problem 2
A force moves an object along the displacement . Find the work done, the component of along and the projection of onto .
- Work is force times displacement, counting only the part of the force along the motion.
- Needed to turn into a unit vector.
- Component The dot product with the unit vector .
- Projection The component times the unit vector, which divides by twice.
- , component , projection Check: minus the projection is , and its dot product with is .
Problem 3
For and , find , check that it is perpendicular to both, and find the area of the parallelogram and of the triangle on and .
- First entry: Cover the first column and take the determinant of what is left.
- Second entry: ; third: The middle entry has the order reversed, which is the minus sign of the cofactor expansion (Mistake 1).
- and The check catches almost every slip.
- Check with Lagrange's identity: .
- ; parallelogram area , triangle area The triangle is half the parallelogram.
Problem 4
Find the area of the triangle with vertices , , , and the equation of the plane through them.
- and Two edges from the same vertex.
- Perpendicular to both edges, so normal to the plane.
- Area Half the parallelogram on the two edges.
- The constant comes from a point on the plane. Check : ; : .
- Area ; plane Dividing by gives the intercept form . Taking the constant from the vector instead of a point gives a parallel plane through the origin (Mistake 4).
Problem 5
Find the volume of the parallelepiped on , , , and the volume of the tetrahedron with the same three edges from one vertex.
- Expand along the first row.
- The triple product .
- Check: and The same number computed the other way.
- The tetrahedron is of the parallelepipedHalf for the triangular base, a third for the pyramid.
- Parallelepiped , tetrahedron The sign of the determinant is positive, so are a right-handed triple. The product of the lengths, , is the volume only when the edges are perpendicular (Mistake 5).
Problem 6
Find the line through and , and the point where it meets the plane .
- The direction is the difference of two points on the line.
- gives and gives .
- Substitute the line into the plane: one equation in .
- So the meeting point is beyond .
- ; it meets the plane at Check: . If had been the line would be parallel to the plane, and the equation in step 3 would have no in it.
Problem 7
Find the distance from to the plane , and the point of the plane nearest to .
- and The normal is read off the coefficients.
- How far the equation is from being satisfied, in units of .
- Distance Dividing by turns it into a length.
- Nearest point: Move from along the normal by the right amount. Check: .
- Distance ; nearest point The distance from to that point is . Forgetting to divide by gives (Mistake 3).
Problem 8
Find the angle between the planes and , and their line of intersection.
- , , The angle between two planes is the angle between their normals.
- , so .
- The line lies in both planes, so it is perpendicular to both normals.
- With : and , so Any point on both planes will do.
- ; line Check a second point, : gives and .
Problem 9
Show that the lines and do not meet and are not parallel, and find the distance between them.
- The directions and are not multiples of each otherSo the lines are not parallel.
- Meeting would need , , : from the first, from the third, and then The three equations have no common solution: the lines are skew.
- Perpendicular to both lines.
- and Project the vector between any two points of the lines onto the common normal.
- Distance Divide by . The closest points are at and : on and on . Their difference is , a multiple of , of length .
Problem 10
A linear classifier predicts the positive class when , with and . Find the signed distances of and to the decision boundary, and the point of the boundary nearest to .
- The boundary is the plane , with normal and The weight vector is perpendicular to the decision boundary.
- , so the signed distance is Positive: is on the positive side.
- , so the signed distance is Negative: is classified negative, from the boundary.
- Nearest point to : Step back along the unit normal by the signed distance. Check: .
- Signed distances and ; nearest boundary point The raw score is the signed distance times , so scaling and by multiplies every score by without moving the boundary. That is why a margin is measured as .
Where this goes wrong
1. The middle sign of the cross product
The three entries are computed with the same pattern, in index order.
- , , first entry Right so far: Problem 3.
- “Second entry: .”The step that causes the mistake: the middle entry is , the minus sign of the cofactor expansion.
- The check catches it: , so this vector is not perpendicular to . The cross product is .
2. Dividing by the squared lengths
The angle formula is remembered with and in the denominator.
- , , Right so far: Problem 1.
- “.”The squared lengths belong to the projection coefficient , not to the cosine.
- , so Nearly perpendicular, for two vectors whose dot product is large and positive. A cosine must not change when is doubled; this one halves. With , .
3. The distance without dividing by |n|
The value of the plane's equation at the point is taken as the distance.
- for and the plane Right so far: Problem 7.
- “The distance is .”That number depends on how the equation is written: is the same plane and would give .
- Distance is the distance measured in units of . Divide: the distance is . Check with the nearest point , which is from .
4. The plane through the wrong point
The constant on the right of the plane's equation is computed from an edge vector.
- is normal to the plane through , , Right so far: Problem 4.
- “.” lies in the plane's direction but is not a point of it; is perpendicular to every edge, so this always gives .
- The plane is That plane passes through the origin, parallel to the right one. does not satisfy it: . Use a point: .
5. The product of the lengths as a volume
The volume of a box is length times width times height, and the same is done for a slanted one.
- , , Right so far: the edges of Problem 5.
- “Volume .”True only when the edges are perpendicular; here and .
- Volume Twice the true volume. The product of the lengths is an upper bound (Hadamard's inequality), reached only by a rectangular box. The triple product gives .
Print this set: vectors-dot-and-cross-products-lines-and-planes.pdf (problems, answers, and worked solutions on separate pages).