The scalar product, better known as the dot product, is one of the most useful operations in all of mathematics. It takes two vectors and combines them into a single number — a scalar — that tells you how much the two vectors point in the same direction. Whether you are resolving forces in physics, computing lighting in a video game, or measuring the similarity of two data sets, the scalar product is the tool that gets you the answer. This page explains exactly what the dot product is, how to compute it by hand, what it means geometrically, and how to use the Scalar Product Calculator above to get instant, accurate results.
Using the calculator is simple: choose 2D or 3D, type in the components of vectors a and b, and press Calculate. You will instantly see the scalar product a·b, both magnitudes, the angle in degrees and radians, the orthogonality verdict, and the scalar projection of a onto b.
What Is the Scalar Product?
In linear algebra, the scalar product (also called the dot product or inner product) is a binary operation that takes two vectors of the same dimension and returns a single real number. Unlike vector addition or scalar multiplication, which produce new vectors, the scalar product collapses two vectors down to one number. That number carries powerful geometric meaning: its sign tells you whether the vectors point roughly together or roughly apart, its magnitude tells you how strongly they align, and a value of zero tells you they are perpendicular.
The operation is written with a dot between the vectors: a·b. Do not confuse it with the cross product (a×b), which exists only in three dimensions and returns a vector. The scalar product works in any dimension and always returns a scalar — which is why it appears in classical mechanics, computer graphics, statistics, and artificial intelligence.
The Algebraic Formula
Algebraically, the scalar product is computed by multiplying corresponding components of the two vectors and adding the results. For two-dimensional vectors a = (aₐ, aₑ) and b = (bₐ, bₑ), the formula is:
a·b = aₐbₐ + aₑbₑ
For three-dimensional vectors a = (aₐ, aₑ, aₒ) and b = (bₐ, bₑ, bₒ), add the third pair of products:
a·b = aₐbₐ + aₑbₑ + aₒbₒ
In general, for n-dimensional vectors the rule is a·b = Σ aᵢbᵢ over all i from 1 to n. As a concrete example, take a = (3, −2) and b = (1, 4). Their scalar product is (3)(1) + (−2)(4) = 3 − 8 = −5. The negative result immediately tells us the two vectors point, on balance, in opposite directions. The Scalar Product Calculator performs exactly this component-by-component multiplication and addition for you, with full decimal precision.
Geometric Interpretation
The true power of the scalar product comes from its geometric form. If |a| and |b| are the lengths (magnitudes) of the two vectors and θ is the angle between them, then:
a·b = |a| |b| cos θ
This equation connects the algebraic computation with the geometry of the vectors: the dot product is the product of the two lengths, scaled by the cosine of the angle between them, reaching its maximum when the vectors are parallel and its minimum when they are anti-parallel.
This interpretation also gives a precise meaning to the sign of the result:
- Positive dot product (a·b > 0): the angle between the vectors is acute (less than 90°), so the vectors point in roughly the same direction.
- Zero dot product (a·b = 0): the angle is exactly 90°, so the vectors are perpendicular (orthogonal), provided neither is the zero vector.
- Negative dot product (a·b < 0): the angle is obtuse (greater than 90°), so the vectors point in roughly opposite directions.
Intuitively, the scalar product measures “how much of one vector lies along the other.” This shadow picture is the key to understanding projections, which we cover below.
Key Properties of the Scalar Product
The scalar product satisfies these algebraic laws:
- Commutative: a·b = b·a. The order of the vectors does not matter.
- Distributive over addition: a·(b + c) = a·b + a·c. You can expand brackets exactly as in ordinary algebra.
- Bilinear (scalar multiplication): (k·a)·b = k(a·b) for any scalar k.
- Positive definite: a·a ≥ 0, and a·a = 0 only when a is the zero vector. In fact, a·a = |a|², so the dot product of a vector with itself is the square of its length.
- Not associative: (a·b)·c is meaningless as written, because a·b is a scalar and cannot be dotted with a vector. Parentheses matter — a·(b·c) is equally invalid.
Orthogonality: Detecting Right Angles
Two vectors are orthogonal (perpendicular) exactly when their scalar product is zero — as long as neither vector is the zero vector. This fact turns the abstract idea of “perpendicular” into a concrete calculation: multiply the matching components, add them up, and check whether the total is zero. No protractor or diagram is needed.
For example, a = (2, 3) and b = (−3, 2) give a·b = (2)(−3) + (3)(2) = −6 + 6 = 0, so these vectors meet at a right angle. The Scalar Product Calculator flags orthogonality automatically and accounts for tiny floating-point rounding errors when it does so.
Orthogonality is one of the most exploited properties of the dot product in practice. In computer graphics, surface normals must be perpendicular to tangent directions; in signal processing, orthogonal signals do not interfere; and in linear algebra, the Gram–Schmidt process builds orthogonal bases one dot product at a time.
Scalar and Vector Projections
The Scalar Projection
The scalar projection (also called the scalar component) of a onto b is the signed length of a’s shadow along b. It is computed as:
compb a = (a·b) / |b|
The sign tells you whether a points along b (positive) or against b (negative). This is exactly what the calculator reports as the “scalar projection of a onto b.”
The Vector Projection
If you want not just the length of the shadow but the actual vector pointing along b, use the vector projection formula:
projb a = ((a·b) / (b·b)) · b
This returns a vector parallel to b whose tip lands exactly where a’s perpendicular shadow falls. The remainder, a − projb a, is automatically orthogonal to b.
Why Projections Matter
Decomposing a force into components parallel and perpendicular to a ramp is a projection problem, and so is extracting the part of a signal that matches a template. Once you see projections as applications of the scalar product, a huge family of problems collapses into one formula.
Finding the Angle Between Two Vectors
Rearranging the geometric formula gives the standard way to compute the angle θ between any two non-zero vectors:
θ = arccos( (a·b) / (|a| |b|) )
The procedure is mechanical: compute the dot product, compute both magnitudes, divide, and take the inverse cosine. The result is always a valid angle between 0° and 180°.
For example, with a = (3, −2) and b = (1, 4): the dot product is −5, |a| ≈ 3.6056, and |b| ≈ 4.1231. The cosine is −5 / (3.6056 × 4.1231) ≈ −0.3364, so θ ≈ 109.65°. The obtuse angle confirms the negative dot product we found earlier.
How to Use the Scalar Product Calculator
- Select the dimension. Click “2D Vectors” for planar vectors with x and y components, or “3D Vectors” to reveal the z-component fields for spatial vectors.
- Enter the components of vector a. Type any real numbers — positive, negative, or decimal — into the a fields.
- Enter the components of vector b. Fill in the matching fields for the second vector.
- Press Calculate. The results appear instantly: the scalar product, both magnitudes, the angle in degrees and radians, the orthogonality verdict, and the scalar projection of a onto b.
- Press Reset to restore the default example values, or switch dimensions to start a new calculation.
If any field is left empty or contains non-numeric text, the calculator shows a clear error message instead of a wrong answer. Note that the angle and the projection are undefined when either vector is the zero vector — the calculator reports this explicitly rather than returning a misleading zero.
Worked Examples
Example 1: Two-Dimensional Vectors
Compute the scalar product of a = (5, −1) and b = (2, 7), then find the angle between them. Step 1 — dot product: a·b = (5)(2) + (−1)(7) = 10 − 7 = 3. Step 2 — magnitudes: |a| = √26 ≈ 5.0990; |b| = √53 ≈ 7.2801. Step 3 — angle: cos θ = 3 / (5.0990 × 7.2801) ≈ 0.0808, so θ ≈ 85.37°. The small positive dot product and the near-right angle agree: the vectors are almost perpendicular but tilt slightly toward each other.
Example 2: Three-Dimensional Vectors
Compute the scalar product of a = (1, 4, −2) and b = (3, 0, 5), and check for orthogonality. Dot product: a·b = (1)(3) + (4)(0) + (−2)(5) = 3 + 0 − 10 = −7. Since −7 ≠ 0, the vectors are not orthogonal; the negative sign shows the angle is obtuse. Magnitudes: |a| = √21 ≈ 4.5826; |b| = √34 ≈ 5.8310. Angle: cos θ = −7 / (4.5826 × 5.8310) ≈ −0.2620, giving θ ≈ 105.19°.
Real-World Applications
Physics and Engineering
The most famous application is work: when a constant force F moves an object through displacement d, the work done is W = F·d. Only the component of force along the displacement counts, which is exactly what the dot product extracts. Power is likewise the dot product of force and velocity, P = F·v.
Computer Graphics and Game Development
Every lit 3D scene on your screen depends on the scalar product. The brightness of a surface is proportional to n·l, the dot product of the surface normal n and the light direction l — this is the heart of Lambertian shading. Back-face culling discards polygons whose normal points away from the camera (negative dot product with the view direction).
Machine Learning and Data Science
In machine learning, the dot product measures similarity. A neuron in a neural network computes w·x + b — the dot product of its weights with the input — before applying an activation function. Cosine similarity, the standard way to compare document embeddings or user profiles, is simply the dot product normalized by the two magnitudes: cos θ = (a·b)/(|a||b|).
Common Mistakes to Avoid
- Mixing up dot and cross products. The dot product returns a scalar and works in any dimension; the cross product returns a vector and exists only in 3D (and 7D). Check which one the problem actually asks for.
- Trying to dot vectors of different dimensions. You cannot take the scalar product of a 2D vector with a 3D vector — component-wise multiplication requires matching pairs.
- Forgetting that a·b = 0 needs non-zero vectors. The zero vector is technically “orthogonal” to everything by the formula, but the geometric angle is undefined. Treat zero-vector results with care.
- Confusing the scalar projection with the vector projection. The scalar projection is a number (a length with a sign); the vector projection is a vector. They answer different questions.
- Assuming a positive dot product means parallel. It only means the angle is acute — “parallel” requires the angle to be exactly 0° (or 180°).
Frequently Asked Questions
What is a scalar product?
The scalar product, also called the dot product, multiplies corresponding components of two vectors and adds the results, producing a single number. It measures how much two vectors point in the same direction and underpins angle, projection, and orthogonality calculations.
How do you calculate the scalar product of two vectors?
Multiply each pair of corresponding components and add the products: for a = (aₐ, aₑ) and b = (bₐ, bₑ), it is aₐbₐ + aₑbₑ, plus the third pair in 3D. The Scalar Product Calculator above performs this instantly for 2D and 3D vectors.
What does the scalar product tell you geometrically?
Geometrically, a·b = |a||b|cos θ. A positive value means an acute angle, zero means a right angle, and a negative value means an obtuse angle — the sign alone reveals the qualitative relationship between the vectors.
What is the difference between the scalar product and the dot product?
There is no difference — they are two names for the same operation. “Scalar product” emphasizes that the result is a scalar (a single number), while “dot product” refers to the dot notation a·b.
How do you know if two vectors are orthogonal using the scalar product?
Two non-zero vectors are orthogonal (perpendicular) if and only if their scalar product equals zero. Compute a·b by multiplying corresponding components and adding; if the total is zero, the vectors meet at exactly 90°.
Can the scalar product be negative?
Yes — whenever the angle between the vectors is obtuse (between 90° and 180°), because cos θ is negative in that range. For example, a = (3, −2) and b = (1, 4) give a·b = −5, confirming the vectors point in roughly opposite directions.
What is the scalar product of a vector with itself?
It equals the square of the vector’s magnitude: a·a = |a|², since cos 0° = 1. This gives a convenient way to compute squared lengths without a square root.
How do you find the angle between two vectors with the scalar product?
Use θ = arccos((a·b) / (|a||b|)): compute the dot product, divide by the product of the two magnitudes, and take the inverse cosine. The Scalar Product Calculator reports the result in both degrees and radians.
What is a scalar projection?
The scalar projection of a onto b is the signed length of a’s “shadow” cast along b, computed as (a·b)/|b|. Positive means a extends in b’s direction; negative means it extends opposite to b.
Is the scalar product commutative?
Yes: a·b = b·a for any vectors a and b, because the sum of pairwise products does not depend on the order. Swapping the two vectors in the calculator always gives the same scalar product.
Can you take the scalar product of a 2D vector and a 3D vector?
No — both vectors must have the same number of components. You can, however, embed a 2D vector in 3D by adding a zero z-component: (3, −2) becomes (3, −2, 0).
What happens if one of the vectors is the zero vector?
The scalar product is zero, since every component product is zero. However, the angle and the scalar projection become undefined, because both require dividing by the zero vector’s magnitude — the calculator reports “undefined” instead of a misleading number.
How is the scalar product used in physics?
Mechanical work is the dot product of force and displacement (W = F·d), and power is the dot product of force and velocity (P = F·v). Resolving any vector into components along chosen axes is a projection built on the scalar product.
How is the scalar product used in computer graphics?
Lighting uses the dot product of the surface normal and the light direction to determine brightness (Lambertian shading). Back-face culling, reflection vectors, and field-of-view tests all rely on dot products to compare directions quickly.
What is the relationship between the scalar product and cosine similarity?
Cosine similarity is the normalized scalar product: cos θ = (a·b)/(|a||b|). It divides out the magnitudes so only the angle matters, giving a similarity score between −1 and 1 used widely to compare embeddings and documents.