Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

How to Compute an Inner Product

An inner product turns two vectors into one number. Multiply matching parts, add them up, and the same number then gives lengths, distances and angles.

Recognize the task

The problem asks for ⟨u,v⟩\langle \mathbf{u}, \mathbf{v} \rangle or u⋅v\mathbf{u} \cdot \mathbf{v}, a length ∥v∥\|\mathbf{v}\|, a distance, or an angle: (1,2,−2)⋅(3,0,4)(1, 2, -2) \cdot (3, 0, 4), ⟨u,v⟩=2u1v1+u2v2\langle \mathbf{u}, \mathbf{v} \rangle = 2u_1v_1 + u_2v_2, ⟨f,g⟩=∫01f(x)g(x) dx\langle f, g \rangle = \int_0^1 f(x)g(x)\,dx. Test: is a rule given? If not, use the standard dot product.
Inner products are defined in the inner product lesson; a rule must satisfy the inner product axioms.

Ways to do it

Standard dot productvectors in Rⁿ
u⋅v=u1v1+u2v2+⋯+unvn\mathbf{u} \cdot \mathbf{v} = u_1v_1 + u_2v_2 + \cdots + u_nv_n
The default in Rn\mathbb{R}^n (algebraic dot product).
Weighted inner productpositive weights
⟨u,v⟩=w1u1v1+⋯+wnunvn,wi>0\langle \mathbf{u}, \mathbf{v} \rangle = w_1u_1v_1 + \cdots + w_nu_nv_n, \quad w_i > 0
Multiply each product by its weight before adding; every weight must be positive.
Function inner productfunctions on an interval
⟨f,g⟩=∫abf(x) g(x) dx\langle f, g \rangle = \int_a^b f(x)\,g(x)\,dx
Multiply the functions and integrate; see the examples of inner products.

Steps

StepOn u=(1,2,−2)\mathbf{u} = (1, 2, -2), v=(3,0,4)\mathbf{v} = (3, 0, 4)
1Identify the inner product. No rule given in Rn\mathbb{R}^n means the standard dot product. Check that both vectors have the same number of entries.standard dot product in R3\mathbb{R}^3
2Multiply matching entries. Entry 1 with entry 1, entry 2 with entry 2, and so on. With weights, multiply each product by its weight.1⋅3,  2⋅0,  (−2)⋅41 \cdot 3,\; 2 \cdot 0,\; (-2) \cdot 4
3Add the products. The sign carries meaning: positive means an acute angle, zero means orthogonal, negative means obtuse.u⋅v=3+0−8=−5\mathbf{u} \cdot \mathbf{v} = 3 + 0 - 8 = -5
4Take lengths from the same inner product. The norm is ∥v∥=⟨v,v⟩\|\mathbf{v}\| = \sqrt{\langle \mathbf{v}, \mathbf{v} \rangle}. A distance is the length of the difference u−v\mathbf{u} - \mathbf{v}.∥u∥=9=3\|\mathbf{u}\| = \sqrt{9} = 3, ∥v∥=25=5\|\mathbf{v}\| = \sqrt{25} = 5
5Find the angle if asked. Divide the inner product by both lengths (angle formula). The Cauchy-Schwarz inequality keeps the ratio between −1-1 and 11.cos⁡θ=−53⋅5=−13\cos\theta = \frac{-5}{3 \cdot 5} = -\frac{1}{3}, θ≈109.47∘\theta \approx 109.47^\circ

Worked examples

Example 1 · four entries

dot product
(1,−1,2,0)⋅(3,1,1,5)(1, -1, 2, 0) \cdot (3, 1, 1, 5)
match entries in order
=3−1+2+0= 3 - 1 + 2 + 0
multiply each pair
=4= 4
add

Example 2 · a weighted rule

weights 2 and 1
⟨u,v⟩=2u1v1+u2v2\langle \mathbf{u}, \mathbf{v} \rangle = 2u_1v_1 + u_2v_2, u=(1,2)\mathbf{u} = (1, 2), v=(3,−1)\mathbf{v} = (3, -1)
the rule is given
⟨u,v⟩=2⋅1⋅3+2⋅(−1)=4\langle \mathbf{u}, \mathbf{v} \rangle = 2 \cdot 1 \cdot 3 + 2 \cdot (-1) = 4
weight the first product
⟨u,v⟩=4\langle \mathbf{u}, \mathbf{v} \rangle = 4, ∥u∥=2⋅1+4=6\|\mathbf{u}\| = \sqrt{2 \cdot 1 + 4} = \sqrt{6}
length under the same rule

Example 3 · two functions

integral
⟨x,x2⟩=∫01x3 dx=14\langle x, x^2 \rangle = \int_0^1 x^3\,dx = \frac{1}{4}
multiply, then integrate
∥x∥=∫01x2 dx=13\|x\| = \sqrt{\int_0^1 x^2\,dx} = \frac{1}{\sqrt{3}}, ∥x2∥=15\|x^2\| = \frac{1}{\sqrt{5}}
norms from the same integral
cos⁡θ=1/41/15=154≈0.968\cos\theta = \frac{1/4}{1/\sqrt{15}} = \frac{\sqrt{15}}{4} \approx 0.968
the two functions are nearly parallel
Check your numbers in the vector calculator.

See it happen

The dot product is the length of one vector times the shadow the other casts on it: u⋅v=∥u∥∥v∥cos⁡θ\mathbf{u} \cdot \mathbf{v} = \|\mathbf{u}\|\|\mathbf{v}\|\cos\theta. A long shadow in the same direction gives a large positive number, no shadow gives zero, and a shadow pointing backwards gives a negative number. Move the vectors in the inner product visualizer.

Common mistakes

Forgetting the square root

✗ ∥(3,0,4)∥=9+0+16=25\|(3, 0, 4)\| = 9 + 0 + 16 = 25
✓ ∥(3,0,4)∥=25=5\|(3, 0, 4)\| = \sqrt{25} = 5

Ignoring the given weights

✗ with ⟨u,v⟩=2u1v1+u2v2\langle \mathbf{u}, \mathbf{v} \rangle = 2u_1v_1 + u_2v_2: (1,2)⋅(3,−1)=1(1, 2) \cdot (3, -1) = 1
✓ 2⋅1⋅3+2⋅(−1)=42 \cdot 1 \cdot 3 + 2 \cdot (-1) = 4
Lengths and angles must use the same rule as the inner product.

Squared lengths in the angle formula

✗ cos⁡θ=−5∥u∥2∥v∥2=−145\cos\theta = \frac{-5}{\|\mathbf{u}\|^2\|\mathbf{v}\|^2} = -\frac{1}{45}
✓ cos⁡θ=−53⋅5=−13\cos\theta = \frac{-5}{3 \cdot 5} = -\frac{1}{3}

Leaving the products unadded

✗ (1,2)⋅(3,4)=(3,8)(1, 2) \cdot (3, 4) = (3, 8)
✓ (1,2)⋅(3,4)=3+8=11(1, 2) \cdot (3, 4) = 3 + 8 = 11
An inner product is a number, not a vector.