Biostatistics · Intermediate

The Scalar Product in Rn

Written by SignalsLab

Early edition: these lessons are being reviewed.

Content

Summary

The scalar product of two vectors in Rn is the sum of the products of their corresponding components, resulting in a real number that geometrically relates to the vectors' lengths and the cosine of the angle between them. This operation allows for the calculation of Euclidean length, distance, and orthogonality, serving as the foundation for projections and least squares applications.

Intuition

Think of the scalar product as a way to measure how much two vectors align with each other. If you multiply corresponding components and sum them up, you get a single number that tells you about their relationship. This number helps us calculate lengths, distances, and angles, and it is crucial for breaking down vectors into parts, which is essential for solving complex problems like least squares in biostatistics.

Key equations

xTy=∑i=1nxiyi
(1)

The scalar product of vectors x and y in Rn, calculated as the sum of the products of corresponding components.

‖x‖=(xTx)1/2
(2)

The Euclidean length (norm) of vector x, derived from its scalar product with itself.

‖x−y‖
(3)

The distance between vectors x and y, defined as the norm of their difference.

xTy=‖x‖‖y‖cos⁡θ
(4)

The relationship between the scalar product, the lengths of vectors x and y, and the cosine of the angle θ between them.

|xTy|≤‖x‖‖y‖
(5)

The Cauchy-Schwarz Inequality, bounding the absolute value of the scalar product by the product of the norms.

Derivation

  1. Define the scalar product of two vectors x and y in Rn as the matrix product x^T y, which results in a 1x1 matrix interpreted as a real number.
  2. Calculate the scalar product by summing the products of corresponding components: x^T y = x1y1 + x2y2 +... + xnyn.
  3. Define the Euclidean length (norm) of a vector x using the scalar product as ||x|| = (x^T x)^(1/2).
  4. Define the distance between two vectors x and y as the norm of their difference, ||x - y||.
  5. Relate the scalar product to geometry using the formula x^T y = ||x|| ||y|| cos θ, where θ is the angle between nonzero vectors x and y.
  6. Define orthogonality: two vectors x and y are orthogonal if their scalar product is zero, i.e., x^T y = 0.
  7. State the Cauchy-Schwarz Inequality: |x^T y| ≤ ||x|| ||y||, which holds for any vectors x and y in R2 or R3.

Worked example

Problem

Given vectors x = (3, -2, 1)^T and y = (4, 3, 2)^T, calculate their scalar product and determine if they are orthogonal.

  1. Identify the components of x: x1=3, x2=-2, x3=1.
  2. Identify the components of y: y1=4, y2=3, y3=2.
  3. Calculate the scalar product: x^T y = 3(4) + (-2)(3) + 1(2).
  4. Perform the multiplication: 12 - 6 + 2.
  5. Sum the results: 8.
  6. Check for orthogonality: Since x^T y = 8 ≠ 0, the vectors are not orthogonal.

Answer The scalar product is 8, and the vectors are not orthogonal.

Common mistakes

  • Confusing the scalar product with the vector cross product; the scalar product results in a scalar (real number), not a vector.
  • Assuming the Cauchy-Schwarz inequality holds for all inner product spaces without verifying the conditions; the text specifies it for R2 and R3 with the standard scalar product.
  • Forgetting that the zero vector is orthogonal to every vector, as 0^T y = 0 for any y.
  • Misinterpreting the angle θ; it is defined only for nonzero vectors in R2 or R3 as the angle between the directed line segments starting at the same point.
  • Believing that x^T y = 0 implies both vectors are zero; it only implies one is zero or they are orthogonal (perpendicular).

Animation

Animation coming soon

The animated version of this lesson is being prepared for the web. In the Signals AI app, lessons are drawn step by step.

Code

This is a text lesson: it has no animation code yet.

ccBYNC© 2026 SignalsLab. Lesson text shared as is under CC BY-NC 4.0.