How to use the vector calculator
- Choose 2D or 3D and enter the components of vector A and vector B.
- Enter a scalar k if you want the scalar multiples k A and k B.
- Read the angle, dot product and magnitudes at the top. The table below lists the sum, difference, cross product, scalar multiples, unit vectors and the projection of A on B.
- Check the steps for the arithmetic behind each result.
Formula
A . B = ax bx + ay by + az bz
|A| = sqrt(ax^2 + ay^2 + az^2)
A x B = (ay bz - az by, az bx - ax bz, ax by - ay bx)
cos(theta) = A . B / (|A| |B|)
proj of A on B = (A . B / |B|^2) B
The dot product measures how much two vectors point the same way. The cross product is a vector at right angles to both A and B, and its length is the area of the parallelogram they span.
Worked example
Take A = (1, 2, 3) and B = (4, 5, 6). The sum is (5, 7, 9), the difference is (-3, -3, -3), the dot product is 4 + 10 + 18 = 32 and the cross product is (-3, 6, -3).
The magnitudes are |A| = 3.741657 and |B| = 8.774964, so cos(theta) = 32 / 32.833 and the angle is 12.933154 degrees, or 0.225726 radians. The projection of A on B is (32 / 77) B = (1.662338, 2.077922, 2.493506).
What each result tells you
A dot product of 0 means the vectors are perpendicular. A positive value means the angle between them is under 90 degrees and a negative value means it is over 90 degrees. The cross product is 0 when the vectors are parallel.
A unit vector has length 1 and keeps the direction. The scalar projection is the signed length of the shadow A casts on the line of B.
Zero vectors
A zero vector has no direction. The angle, the unit vector of the zero vector and any projection onto a zero vector are reported as Undefined rather than as a made-up number.
2D vectors and the cross product
Strictly, the cross product exists in three dimensions. For 2D input the calculator shows the z component of the cross product of the same vectors placed in the xy plane, which is ax by - ay bx. Its sign tells you whether B is counterclockwise or clockwise from A.
Rounding
Results are shown to six decimal places. The cosine used for the angle is clamped to the range -1 to 1, so tiny floating point errors cannot produce an invalid angle for parallel or opposite vectors.
Assumptions and limits
- Components are real numbers with absolute value up to 10^100.
- Vectors are free vectors in a Cartesian coordinate system.
- Angles are between 0 and 180 degrees. Radians are shown for the same angle.
- Results are rounded to six decimals for display only.
Frequently asked questions
How do I find the angle between two vectors?
Divide the dot product by the product of the magnitudes and take the inverse cosine. The tool does this and gives degrees and radians.
When is the cross product zero?
When A and B are parallel, pointing the same or opposite ways, or when either one is the zero vector.
What is a unit vector?
A vector of length 1 pointing the same way as the original. You get it by dividing each component by the magnitude.
Why does projection of A on B differ from B on A?
The projection lies along the vector you project onto. Projecting A on B gives a vector parallel to B, and the reverse gives one parallel to A.
Can I use this for 2D problems?
Yes, choose 2D and only x and y are used. The cross product becomes a single z component.