Linear algebra tool

Vector Calculator

Perform common operations on 2D and 3D vectors. Calculate the sum, difference, scalar multiples, dot product, cross product, magnitudes, unit vectors, distance, and angle between vectors.

Enter your vectors

Enter two or three components separated by commas or spaces. Both vectors must have the same dimension.

Example: 2, 3 or 2, 3, 4

Use the same number of components as Vector A.

Used to calculate scalar × A and scalar × B.

Calculations are performed by PHP when the form is submitted.

Vector results

Calculation completed for 3D vectors.
A + B — Vector addition (3, 1, 6)
A − B — Vector subtraction (1, 5, 2)
Scalar × A (4, 6, 8)
Scalar × B (2, -4, 4)
Dot product A · B 4
Magnitude |A| 5.385164807
Magnitude |B| 3
Distance |A − B| 5.477225575
Cross product A × B (14, 0, -7)
Angle between A and B 75.66482971°

Unit vectors

Unit vector of A (0.3713906764, 0.5570860145, 0.7427813527)
Unit vector of B (0.3333333333, -0.6666666667, 0.6666666667)

Formulas

Addition

(a₁, a₂, ...) + (b₁, b₂, ...) = (a₁+b₁, a₂+b₂, ...)

Dot product

A · B = a₁b₁ + a₂b₂ + ... + aₙbₙ

Magnitude

|A| = √(a₁² + a₂² + ... + aₙ²)

Angle between vectors

θ = arccos((A · B) / (|A| |B|))

The angle is reported in degrees. It is undefined if either vector is zero.

3D cross product

A × B = (a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁)

How to use the vector calculator

  1. Enter Vector A using two components for 2D or three for 3D.
  2. Enter Vector B with the same number of components.
  3. Enter a scalar if you want scalar multiplication results.
  4. Click Calculate vectors to display all results.

Components can be separated by commas or spaces. Negative and decimal values are accepted. For example, enter 1, -2, 3.5.

Frequently asked questions

What is a vector?

A vector is a quantity represented by ordered components. A 2D vector has two components, while a 3D vector has three. Vectors are used to represent direction and magnitude in geometry, physics, and linear algebra.

What is the difference between a dot product and a cross product?

The dot product returns a scalar. The 3D cross product returns a vector perpendicular to both input vectors. For two-dimensional vectors, this calculator returns the scalar z-component of their cross product.

Why is the unit vector undefined for a zero vector?

A unit vector is obtained by dividing a vector by its magnitude. The zero vector has magnitude zero, so this division is undefined.

How is the angle between vectors calculated?

The calculator uses the inverse cosine of the dot product divided by the product of the two magnitudes. The answer is shown in degrees.

Related matrix and vector calculators

Remove any link above if its target page does not exist on your website.