Vector Calculator
Calculate vector magnitude, addition, subtraction, unit vector, and angle between vectors in 2D and 3D.
Results
Vector Mathematics
A vector is a mathematical object that has both magnitude (length) and direction. Vectors are fundamental in physics, engineering, computer graphics, and machine learning. This vector calculator handles the most common vector operations in both 2D and 3D.
Magnitude (Length)
|v| = √(x² + y²) for 2D. |v| = √(x² + y² + z²) for 3D. The magnitude is the Euclidean distance from the origin to the vector's tip. It is always non-negative.
Unit Vector
A unit vector has magnitude 1 and points in the same direction as the original vector: û = v / |v|. Unit vectors are used to represent pure directions without scale, and appear in normal vectors, ray directions, and basis vectors.
Vector Addition and Subtraction
Add/subtract corresponding components: (3,4) + (1,−2) = (4,2). Geometrically, vector addition forms the "tip-to-tail" rule. Subtraction gives the vector from one point to another. The result of A − B points from B to A.
Angle Between Vectors
θ = arccos(A·B / (|A||B|)). Uses the dot product: A·B = AxBx + AyBy (+ AzBz in 3D). When θ=0°, vectors are parallel. When θ=90°, vectors are perpendicular (orthogonal). When θ=180°, vectors point in opposite directions.
Worked Example
Let A = (3, 4) and B = (1, −2) in 2D. Magnitude of A: |A| = √(9+16) = 5. Magnitude of B: |B| = √(1+4) = √5 ≈ 2.236. Sum A+B = (4, 2). Difference A−B = (2, 6). Dot product A·B = 3×1 + 4×(−2) = 3 − 8 = −5. Angle between them: θ = arccos(−5 / (5 × 2.236)) = arccos(−0.447) ≈ 116.6°. Since the angle exceeds 90°, the vectors point in broadly opposite directions.
Common Applications
Vectors appear throughout physics and engineering. Velocity, force, and displacement are all vector quantities — direction matters as much as magnitude. In computer graphics, unit vectors define surface normals for lighting calculations. In machine learning, data points are represented as high-dimensional vectors, and cosine similarity (closely related to the angle between vectors) measures how alike two documents or items are. Navigation systems use vector addition to combine wind speed with aircraft heading to find actual ground velocity.
| Operation | Formula | Example A=(3,4), B=(1,2) |
|---|---|---|
| Magnitude of A | √(x²+y²) | √(9+16) = 5 |
| Unit vector of A | A / |A| | (0.6, 0.8) |
| A + B | Component-wise sum | (4, 6) |
| A − B | Component-wise diff | (2, 2) |
| Dot product A·B | AxBx + AyBy | 3+8 = 11 |
| Angle between A, B | arccos(A·B / |A||B|) | arccos(11/√250) ≈ 45.97° |
Frequently Asked Questions
Magnitude = √(x²+y²) in 2D, √(x²+y²+z²) in 3D. It's the length of the vector. For v=(3,4): |v| = √(9+16) = √25 = 5.
A vector with magnitude 1. Found by û = v/|v|. For v=(3,4) with |v|=5: û = (3/5, 4/5) = (0.6, 0.8). Useful for representing pure direction.
Add corresponding components: (a₁,a₂,a₃) + (b₁,b₂,b₃) = (a₁+b₁, a₂+b₂, a₃+b₃). Geometrically, place the tail of B at the tip of A; the result points from the tail of A to the tip of B.
θ = arccos(A·B / (|A||B|)). First compute the dot product (sum of component products), then divide by the product of magnitudes, then take arccos. Result is in degrees (0°–180°).
Two vectors are orthogonal (perpendicular) when their dot product equals zero. The angle between them is 90°. For (1,0) and (0,1): 1×0+0×1=0 → orthogonal.
The cross product A×B is defined only in 3D and produces a new vector perpendicular to both A and B, with magnitude |A||B|sin(θ). It is used to find normal vectors to surfaces, calculate torque in physics, and determine the area of a parallelogram formed by two vectors.
A scalar has only magnitude (e.g., temperature: 25°C, speed: 60 mph). A vector has both magnitude and direction (e.g., velocity: 60 mph north, force: 10 N downward). Multiplying a vector by a scalar scales its length without changing direction (or reverses it if the scalar is negative).