Understanding the vector calculator — concept and principle
This calculator works with two 3D vectors a and b. It returns the dot product, the cross product, both magnitudes, the angle between the vectors, and the vector projection of a onto b. These operations are the core of vector algebra and appear in physics (work, torque, magnetic force), computer graphics (lighting, surface normals), machine learning (cosine similarity) and engineering statics. For 2D vectors, enter 0 or leave out the z component.
How it is calculated
- Dot product: a·b = a₁b₁ + a₂b₂ + a₃b₃.
- Cross product: a×b = (a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁).
- Magnitude: |a| = √(a₁² + a₂² + a₃²).
- Angle: θ = arccos(a·b ÷ (|a||b|)), in degrees from 0° to 180°.
- Projection of a on b: (a·b ÷ |b|²) × b.
The principle
Geometrically, a·b = |a||b| cos θ: it measures how much the two vectors point the same way. Combining this with the component formula gives the angle. The projection scales b by a·b ÷ |b|², the length of a's shadow on b divided by |b|. The cross product is a vector perpendicular to both a and b, with length |a||b| sin θ (the area of the parallelogram they span) and direction given by the right-hand rule.
Worked example
- Defaults: a = (1, 2, 3), b = (4, 5, 6).
- a·b = 1·4 + 2·5 + 3·6 = 4 + 10 + 18 = 32.
- a×b = (2·6 − 3·5, 3·4 − 1·6, 1·5 − 2·4) = (−3, 6, −3).
- |a| = √14 = 3.741657387; |b| = √77 = 8.774964387.
- cos θ = 32 ÷ (3.741657 × 8.774964) = 0.974632, so θ = 12.93315449°.
- Projection: 32 ÷ 77 = 0.415584 times (4, 5, 6) = (1.662337662, 2.077922078, 2.493506494).
How to read the result
A positive dot product means the angle is acute, zero means the vectors are perpendicular, and negative means obtuse. The cross product is (0, 0, 0) when the vectors are parallel. Here θ ≈ 12.9° shows that a and b point in nearly the same direction, and |a×b| = √54 ≈ 7.35 is the area of their parallelogram. You can check the cross product: (−3, 6, −3)·a = −3 + 12 − 9 = 0.
Common mistakes
- Treating the cross product as commutative; b×a = −(a×b).
- Confusing the scalar projection (a·b ÷ |b|) with the vector projection shown here.
- Forgetting that the cross product as written only exists in 3D.
Frequently asked questions
How do I check whether two vectors are perpendicular?
Their dot product is 0. For example (1, 0, 0)·(0, 3, 0) = 0.
What is cosine similarity?
It is a·b ÷ (|a||b|), the cosine of the angle between vectors, often used to compare data vectors. For the defaults it is 0.9746.
How do I get a vector perpendicular to a plane containing a and b?
Use a×b; it is normal to the plane spanned by a and b.
Sources: Gilbert Strang, Introduction to Linear Algebra, Chapter 1 (vectors, lengths and dot products) · James Stewart, Calculus: Early Transcendentals, sections on the dot product and the cross product