Vector Calculator
Perform vector operations: dot product, cross product, magnitude, and more.
2D Vectors
3D Vectors
Quick Examples
Vector Operations
Dot Product
The dot product gives a scalar. It measures projection and is zero for perpendicular vectors.
Cross Product (3D only)
The cross product gives a vector perpendicular to both A and B.
Magnitude
Angle Between Vectors
Formulas Summary
| Operation | Result Type | Properties |
|---|---|---|
| Dot Product | Scalar | A·B = |A||B|cos(θ) |
| Cross Product | Vector | |A×B| = |A||B|sin(θ) |
| Magnitude | Scalar | Always non-negative |
What Is a Vector?
A vector is a quantity with both size (magnitude) and direction — displacement, velocity, and force are vectors. A scalar has only size: speed, temperature, and mass are scalars. In components, a 2D vector is written ⟨x, y⟩ and a 3D vector ⟨x, y, z⟩, where the components are the steps along each axis. The basis vectors ⟨1, 0, 0⟩, ⟨0, 1, 0⟩, ⟨0, 0, 1⟩ are named i, j, k.
The geometry matters as much as the arithmetic: a vector is an arrow, and operations like addition (head-to-tail) and the dot product (a measure of alignment) have direct visual meaning.
Dot vs Cross: One Glance
| Dot Product A·B | Cross Product A×B | |
|---|---|---|
| Result type | Scalar (single number) | Vector (magnitude + direction) |
| Formula | |A||B|cos θ | |A||B|sin θ |
| Geometric meaning | How aligned the vectors are; projection length | Perpendicular vector; parallelogram area |
| Zero when… | Perpendicular (θ = 90°) | Parallel (θ = 0° or 180°) |
| Sign rule | Positive if angle < 90° | Direction follows the right-hand rule |
| Commutative? | Yes: A·B = B·A | No: A×B = −(B×A) |
| Dimensions | Works in 2D and 3D | Defined in 3D only |
Step-by-Step: Magnitude of ⟨3, 4, 12⟩
- Step 1 — Square each component: 3² = 9, 4² = 16, 12² = 144.
- Step 2 — Add: 9 + 16 + 144 = 169.
- Step 3 — Take the square root: √169 = 13.
- Step 4 — Note the type: the answer is a scalar — magnitude has no direction.
Worked Examples
Example 1: Dot product
⟨1, 2, 3⟩ · ⟨4, −5, 6⟩ = (1)(4) + (2)(−5) + (3)(6) = 4 − 10 + 18 = 12.
Example 2: Angle between vectors
For ⟨1, 0⟩ and ⟨1, 1⟩: A·B = 1, |A| = 1, |B| = √2, so cos θ = 1/√2 and θ = 45°.
Example 3: Cross product
⟨1, 0, 0⟩ × ⟨0, 1, 0⟩ = ⟨0, 0, 1⟩ — the unit vector perpendicular to both, following the right-hand rule.
Example 4: Unit vector
⟨3, 4⟩ has magnitude 5, so its unit vector is ⟨3/5, 4/5⟩ = ⟨0.6, 0.8⟩ — same direction, length 1.
Vector Projection
The projection of B onto A is the "shadow" B casts on A's direction: its length is |B|cos θ, and its vector form is ((A·B) / |A|²)A. For A = ⟨2, 3, 4⟩ and B = ⟨1, −2, 3⟩: A·B = 2 − 6 + 12 = 8 and |A|² = 29, so the projection is (8/29)⟨2, 3, 4⟩ = ⟨0.552, 0.828, 1.103⟩. Projection is the operation behind dot-product-based lighting in computer graphics.
Common Mistakes
- Adding magnitudes instead of components: |A| + |B| is not |A + B| — the triangle inequality says |A + B| ≤ |A| + |B|.
- Expecting a vector from a dot product: the dot product returns a number; only the cross product returns a vector.
- Using the cross product in 2D: it is defined in 3D only — treat 2D vectors as 3D vectors with z = 0 if you must cross them.
- Dividing by a zero vector's magnitude: the unit vector and the angle between vectors are undefined for the zero vector, which has no direction.
Vectors in the Real World
- Physics: forces add as vectors — two 10 N pushes at right angles make a √200 ≈ 14.14 N diagonal force, not 20 N.
- Navigation: aircraft correct for wind by adding the wind vector to the airspeed vector; the ground track is the vector sum.
- Computer graphics: surface lighting uses dot products (how aligned a surface is with the light) and cross products (which way the surface faces).
- Machine learning: word embeddings and neural-network activations are vectors in hundreds of dimensions; similarity is measured by the angle between them (cosine similarity) — the same dot-product idea in higher dimensions.
Scalar Multiplication and Linear Combinations
Multiplying a vector by a scalar stretches it (k > 1), shrinks it (0 < k < 1), flips it (k < 0), or zeroes it (k = 0) — the direction stays the same except for the sign flip. Each component is multiplied individually: 3·〈1, −2, 4〉 = 〈3, −6, 12〉.
Adding scaled vectors gives a linear combination, the building block of spans and bases: 2〈1, 2〉 + 3〈3, 4〉 = 〈2, 4〉 + 〈9, 12〉 = 〈11, 16〉. Every vector in the plane can be written this way from two non-parallel vectors — that is what "basis" means.
Direction Angles and Bearings
A 2D vector's direction is usually given as an angle from the positive x-axis, counterclockwise: θ = atan2(y, x). For 〈1, 1〉, θ = 45°. Navigation uses bearings instead: clockwise from north. A math angle of 45° (northeast) is a bearing of 045°, but a math angle of 135° (northwest) is a bearing of 315° — the two conventions run in opposite directions from different zero points. Converting between them: bearing = (90° − math angle) mod 360°.
Frequently Asked Questions
What is the difference between a vector and a scalar? A vector has magnitude and direction (velocity, force); a scalar has magnitude only (speed, temperature, mass).
When should I use dot vs cross product? Dot for alignment questions (angle, projection, work); cross for perpendicular constructions (normals, torque, area).
What is a unit vector? A vector of length 1 pointing the same way: v / |v|. It carries pure direction, used wherever only the heading matters.
How do I find the angle between two vectors? θ = arccos((A·B) / (|A||B|)), always between 0° and 180°.
Why is A × B = −(B × A)? The cross product follows the right-hand rule, so swapping the inputs flips the perpendicular direction.