Dot Product Calculator
Measure how two 2D or 3D vectors align, then decompose one onto the other without losing the projection direction. The lab shows component products, angle, cosine similarity, scalar and vector projection, perpendicular rejection, and a Cauchy–Schwarz boundary check.
Cosine similarity is about 0.974632 and the smaller angle is about 12.933154°.
Enter aligned coordinates
Vector A
Vector B
Dimension and projection direction
Alignment and projection report
Scalar projection: 3.646738
Vector projection: ⟨1.662338, 2.077922, 2.493506⟩
Perpendicular rejection: ⟨−0.662338, −0.077922, 0.506494⟩; rejection magnitude: 0.837436.
The angle and normalized similarity are undefined if either vector has zero magnitude. Projection is undefined if the target/basis vector is zero. The calculator reports those cases rather than dividing by zero.
Coordinate definition
Multiply matching coordinates and add. For the default, x contributes 1×4 = 4, y contributes 2×5 = 10, and z contributes 3×6 = 18. The total is 32. In 2D mode the calculator ignores both z entries and labels their contribution unused.
Coordinates must refer to the same ordered basis and compatible units. Pairing east with north or meters with feet without conversion produces arithmetic but not a meaningful dot product.
Geometric definition and angle
θ = arccos[(A · B)/(|A||B|)]
The default magnitudes are √14 ≈ 3.741657 and √77 ≈ 8.774964. Dividing 32 by their product gives cosine similarity 0.974632. The inverse cosine gives the smaller angle, approximately 12.933154 degrees.
The script clamps the computed cosine to the interval from −1 to 1 before inverse cosine. Floating-point rounding can otherwise produce 1.0000000000000002 for nearly parallel vectors and make a valid angle appear undefined.
What the sign means
A positive dot product corresponds to an acute angle and broadly aligned directions. Zero corresponds to orthogonality when both vectors are nonzero. A negative value corresponds to an obtuse angle and opposing components. The sign does not by itself measure magnitude or practical goodness.
Parallel same-direction vectors achieve cosine similarity +1, while antiparallel vectors achieve −1. Scaling either vector by a positive number leaves cosine similarity unchanged; a negative scale reverses its sign.
Cosine similarity
Cosine similarity is the normalized dot product. It removes vector length and retains orientation in the coordinate feature space. It is widely used in geometric analysis and data applications, but interpretation depends on preprocessing and whether negative, sparse, centered, or weighted features are appropriate.
Two vectors can have high cosine similarity yet very different magnitudes. In a data system, normalization can hide an important scale difference. Report both norms when scale matters.
Projection direction is ordered
compBA = A · B / |B|
“Project A onto B” uses B as the basis direction. The default scale factor is 32/77. Multiplying B by it gives ⟨1.662338, 2.077922, 2.493506⟩. The signed scalar component is 32/√77 ≈ 3.646738.
Projecting B onto A instead uses 32/14 times A. The dot product is symmetric, but vector projection is not, because its denominator and direction come from the selected basis. The interface labels the order and offers a selector.
Perpendicular rejection
The rejection is the source vector minus its projection onto the basis. For default A onto B, subtracting gives approximately ⟨−0.662338, −0.077922, 0.506494⟩. Its dot product with B is zero apart from floating-point error.
Projection plus rejection reconstructs the source vector. This decomposition is useful for separating along-track and cross-track motion, normal and tangential components, or fitted and residual portions under an orthogonal projection.
Cauchy–Schwarz boundary
The Cauchy–Schwarz inequality states |A·B| ≤ |A||B|. The panel reports the nonnegative slack |A||B| − |A·B|. Equality occurs when one vector is a scalar multiple of the other, including opposite direction.
A noticeably negative slack would signal numeric overflow, invalid data, or an implementation problem. Tiny negative roundoff should be treated using scale-aware tolerance, not blindly clipped in high-consequence work.
Zero-vector cases
The dot product with a zero vector is zero, but the angle is undefined because zero has no direction. Cosine similarity divides by both magnitudes and is also undefined. Projecting onto a zero basis is undefined because |B|² is zero.
Projecting the zero source onto a nonzero basis is defined as zero. The calculator distinguishes that case from a zero target basis. Do not label every zero dot product “perpendicular” without first checking both norms.
Work interpretation in physics
Mechanical work from a constant force is W = F · s. A force component along displacement contributes positive work; an opposite component contributes negative work; a perpendicular component contributes zero work. Units are force times displacement, such as newton-meters or joules.
The calculator does not integrate a changing force along a curved path. It also does not determine whether a coordinate frame is inertial or whether signs match a system convention. Enter consistent vectors from the physical model.
Dot product versus cross product
The dot product returns a scalar measuring aligned projection through cosine. The cross product in 3D returns a perpendicular vector whose magnitude measures area through sine. They answer complementary questions.
The full URL connects the related vector topics while each page preserves its distinct result structure.
Numerical and data audit
| Check | Why it matters |
|---|---|
| Dimension | Both vectors must use the same number of active coordinates |
| Basis | Coordinate order and axis orientation must match |
| Units | Corresponding components need compatible units |
| Zero norms | Angle, similarity, and some projections become undefined |
| Projection order | A onto B and B onto A are different vectors |
| Tolerance | Near-zero classification should reflect scale and uncertainty |
Worked two-dimensional example
Select 2D and enter A = ⟨3,4⟩ and B = ⟨4,−3⟩. The component products are 12 and −12, so the dot product is zero. Both vectors have magnitude 5, and their angle is 90 degrees. Projecting A onto B returns the zero vector, while the rejection remains A. The unused z inputs do not affect any result.
This example also shows that perpendicular vectors do not need to align with coordinate axes. Rotating a nonzero vector ⟨x,y⟩ by 90 degrees produces one perpendicular choice ⟨−y,x⟩; their dot product is −xy + xy = 0. Reversing that rotated vector gives the other perpendicular direction.
Why projection and rejection reconstruct the source
Let P be projBA and R = A − P. By definition, P is a scalar multiple of B. Dotting R with B gives A·B − [(A·B)/|B|²](B·B), which simplifies to zero. Therefore R is perpendicular to B and A = P + R is an orthogonal decomposition.
The squared lengths also satisfy |A|² = |P|² + |R|² under Euclidean coordinates. This Pythagorean check is useful for auditing computed projection output. It relies on the rejection being orthogonal; an arbitrary split of A into two vectors does not have the same squared-length identity.
Weighted and non-Euclidean inner products
This interface uses the ordinary Euclidean dot product, where each coordinate product has weight one. Some applications define an inner product using a positive-definite weight matrix, such as AᵀWB. That changes magnitudes, angles, orthogonality, and projections. Feature standardization can have a similar practical effect by changing coordinate scales before the ordinary dot product is applied.
Do not insert weights by multiplying only one arbitrary coordinate after calculation. Define the metric first and use formulas consistent with it. If a covariance inverse, mass matrix, or complex conjugation belongs in the domain’s inner product, this calculator’s Euclidean results are not substitutes.
Complex vectors are outside this calculator’s scope
For complex vector spaces, the standard Hermitian inner product conjugates one argument. A simple sum of matching complex products can fail positive-definiteness and produce unexpected self-products. This calculator accepts real numeric components only and does not implement conjugation.
The order of conjugation varies by notation convention, even though the geometric content is consistent when used carefully. Use a complex-linear-algebra tool and state the convention when working with phasors, quantum states, or complex signal vectors.
Data similarity requires preprocessing choices
When vectors represent documents, embeddings, customer features, or sensor windows, coordinate construction matters as much as the cosine formula. Missing values, centering, normalization, feature weighting, and incompatible model versions can invalidate comparisons. A high similarity is not automatically a causal, semantic, or identity claim.
Compare vectors from the same feature space and model release. Record whether they were normalized before storage and whether zero vectors can occur. Establish thresholds from validated examples for the application rather than adopting a universal “close enough” cosine.
Common hand-calculation mistakes
Frequent errors include multiplying unlike coordinates, forgetting a negative sign, taking the square root of the dot product instead of the sum of component squares for magnitude, and using |A| rather than |B| in projBA. Another is reporting the unsigned projection magnitude when the signed scalar component is required.
Write the projection label with a subscript identifying the basis, retain the dot product before rounding, and check that the vector projection is parallel to the basis. Finally, dot the rejection with that basis; it should be zero within a scale-appropriate tolerance.
Frequently asked questions
Is the dot product a vector?
No. In ordinary Euclidean coordinates it returns a scalar.
Does zero dot product always mean perpendicular?
Only when both vectors are nonzero. A zero vector has zero dot product with everything but no defined direction.
Why is projection order important?
The target basis determines the denominator and output direction, so projecting A onto B differs from projecting B onto A.
Can cosine similarity exceed one?
Not mathematically. Tiny excursions can come from floating-point rounding; this calculator clamps only the angle input.
Can I use 2D vectors?
Yes. Select 2D and the z entries are ignored.
What units does the dot product have?
The units are the product of the input component units. A normalized cosine similarity is unitless.
References
OpenStax Calculus Volume 3 — Dot product, angle, and projections
OpenStax University Physics — Scalar products and orientation