Linear algebra
Vector mathematics calculator
Enter the components of two vectors in the plane or in space: magnitude, unit vector, dot and cross products, angle, projection and areas update as you type, and in the plane you see both vectors drawn with the parallelogram of their sum.
The two ways to multiply vectors
Adding two vectors is easy — add the components — but there are two different ways to multiply them, and they answer different questions. The dot product u · v = uₓvₓ + u_yv_y + u_zv_z returns a number, and that number is |u||v|·cos θ: it measures how far the two point the same way. It is zero when they are perpendicular, and it is the calculation behind the work done by a force along a displacement and behind the projection of one vector onto another.
The cross product u × v returns another vector instead, square to both, of magnitude |u||v|·sin θ. That magnitude is the area of the parallelogram the two span — half of it is the triangle — while its direction gives the normal to the plane they determine. It exists only in space: in the plane all that survives is the z component, which is the signed area, positive when v lies to the left of u.
The angle between two vectors can be recovered from either product, but not equally well. The dot product gives cos θ, and the cosine is flat near 0° and 180°: there, a rounding error in the ninth digit moves the angle in the fifth. This calculator uses the arctangent of the cross product's magnitude against the dot product instead, which stays sharp at both ends — which is why two nearly parallel vectors get a trustworthy angle here.
Common mistakes
- Swapping the two products. The dot product gives a number, the cross product gives a vector: if the answer wanted is an area or a normal it is the second, and if it is work or a projection it is the first.
- Assuming u × v equals v × u. The cross product changes sign when the factors swap: u × v = −(v × u). The dot product is symmetric, and that is where the wrong habit comes from.
- Confusing the unit vector with the vector. The unit vector points the same way but has magnitude 1, and comes from dividing each component by the magnitude. The zero vector is the only one without one, because it has no direction to keep.
Frequently asked questions
How do you find the angle between two vectors?
From u · v = |u||v|·cos θ, so θ = arccos(u · v / (|u||v|)). Near 0° and 180° that formula loses precision, because the cosine is flat there: θ = atan2(|u × v|, u · v) is steadier, and that is the form used here.
When are two vectors perpendicular?
When their dot product is zero. There is no need for the angle: if uₓvₓ + u_yv_y + u_zv_z comes to zero and neither vector is the zero vector, the angle is 90°.
How can you tell whether two vectors are parallel?
When the cross product vanishes, which is to say when one is a multiple of the other. In the plane it is enough to check that uₓv_y − u_yvₓ is zero. Careful: vectors pointing opposite ways are parallel too, and their angle is 180°.
What is the projection of one vector onto another for?
For splitting a vector into two parts: the one along v and the one square to it. The first is (u · v / |v|²)·v and the second is what remains. It is the step behind resolving forces on an inclined plane and behind orthogonalising a basis.
How do you find the area of a triangle from two vectors?
It is half the magnitude of the cross product: area = |u × v|/2. In the plane that reduces to |uₓv_y − u_yvₓ|/2. Given three vertices A, B and C, take u = B − A and v = C − A.
How this calculation works
Magnitude: |u| = √(uₓ² + u_y² + u_z²). Unit vector: û = u/|u|, defined only when |u| ≠ 0. Sum and difference: component by component. Dot product: u · v = uₓvₓ + u_yv_y + u_zv_z = |u||v|·cos θ. Cross product: u × v = (u_yv_z − u_zv_y, u_zvₓ − uₓv_z, uₓv_y − u_yvₓ), with |u × v| = |u||v|·sin θ; in the plane only the z component survives. Angle: θ = atan2(|u × v|, u · v), preferred to the arccosine because it stays accurate near 0° and 180°. Parallelogram area: |u × v|; triangle: half of it. Projection of u onto v: scalar component u · v/|v|, vector (u · v/|v|²)·v; the perpendicular part is u less that projection. Distance between the tips: |u − v|. Perpendicular when u · v = 0; parallel when |u × v| = 0. Both tests use a tolerance proportional to |u||v|, because in floating point a product that ought to vanish almost never comes to exactly zero.
Related calculators
Line through two points
Equation of the line in slope-intercept and standard form, slope and intercepts.
Distance and midpoint
Distance between two points in the coordinate plane and coordinates of the midpoint.
Conic sections
Identifies the conic from its general equation and finds centre, foci, axes, eccentricity, asymptotes and canonical form.
Matrices and vectors
Addition, product, determinant, transpose, dot product and magnitude for matrices and vectors.