Euclidean space — exam-style exercises with music taste: norms, cosines, Gram matrix, Gram-Schmidt and a Campus-style quiz (and the form I ticked too many times)

In quiz 3 on the Campus there was a multiple-answer question with four ways of writing the dot product of two vectors of R2\mathbb{R}^2 with the identity, and I got half marks: I ticked the two right ones and also the column-times-row ones. As in the exam each wrongly ticked option cancels a right one, I lost half. A column times a matrix times a row cannot even be multiplied; fragment 1 of “What’s wrong here?” is about that.

How to use this article

In the AG exam, EX=(T+P)/2EX = (T + P)/2: T is the 20-question test taken from the Campus quizzes and P, the written exercises. You can see how it combines with the quizzes and the assignments in the AG grade calculator.

In recent years’ exams there is no exercise only about the Euclidean space: the topic appears inside the bilinear forms exercise, when they ask you to “compute, if possible, the cosine of the angle” with the dot product the form defines, and in the test, where half of quiz 3 is norms, angles, orthogonality and Gram matrix. That is why the exercises here have the format of one part of an exam question (marks and criteria), and the 20-question quiz at the end is where most is at stake.

  • Do each exercise on paper: first write down the Gram matrix you need.
  • Compare with the expected result and, if it does not match, open the hint before looking at the solution.
  • In “What’s wrong here?”, look for the mistake yourself before reading the explanation.
  • Do the quiz and check the exercises in MATLAB. For the systems that come up when looking for perpendiculars, the Gauss-Jordan step-by-step simulator also works.

If some method gets stuck, go back to the Euclidean space guided practice.

Exercise 1 (basic level): four genres

Exercise 1. [3 points] In R4\mathbb{R}^4 with the standard dot product, the weekly hours of pop, rock, classical and reggaeton of three friends are m⃗=(1,2,2,4)\vec m = (1, 2, 2, 4), j⃗=(2,0,1,2)\vec j = (2, 0, 1, 2) and k⃗=(0,3,0,0)\vec k = (0, 3, 0, 0). a) (1 point) Compute ∥m⃗∥\lVert \vec m \rVert, ∥j⃗∥\lVert \vec j \rVert and the unit vector with the direction and sense of m⃗\vec m. b) (1 point) Compute the cosine and the angle between m⃗\vec m and j⃗\vec j, and say whether j⃗\vec j and k⃗\vec k are orthogonal. c) (1 point) Compute the orthogonal projection of m⃗\vec m onto L{j⃗}L\{\vec j\} and check that the remainder is orthogonal to j⃗\vec j.

Expected result: ∥m⃗∥=5\lVert \vec m \rVert = 5, ∥j⃗∥=3\lVert \vec j \rVert = 3, unit vector (15,25,25,45)(\tfrac15, \tfrac25, \tfrac25, \tfrac45); cos⁡α=45\cos \alpha = \tfrac45, α≈36.87∘\alpha \approx 36.87^\circ; j⃗⋅k⃗=0\vec j \cdot \vec k = 0, yes they are orthogonal; projection (83,0,43,83)(\tfrac83, 0, \tfrac43, \tfrac83).

1+4+4+16=251 + 4 + 4 + 16 = 25. And to project onto a single direction you do not need Gram-Schmidt: a quotient is enough.

Exercise 2 (intermediate level): an odd dot product

Exercise 2. [3 points] In R2\mathbb{R}^2 define u⃗⋅v⃗=x1y1−x1y2−x2y1+3x2y2\vec u \cdot \vec v = x_1 y_1 – x_1 y_2 – x_2 y_1 + 3 x_2 y_2, with u⃗=(x1,x2)\vec u = (x_1, x_2) and v⃗=(y1,y2)\vec v = (y_1, y_2). a) (1 point) Write its Gram matrix GG in the standard basis and compute ∥(1,1)∥\lVert (1, 1) \rVert. b) (1 point) Compute the cosine of the angle between (1,0)(1, 0) and (0,1)(0, 1). c) (1 point) Compute the Gram matrix G′G' with respect to the basis B′={(1,1),(1,0)}B' = \{(1, 1), (1, 0)\} and deduce an orthonormal basis from it.

Expected result: G=(1−1−13)G = \begin{pmatrix} 1 & -1 \\ -1 & 3 \end{pmatrix}, ∥(1,1)∥=2\lVert (1, 1) \rVert = \sqrt2; cos⁡α=−13≈−0.5774\cos \alpha = -\tfrac{1}{\sqrt3} \approx -0.5774; G′=(2001)G' = \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix}, orthonormal basis {12(1,1),(1,0)}\{\tfrac{1}{\sqrt2}(1, 1), (1, 0)\}.

G′=CtGCG' = C^t G C with the vectors of B′B' as columns. If it comes out diagonal, you already know B′B' is orthogonal with this product.

Exercise 3 (challenge): Gram-Schmidt, projection and cross product

Exercise 3. [4 points] In R3\mathbb{R}^3 with the standard product, let W=L{(1,0,1),(1,1,0)}W = L\{(1, 0, 1), (1, 1, 0)\} and v⃗=(1,2,3)\vec v = (1, 2, 3). a) (1 point) Compute an orthonormal basis of WW by Gram-Schmidt. b) (1.5 points) Compute the orthogonal projection of v⃗\vec v onto WW and the distance from v⃗\vec v to WW. c) (1 point) Compute a vector perpendicular to WW with the cross product and check that it is parallel to v⃗−projWv⃗\vec v – \text{proj}_W \vec v. d) (0.5 points) Compute the volume of the parallelepiped formed by (1,0,1)(1, 0, 1), (1,1,0)(1, 1, 0) and v⃗\vec v.

Expected result: {12(1,0,1),16(1,2,−1)}\{\tfrac{1}{\sqrt2}(1, 0, 1), \tfrac{1}{\sqrt6}(1, 2, -1)\}; projection (73,23,53)(\tfrac73, \tfrac23, \tfrac53), distance 43≈2.3094\tfrac{4}{\sqrt3} \approx 2.3094; normal (−1,1,1)(-1, 1, 1); volume 4.

The volume is base area times height, and the height of v⃗\vec v over WW is exactly the distance from b). Use it to check d).

What’s wrong here?

Three solutions with one mistake each. Read, find the mistake and then the explanation.

Fragment 1: column times row

G = [2 1; 1 1]     u = (1, 2)     v = (3, 1)

u · v = (column of u) · G · (row of v)
      = [1; 2] · [2 1; 1 1] · [3 1]

First [1; 2] · [3 1] = [3 1; 6 2], and then times G:
[3 1; 6 2] · [2 1; 1 1] = [7 4; 14 8]

Predict: what is u⃗⋅v⃗\vec u \cdot \vec v?

A dot product is a number, and here a 2×22 \times 2 matrix came out. To get it, the order of the factors was also changed ([1;2]⋅G[1; 2] \cdot G cannot be multiplied: 2×12 \times 1 by 2×22 \times 2). The right way is row ⋅\cdot GG ⋅\cdot column: G(3,1)t=(6+1,3+1)=(7,4)G (3, 1)^t = (6 + 1, 3 + 1) = (7, 4), and (1,2)⋅(7,4)=7+8=15(1, 2) \cdot (7, 4) = 7 + 8 = 15.

The order of the matrix expressionOn the left, in red, the column times the row gives a 2 by 2 matrix and multiplying by G gives another matrix. On the right, in green, G times the column (3,1) gives (7,4) and the row (1,2) times that gives 15.column · G · row[1; 2] · [3 1] = [3 1; 6 2]· G = [7 4; 14 8]a matrix, not a numberrow · G · columnG · (3, 1)ᵗ = (7, 4)(1, 2) · (7, 4) = 151 × 2 · 2 × 2 · 2 × 1 = 1 × 1
If you are not left with a 1 × 1, the order is wrong.

Writing YGXtY G X^t or XGYtX G Y^t with XX, YY columns. The right form is XtGYX^t G Y: row, matrix, column. If you do not end up with a 1×11 \times 1, something is the wrong way round.

Fragment 2: the norm with two signs

u = (3, -4)

||u|| = ±sqrt(3^2 + (-4)^2) = ±5
Unit vector in the direction of u:  u / 5 = (3/5, -4/5)   (it is the only one)

Predict: what is wrong?

Two things, crossed over. The norm is +5+5, positive only: a length is not negative. And there are two unit vectors in that direction: ±(35,−45)\pm(\tfrac35, -\tfrac45), one for each sense. The ± goes on the unit vectors, not on the norm (and if you are asked for one “in the same sense as u⃗\vec u“, only the ++).

Ticking ±u⃗⋅u⃗\pm\sqrt{\vec u \cdot \vec u} as the definition of the norm. It is the trap of one question in Campus quiz 3.

Fragment 3: orthogonal with the wrong product

Dot product with Gram matrix G = [1 0 0; 0 2 0; 0 0 1]
u = (1, 1, 0)     v = (1, -1, 0)

u · v = 1·1 + 1·(-1) + 0·0 = 0    ->   u and v are orthogonal

Predict: are they orthogonal with that product?

No. The standard product was used. With GG, u⃗⋅v⃗=1⋅1⋅1+1⋅(−1)⋅2+0=1−2=−1≠0\vec u \cdot \vec v = 1 \cdot 1 \cdot 1 + 1 \cdot (-1) \cdot 2 + 0 = 1 – 2 = -1 \neq 0. Both norms are 1+2=3\sqrt{1 + 2} = \sqrt3, and cos⁡α=−13\cos \alpha = -\tfrac13: they make about 109.47∘109.47^\circ, not 90∘90^\circ.

Forgetting the Gram matrix when the statement gives a dot product. In the exam, the cosine “with respect to the bilinear form” is computed with its matrix; with the standard one, the part scores 0.

Solutions

Exercise 1

Before any arithmetic, the plan. The product is the standard one, so every measurement uses the same operation: multiply genre by genre and add up. And the parts are chained: the norms from a) come back in the cosine of b), and m⃗⋅j⃗=12 \vec m \cdot \vec j = 12 comes back in the projection of c). Work out each number once and write it down on the side.

And why does the question ask for the angle to compare tastes, and not the distance? The first thing you would think of is subtracting and measuring, but distance mixes two things: what you listen to and how much you listen. If j⃗ \vec j listened to twice as much of everything, 2j⃗=(4,0,2,4) 2 \vec j = (4, 0, 2, 4) , their tastes would be the same, and yet their distance to m⃗ \vec m would go from 10≈3.16 \sqrt{10} \approx 3.16 to 13≈3.61 \sqrt{13} \approx 3.61 . The cosine does not move: the 2 appears on top and at the bottom, cancels out, and it still gives 0.8 0.8 . The cosine compares the proportion of each genre, not the hours: that is what “having similar tastes” means.

a) ∥m⃗∥=1+4+4+16=25=5\lVert \vec m \rVert = \sqrt{1 + 4 + 4 + 16} = \sqrt{25} = 5 and ∥j⃗∥=4+0+1+4=3\lVert \vec j \rVert = \sqrt{4 + 0 + 1 + 4} = 3. The unit vector with the direction and sense of m⃗\vec m:

m⃗∥m⃗∥=(1,2,2,4)5=(15,25,25,45) \frac{\vec m}{\lVert \vec m \rVert} = \frac{(1, 2, 2, 4)}{5} = \left( \tfrac15, \tfrac25, \tfrac25, \tfrac45 \right)

(with norm 1+4+4+1625=1\sqrt{\tfrac{1 + 4 + 4 + 16}{25}} = 1).

b) m⃗⋅j⃗=2+0+2+8=12\vec m \cdot \vec j = 2 + 0 + 2 + 8 = 12, so

cos⁡α=125⋅3=45=0.8⟹α=arccos⁡0.8≈36.87∘ \cos \alpha = \frac{12}{5 \cdot 3} = \frac45 = 0.8 \quad \Longrightarrow \quad \alpha = \arccos 0.8 \approx 36.87^\circ

And j⃗⋅k⃗=0+0+0+0=0\vec j \cdot \vec k = 0 + 0 + 0 + 0 = 0: orthogonal. k⃗\vec k only listens to rock, and j⃗\vec j listens to no rock at all.

c)

projj⃗ m⃗=m⃗⋅j⃗j⃗⋅j⃗ j⃗=129(2,0,1,2)=(83,0,43,83) \text{proj}_{\vec j} \, \vec m = \frac{\vec m \cdot \vec j}{\vec j \cdot \vec j} \, \vec j = \frac{12}{9} (2, 0, 1, 2) = \left( \tfrac83, 0, \tfrac43, \tfrac83 \right)

Remainder: m⃗−proj=(1−83,  2,  2−43,  4−83)=(−53,2,23,43)\vec m – \text{proj} = (1 – \tfrac83, \; 2, \; 2 – \tfrac43, \; 4 – \tfrac83) = (-\tfrac53, 2, \tfrac23, \tfrac43). And (−53,2,23,43)⋅(2,0,1,2)=−103+0+23+83=0(-\tfrac53, 2, \tfrac23, \tfrac43) \cdot (2, 0, 1, 2) = -\tfrac{10}{3} + 0 + \tfrac23 + \tfrac83 = 0.

The projection in c), step by step, with the reason for each piece:

StepCalculationWhy
1m⃗⋅j⃗=12 \vec m \cdot \vec j = 12 How much of m⃗ \vec m points towards j⃗ \vec j ; you already had it from b)
2j⃗⋅j⃗=9 \vec j \cdot \vec j = 9 It is ∥j⃗∥2 \lVert \vec j \rVert^2 , not ∥j⃗∥ \lVert \vec j \rVert : since j⃗ \vec j is not a unit vector, you divide by its norm twice
3129=43 \frac{12}{9} = \frac43 How many times j⃗ \vec j fits in the shadow of m⃗ \vec m
443(2,0,1,2) \frac43 (2, 0, 1, 2) The projection is a multiple of j⃗ \vec j : it has to live in L{j⃗} L\{\vec j\}
5remainder times j⃗ \vec j gives 0If it does not give 0, something earlier is wrong

Dividing by ∥j⃗∥=3 \lVert \vec j \rVert = 3 instead of by j⃗⋅j⃗=9 \vec j \cdot \vec j = 9 . You get 4j⃗=(8,0,4,8) 4 \vec j = (8, 0, 4, 8) , and the remainder (−7,2,−2,−4) (-7, 2, -2, -4) gives −14+0−2−8=−24 -14 + 0 – 2 – 8 = -24 with j⃗ \vec j : it is not orthogonal. That is why the check in c) is worth marks: it warns you about the mistake.

Why it is done this way: in R4\mathbb{R}^4 there is no cross product and no drawing, but the formulas for norm, angle and projection are the same in any dimension. The check in c) is what convinces the marker.

How it is marked (indicative, mine): a) 0.25 each norm and 0.5 the unit vector; b) 0.5 the cosine with the angle and 0.5 the justified orthogonality; c) 0.75 the projection and 0.25 the check.

Exercise 2

a) In position (i,j)(i, j), the coefficient of xiyjx_i y_j:

G=(1−1−13) G = \begin{pmatrix} 1 & -1 \\ -1 & 3 \end{pmatrix}

∥(1,1)∥2=(1,1) G (1,1)t=(1,1)⋅(1−1,  −1+3)=(1,1)⋅(0,2)=2\lVert (1, 1) \rVert^2 = (1, 1) \, G \, (1, 1)^t = (1, 1) \cdot (1 – 1, \; -1 + 3) = (1, 1) \cdot (0, 2) = 2, so ∥(1,1)∥=2\lVert (1, 1) \rVert = \sqrt2.

One thing about a), which is where most marks are lost: the coefficient of x1y2 x_1 y_2 goes whole into entry (1,2) (1, 2) and the one of x2y1 x_2 y_1 , whole into entry (2,1) (2, 1) . You only divide by 2 when the expression merges the two cross terms into one, as in a quadratic form with −2x1x2 -2 x_1 x_2 ; here they come separately.

And before b), watch out for the trap. The obvious move is to look at the two vectors and say they are perpendicular, because with the standard product (1,0)⋅(0,1)=0 (1, 0) \cdot (0, 1) = 0 and they form 90∘ 90^\circ . But the question has changed the rule for measuring, and the angle depends on the dot product, not on the drawing. That is why all of b) is done with G G , and with the standard basis vectors you just read off its entries.

b) With the standard vectors everything is read from GG: (1,0)⋅(0,1)=g12=−1(1, 0) \cdot (0, 1) = g_{12} = -1, ∥(1,0)∥=g11=1\lVert (1, 0) \rVert = \sqrt{g_{11}} = 1, ∥(0,1)∥=g22=3\lVert (0, 1) \rVert = \sqrt{g_{22}} = \sqrt3:

cos⁡α=−11⋅3=−13≈−0.5774(α≈125.26∘) \cos \alpha = \frac{-1}{1 \cdot \sqrt3} = -\frac{1}{\sqrt3} \approx -0.5774 \quad (\alpha \approx 125.26^\circ)

c) With C=(1110)C = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix} (the vectors of B′B' as columns):

GC=(1−11−1+3−1)=(012−1),G′=Ct(GC)=(1110)(012−1)=(2001) G C = \begin{pmatrix} 1 – 1 & 1 \\ -1 + 3 & -1 \end{pmatrix} = \begin{pmatrix} 0 & 1 \\ 2 & -1 \end{pmatrix}, \qquad G' = C^t (G C) = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 0 & 1 \\ 2 & -1 \end{pmatrix} = \begin{pmatrix} 2 & 0 \\ 0 & 1 \end{pmatrix}

Diagonal: B′B' is orthogonal with this product, and on the diagonal are the squared norms, ∥(1,1)∥2=2\lVert (1, 1) \rVert^2 = 2 (as in a) and ∥(1,0)∥2=1\lVert (1, 0) \rVert^2 = 1. Dividing:

Bon={12(1,1),  (1,0)} B_{\text{on}} = \left\{ \tfrac{1}{\sqrt2} (1, 1), \; (1, 0) \right\}

Why it is done this way: the congruence G′=CtGCG' = C^t G C gives the three products of the basis at once (two norms and the cross one). And it is symmetric and positive definite (minors 1>01 > 0 and 3−1=2>03 – 1 = 2 > 0), so it is a genuine dot product: you will check it this way in topic 6.

If you do not trust the congruence, check it the long way: the three products of the basis with the formula in the question, x1y1−x1y2−x2y1+3x2y2 x_1 y_1 – x_1 y_2 – x_2 y_1 + 3 x_2 y_2 .

ProductWith the formulaValueWhere it goes in G′ G'
(1,1)⋅(1,1) (1, 1) \cdot (1, 1) 1−1−1+3 1 – 1 – 1 + 3 2g11′ g'_{11}
(1,0)⋅(1,0) (1, 0) \cdot (1, 0) 1−0−0+0 1 – 0 – 0 + 0 1g22′ g'_{22}
(1,1)⋅(1,0) (1, 1) \cdot (1, 0) 1−0−1+0 1 – 0 – 1 + 0 0g12′=g21′ g'_{12} = g'_{21}

Same result. So why the congruence? Because in R3 \mathbb{R}^3 there would be six products, six chances to get a sign wrong; CtGC C^t G C does them all with two matrix products. And the last step, dividing each vector by its norm, breaks nothing: if two vectors are orthogonal, their multiples are too, so 12(1,1) \tfrac{1}{\sqrt2} (1, 1) and (1,0) (1, 0) are still perpendicular and now have length 1.

How it is marked (indicative):

PartWhat is assessedPoints
a)GG with the cross terms not halved0.5
a)∥(1,1)∥\lVert (1, 1) \rVert with GG0.5
b)Cosine with GG1
c)G′=CtGCG' = C^t G C correctly computed0.5
c)Deducing it is orthogonal and giving the orthonormal basis0.5

Exercise 3

The plan: a) is not there for nothing. The projection in b) is the sum of the projections onto each vector of the basis of W W , but only if the basis is orthogonal.

What happens if you skip a) and project straight onto (1,0,1) (1, 0, 1) and (1,1,0) (1, 1, 0) , which is the obvious move? You get (2,0,2)+32(1,1,0)=(72,32,2) (2, 0, 2) + \tfrac32 (1, 1, 0) = (\tfrac72, \tfrac32, 2) , and the remainder (−52,12,1) (-\tfrac52, \tfrac12, 1) gives −32 -\tfrac32 with (1,0,1) (1, 0, 1) : it is not perpendicular to W W , so that is not the projection. Since (1,0,1)⋅(1,1,0)=1≠0 (1, 0, 1) \cdot (1, 1, 0) = 1 \neq 0 , the two vectors overlap and each shadow counts again a piece of the other one. Gram-Schmidt removes exactly that overlap:

StepCalculationWhy
1u⃗1=(1,0,1) \vec u_1 = (1, 0, 1) The first one stays as it is: there is nothing yet to be orthogonal to
2v⃗2⋅u⃗1u⃗1⋅u⃗1=12 \frac{\vec v_2 \cdot \vec u_1}{\vec u_1 \cdot \vec u_1} = \frac12 How much of v⃗2 \vec v_2 points in the direction of u⃗1 \vec u_1 : that is what you have to remove
3(1,1,0)−12(1,0,1)=(12,1,−12) (1, 1, 0) – \tfrac12 (1, 0, 1) = (\tfrac12, 1, -\tfrac12) What is left of v⃗2 \vec v_2 is already perpendicular to u⃗1 \vec u_1
4u⃗2=(1,2,−1) \vec u_2 = (1, 2, -1) Multiplying by 2 does not change the direction and gets rid of the halves; the quotient makes up for it
5Divide by 2 \sqrt2 and 6 \sqrt6 Only for the orthonormal basis in a); b) is done with the orthogonal one

a) Gram-Schmidt with v⃗1=(1,0,1)\vec v_1 = (1, 0, 1), v⃗2=(1,1,0)\vec v_2 = (1, 1, 0):

u⃗1=(1,0,1),u⃗2=(1,1,0)−12(1,0,1)=(12,1,−12)→(1,2,−1) \vec u_1 = (1, 0, 1), \qquad \vec u_2 = (1, 1, 0) – \frac{1}{2} (1, 0, 1) = \left( \tfrac12, 1, -\tfrac12 \right) \to (1, 2, -1)

(v⃗2⋅u⃗1=1\vec v_2 \cdot \vec u_1 = 1, u⃗1⋅u⃗1=2\vec u_1 \cdot \vec u_1 = 2; I multiply by 2 to remove the halves). Check: (1,0,1)⋅(1,2,−1)=0(1, 0, 1) \cdot (1, 2, -1) = 0. Normalising:

{12(1,0,1),  16(1,2,−1)} \left\{ \tfrac{1}{\sqrt2} (1, 0, 1), \; \tfrac{1}{\sqrt6} (1, 2, -1) \right\}

b) v⃗⋅u⃗1=1+3=4\vec v \cdot \vec u_1 = 1 + 3 = 4, v⃗⋅u⃗2=1+4−3=2\vec v \cdot \vec u_2 = 1 + 4 – 3 = 2:

projWv⃗=42(1,0,1)+26(1,2,−1)=(2,0,2)+(13,23,−13)=(73,23,53) \text{proj}_W \vec v = \frac42 (1, 0, 1) + \frac26 (1, 2, -1) = (2, 0, 2) + \left( \tfrac13, \tfrac23, -\tfrac13 \right) = \left( \tfrac73, \tfrac23, \tfrac53 \right)
v⃗−projWv⃗=(−43,43,43),d(v⃗,W)=433=43≈2.3094 \vec v – \text{proj}_W \vec v = \left( -\tfrac43, \tfrac43, \tfrac43 \right), \qquad d(\vec v, W) = \tfrac43 \sqrt3 = \tfrac{4}{\sqrt3} \approx 2.3094

c)

(1,0,1)×(1,1,0)=(0⋅0−1⋅1,  1⋅1−1⋅0,  1⋅1−0⋅1)=(−1,1,1) (1, 0, 1) \times (1, 1, 0) = (0 \cdot 0 – 1 \cdot 1, \; 1 \cdot 1 – 1 \cdot 0, \; 1 \cdot 1 – 0 \cdot 1) = (-1, 1, 1)

and v⃗−projWv⃗=43(−1,1,1)\vec v – \text{proj}_W \vec v = \tfrac43 (-1, 1, 1): parallel, as it should be, because both are perpendicular to the plane WW.

d)

∣101110123∣=1(3−0)−0+1(2−1)=4 \begin{vmatrix} 1 & 0 & 1 \\ 1 & 1 & 0 \\ 1 & 2 & 3 \end{vmatrix} = 1(3 – 0) – 0 + 1(2 – 1) = 4

Volume 4. Check with the hint: the base area is ∥(−1,1,1)∥=3\lVert (-1, 1, 1) \rVert = \sqrt3 and the height, 43\tfrac{4}{\sqrt3}: 3⋅43=4\sqrt3 \cdot \tfrac{4}{\sqrt3} = 4.

Exercise 3: normal, distance and volumeSketch of the plane W with its two vectors, the normal (−1, 1, 1) from the cross product, the vector v, its projection on W and the rest of length 4 over root 3. Beside, the base area root 3 times the height gives the volume 4, the same as the determinant.(1,0,1)(1,1,0)(−1, 1, 1)v = (1, 2, 3)projd = 4/√3base area = √3height = 4/√3volume = √3 · 4/√3 = 4det(…) = 4sketch, not to scale
The four tools of the topic check each other.

Why it is done this way: the exercise links the four tools of the topic, and each one checks another: the normal from the cross product matches the remainder of the projection, and the volume, base times height.

How it is marked (indicative):

PartWhat is assessedPoints
a)Orthogonalise and normalise1
b)Projection with the orthogonal basis1
b)Distance0.5
c)Cross product and parallelism1
d)Scalar triple product0.5

Check it in MATLAB

The three exercises in one session (the same code works in the website’s MATLAB playground):

format short
%% Exercise 1
m = [1 2 2 4]; j = [2 0 1 2]; k = [0 3 0 0];
c = dot(m, j) / (norm(m) * norm(j))
acos(c) * 180 / pi
dot(j, k)
format rat
p = dot(m, j) / dot(j, j) * j
%% Exercise 2
G = [1 -1; -1 3]; C = [1 1; 1 0];
C' * G * C                            % G' in the basis B'

Output:

c =

    0.8000

ans =

   36.8699

ans =

     0

p =

       8/3            0              4/3            8/3     

ans =

       2              0       
       0              1       

Now exercise 3:

%% Exercise 3
v = [1; 2; 3]; u1 = [1; 0; 1]; w2 = [1; 1; 0];
u2 = w2 - dot(w2, u1) / dot(u1, u1) * u1
p = dot(v, u1) / dot(u1, u1) * u1 + dot(v, u2) / dot(u2, u2) * u2
format short
norm(v - p)                           % the distance
cross([1 0 1], [1 1 0])
det([1 0 1; 1 1 0; 1 2 3])            % the volume

Output:

u2 =

       1/2     
       1       
      -1/2     

p =

       7/3     
       2/3     
       5/3     

ans =

    2.3094

ans =

    -1     1     1

ans =

     4

u2 comes out as (12,1,−12)(\tfrac12, 1, -\tfrac12), the paper one before multiplying by 2; the projection and the distance match. A detail of format rat: if you compute a root with it on, MATLAB approximates it with a fraction (2\sqrt2 comes out as 1393/985), so for norms and distances it is better to go back to format short.

Campus-style quiz

Twenty questions like those in Campus quiz 3 (the dot product part; the vector spaces and subspaces part is in the topic 3 quiz). It does not count for anything and you can repeat it as many times as you like. In questions with several correct answers, as in the exam, each wrong option you tick cancels a correct one.

Question 1Single choice

The norm of a vector u⃗\vec u in a Euclidean space is defined as:

  1. +u⃗⋅u⃗+\sqrt{\vec u \cdot \vec u}
  2. ±u⃗⋅u⃗\pm\sqrt{\vec u \cdot \vec u}
  3. u⃗⋅u⃗\vec u \cdot \vec u
  4. None of the above
Solution

Answer: +u⃗⋅u⃗+\sqrt{\vec u \cdot \vec u}

The norm is the positive root of the product of the vector with itself: ∥u⃗∥=+u⃗⋅u⃗\lVert \vec u \rVert = +\sqrt{\vec u \cdot \vec u}.

Question 2True or false

Say whether each statement is true or false:

  1. Two non-zero vectors are orthogonal if and only if their dot product is 1.
  2. Two non-zero vectors are orthogonal if and only if their dot product is 0.
  3. Whether two vectors are orthogonal depends on the dot product used.
Solution
  • F — Two non-zero vectors are orthogonal if and only if their dot product is 1.
  • T — Two non-zero vectors are orthogonal if and only if their dot product is 0.
  • T — Whether two vectors are orthogonal depends on the dot product used.

Orthogonal means product 0 (an angle of 90∘90^\circ). With another Gram matrix the same pair of vectors may stop being orthogonal: (1,0)(1, 0) and (0,1)(0, 1) have product g12g_{12}.

Question 3Short answer

With the standard dot product, what is the norm of (2,−6,3)(2, -6, 3)? Write just the number.

Solution

Answer: 7

4+36+9=49=7\sqrt{4 + 36 + 9} = \sqrt{49} = 7.

Question 4Single choice

With the standard product of R3\mathbb{R}^3, the cosine of the angle between (1,1,0)(1, 1, 0) and (1,0,0)(1, 0, 0) is:

  1. 12\frac{1}{\sqrt2}
  2. 11
  3. 12\frac12
  4. 00
Solution

Answer: 12\frac{1}{\sqrt2}

Product 11, norms 2\sqrt2 and 11: cos⁡α=12\cos \alpha = \frac{1}{\sqrt2}, that is, 45∘45^\circ.

Question 5Multiple · wrong ticks subtract

With u⃗=(2,−1)\vec u = (2, -1), v⃗=(1,3)\vec v = (1, 3) and the standard dot product, which of these expressions give u⃗⋅v⃗\vec u \cdot \vec v?

  1. (2−1)I2(13)\begin{pmatrix} 2 & -1 \end{pmatrix} I_2 \begin{pmatrix} 1 \\ 3 \end{pmatrix}
  2. (13)I2(2−1)\begin{pmatrix} 1 & 3 \end{pmatrix} I_2 \begin{pmatrix} 2 \\ -1 \end{pmatrix}
  3. (2−1)I2(13)\begin{pmatrix} 2 \\ -1 \end{pmatrix} I_2 \begin{pmatrix} 1 & 3 \end{pmatrix}
  4. (13)I2(2−1)\begin{pmatrix} 1 \\ 3 \end{pmatrix} I_2 \begin{pmatrix} 2 & -1 \end{pmatrix}
Solution

Answer: (2−1)I2(13)\begin{pmatrix} 2 & -1 \end{pmatrix} I_2 \begin{pmatrix} 1 \\ 3 \end{pmatrix} · (13)I2(2−1)\begin{pmatrix} 1 & 3 \end{pmatrix} I_2 \begin{pmatrix} 2 \\ -1 \end{pmatrix}

The matrix expression is row · GG · column, and by symmetry it does not matter which vector goes first. The column · GG · row ones are not a number (they cannot even be multiplied in that order).

Question 6Single choice

In R2\mathbb{R}^2, with u⃗⋅v⃗=3x1y1+2x1y2+2x2y1+5x2y2\vec u \cdot \vec v = 3 x_1 y_1 + 2 x_1 y_2 + 2 x_2 y_1 + 5 x_2 y_2, the Gram matrix in the standard basis is:

  1. (3225)\begin{pmatrix} 3 & 2 \\ 2 & 5 \end{pmatrix}
  2. (3115)\begin{pmatrix} 3 & 1 \\ 1 & 5 \end{pmatrix}
  3. (3445)\begin{pmatrix} 3 & 4 \\ 4 & 5 \end{pmatrix}
  4. (3005)\begin{pmatrix} 3 & 0 \\ 0 & 5 \end{pmatrix}
Solution

Answer: (3225)\begin{pmatrix} 3 & 2 \\ 2 & 5 \end{pmatrix}

Position (i,j)(i, j) holds the coefficient of xiyjx_i y_j: g12=2g_{12} = 2 (from x1y2x_1 y_2) and g21=2g_{21} = 2 (from x2y1x_2 y_1).

Question 7Short answer

With the Gram matrix G=(3225)G = \begin{pmatrix} 3 & 2 \\ 2 & 5 \end{pmatrix}, what is ∥(1,0)∥2\lVert (1, 0) \rVert^2? Write just the number.

Solution

Answer: 3

∥e⃗1∥2=e⃗1⋅e⃗1=g11=3\lVert \vec e_1 \rVert^2 = \vec e_1 \cdot \vec e_1 = g_{11} = 3, so ∥(1,0)∥=3\lVert (1, 0) \rVert = \sqrt3.

Question 8True or false

About the Gram matrix GG of a dot product with respect to a basis BB:

  1. GG is symmetric.
  2. If BB is orthogonal, GG is diagonal.
  3. If BB is orthonormal, GG is the identity.
  4. GG is the same in every basis.
Solution
  • T — GG is symmetric.
  • T — If BB is orthogonal, GG is diagonal.
  • T — If BB is orthonormal, GG is the identity.
  • F — GG is the same in every basis.

gij=e⃗i⋅e⃗j=e⃗j⋅e⃗i=gjig_{ij} = \vec e_i \cdot \vec e_j = \vec e_j \cdot \vec e_i = g_{ji}. In an orthogonal basis the cross products are 0, and in an orthonormal one, in addition, the norms are 1. When you change basis, GG changes to a congruent CtGCC^t G C.

Question 9Single choice

If GG and G′G' are the Gram matrices of a dot product in two bases and CC is the change-of-basis matrix from the second basis to the first, then:

  1. G′=CtGCG' = C^t G C
  2. G′=C−1GCG' = C^{-1} G C
  3. G′=CGCtG' = C G C^t
  4. G′=GG' = G
Solution

Answer: G′=CtGCG' = C^t G C

GG and G′G' are congruent: G′=CtGCG' = C^t G C, and they have the same rank.

Question 10Multiple · wrong ticks subtract

With the standard product of R3\mathbb{R}^3, which of these vectors are orthogonal to (1,2,−1)(1, 2, -1)?

  1. (1,0,1)(1, 0, 1)
  2. (2,−1,0)(2, -1, 0)
  3. (1,1,1)(1, 1, 1)
  4. (−1,−2,1)(-1, -2, 1)
Solution

Answer: (1,0,1)(1, 0, 1) · (2,−1,0)(2, -1, 0)

Check the product: 1+0−1=01 + 0 – 1 = 0 and 2−2+0=02 – 2 + 0 = 0. The opposite has product −6-6.

Question 11Single choice

A unit vector in the direction of (0,3,4)(0, 3, 4) is:

  1. (0,35,45)\left(0, \frac35, \frac45\right)
  2. (0,3,4)(0, 3, 4)
  3. (0,37,47)\left(0, \frac37, \frac47\right)
  4. (0,13,14)\left(0, \frac13, \frac14\right)
Solution

Answer: (0,35,45)\left(0, \frac35, \frac45\right)

You divide by the norm, 9+16=5\sqrt{9 + 16} = 5. The other unit vector in that direction is the opposite, (0,−35,−45)(0, -\frac35, -\frac45).

Question 12Match

Match each cosine with the position of the two vectors:

cos α = 1
cos α = 0
cos α = −1

Definitions:

  • Orthogonal
  • Same direction and sense
  • Same direction, opposite sense
  • Unit vectors
Solution
  • cos α = 1 → Same direction and sense
  • cos α = 0 → Orthogonal
  • cos α = −1 → Same direction, opposite sense

The cosine is 1 for 0∘0^\circ, 0 for 90∘90^\circ and −1-1 for 180∘180^\circ. Being unit vectors does not depend on the angle between them.

Question 13Single choice

The cross product (1,0,0)×(0,1,0)(1, 0, 0) \times (0, 1, 0) is:

  1. (0,0,1)(0, 0, 1)
  2. (0,0,−1)(0, 0, -1)
  3. 00
  4. (1,1,0)(1, 1, 0)
Solution

Answer: (0,0,1)(0, 0, 1)

e⃗1×e⃗2=e⃗3\vec e_1 \times \vec e_2 = \vec e_3, by the right-hand rule. In the opposite order, e⃗2×e⃗1=−e⃗3\vec e_2 \times \vec e_1 = -\vec e_3.

Question 14True or false

About the cross product in R3\mathbb{R}^3:

  1. u⃗×v⃗\vec u \times \vec v is perpendicular to u⃗\vec u and to v⃗\vec v.
  2. u⃗×v⃗=v⃗×u⃗\vec u \times \vec v = \vec v \times \vec u.
  3. If u⃗\vec u and v⃗\vec v are parallel and non-zero, u⃗×v⃗=0⃗\vec u \times \vec v = \vec 0.
  4. ∥u⃗×v⃗∥\lVert \vec u \times \vec v \rVert is the area of the parallelogram of u⃗\vec u and v⃗\vec v.
Solution
  • T — u⃗×v⃗\vec u \times \vec v is perpendicular to u⃗\vec u and to v⃗\vec v.
  • F — u⃗×v⃗=v⃗×u⃗\vec u \times \vec v = \vec v \times \vec u.
  • T — If u⃗\vec u and v⃗\vec v are parallel and non-zero, u⃗×v⃗=0⃗\vec u \times \vec v = \vec 0.
  • T — ∥u⃗×v⃗∥\lVert \vec u \times \vec v \rVert is the area of the parallelogram of u⃗\vec u and v⃗\vec v.

It is anticommutative: u⃗×v⃗=−v⃗×u⃗\vec u \times \vec v = -\vec v \times \vec u. Its norm is ∥u⃗∥∥v⃗∥sin⁡α\lVert \vec u \rVert \lVert \vec v \rVert \sin \alpha, which vanishes for α=0\alpha = 0 or 180∘180^\circ.

Question 15Single choice

Three vectors of R3\mathbb{R}^3 have scalar triple product 0. Then:

  1. They are coplanar (linearly dependent)
  2. They are pairwise orthogonal
  3. They form an orthonormal basis
  4. One of them is the zero vector
Solution

Answer: They are coplanar (linearly dependent)

The triple product is the determinant of the three vectors and its absolute value, the volume of the parallelepiped. Volume 0 means they lie in the same plane.

Question 16Fill in the gaps

Complete:

A real vector space with a ____ product is a ____ space. A basis whose vectors are pairwise orthogonal and have norm 1 is an ____ basis, and in it the Gram matrix is the ____.

Words:

  • identity
  • diagonal
  • dot
  • orthogonal
  • orthonormal
  • Euclidean
  • cross
Solution

A real vector space with a dot product is a Euclidean space. A basis whose vectors are pairwise orthogonal and have norm 1 is an orthonormal basis, and in it the Gram matrix is the identity.

Orthogonal only requires zero cross products (diagonal Gram); orthonormal, in addition, norms 1 (identity Gram).

Question 17Short answer

With the standard product, what is the dot product of (1,2,−3,0)(1, 2, -3, 0) and (0,3,2,1)(0, 3, 2, 1)? Write just the number.

Solution

Answer: 0

0+6−6+0=00 + 6 – 6 + 0 = 0: they are orthogonal in R4\mathbb{R}^4.

Question 18Order

Order the steps to compute the cosine of the angle between u⃗\vec u and v⃗\vec v with a dot product given by an expression:

  1. Write the Gram matrix GG from the coefficients
  2. Compute GG times each vector as a column
  3. Divide and round only at the end
  4. Compute u⃗⋅v⃗\vec u \cdot \vec v, ∥u⃗∥\lVert \vec u \rVert and ∥v⃗∥\lVert \vec v \rVert as row times those columns
Solution

Correct order:

  1. Write the Gram matrix GG from the coefficients
  2. Compute GG times each vector as a column
  3. Compute u⃗⋅v⃗\vec u \cdot \vec v, ∥u⃗∥\lVert \vec u \rVert and ∥v⃗∥\lVert \vec v \rVert as row times those columns
  4. Divide and round only at the end

Every measurement comes from GG. Leaving the roots unrounded until the last step avoids errors in the fourth decimal.

Question 19Single choice

Applying Gram-Schmidt to v⃗1=(1,1)\vec v_1 = (1, 1) and v⃗2=(1,0)\vec v_2 = (1, 0) with the standard product, the second orthogonal vector is:

  1. (12,−12)\left(\frac12, -\frac12\right)
  2. (1,0)(1, 0)
  3. (0,1)(0, 1)
  4. (12,12)\left(\frac12, \frac12\right)
Solution

Answer: (12,−12)\left(\frac12, -\frac12\right)

u⃗2=(1,0)−12(1,1)=(12,−12)\vec u_2 = (1, 0) – \frac{1}{2} (1, 1) = (\frac12, -\frac12), and (12,−12)⋅(1,1)=0(\frac12, -\frac12) \cdot (1, 1) = 0.

Question 20Multiple · wrong ticks subtract

Which of these matrices can be the Gram matrix of a dot product on R2\mathbb{R}^2?

  1. (2112)\begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}
  2. (1004)\begin{pmatrix} 1 & 0 \\ 0 & 4 \end{pmatrix}
  3. (1201)\begin{pmatrix} 1 & 2 \\ 0 & 1 \end{pmatrix}
  4. (100−1)\begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}
Solution

Answer: (2112)\begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix} · (1004)\begin{pmatrix} 1 & 0 \\ 0 & 4 \end{pmatrix}

It has to be symmetric (property 1) and positive definite (property 4): u⃗⋅u⃗>0\vec u \cdot \vec u > 0 for every u⃗≠0⃗\vec u \neq \vec 0. The first two satisfy it.

What next?

With topics 3 and 4 you have the whole of Campus quiz 3 and the subspaces exercise of the exam. The Euclidean space comes back in two places: in topic 6, bilinear and quadratic forms, where you will decide whether a form is a dot product and compute the cosine with it (the exam part), and in topic 8, the affine space, where the cross product gives planes and distances. Before that comes topic 5, linear transformations and diagonalisation. If you want to review bases and implicit equations, go back to the vector spaces exercises.

AG exam coming up?The test and practical packs with new solved questions and exercises, their cheat sheets, a blank test and practical exam and MATLAB functions, for free.See the pack

Cheat sheet: Euclidean space

The essentials in 30 seconds: product =XtGY= X^t G Y (row · GG · column), ∥u⃗∥=+u⃗⋅u⃗\lVert \vec u \rVert = +\sqrt{\vec u \cdot \vec u}, cos⁡α=u⃗⋅v⃗∥u⃗∥∥v⃗∥\cos \alpha = \frac{\vec u \cdot \vec v}{\lVert \vec u \rVert \lVert \vec v \rVert}, orthogonal if the product is 0. Orthogonal basis   ⟺  \iff GG diagonal; orthonormal   ⟺  \iff G=IG = I.

I want…By handMATLAB
Standard product∑xiyi\sum x_i y_idot(u, v)
Product with GGXtGYX^t G Yu * G * v’ (u, v rows)
Gram matrix in another basisG′=CtGCG' = C^t G CC’ * G * C
Norm+XtGX+\sqrt{X^t G X}norm(u) or sqrt(u * G * u’)
Unit vectors±u⃗/∥u⃗∥\pm \vec u / \lVert \vec u \rVertu / norm(u)
Anglearccos⁡\arccos of the quotientacos(c) * 180 / pi
Orthogonal basisGram-Schmidtloop with dot
Projection onto WW∑v⃗⋅u⃗ju⃗j⋅u⃗ju⃗j\sum \frac{\vec v \cdot \vec u_j}{\vec u_j \cdot \vec u_j} \vec u_j (orthogonal basis)the same sum
Perpendicular to two vectors of R3\mathbb{R}^3Cross productcross(u, v)
Volume / coplanarScalar triple product (determinant)det([u; v; w])

Template for the exam part:

  • Write GG (coefficient of xiyjx_i y_j in position (i,j)(i, j), not halved).
  • Check it is a dot product (topic 6: symmetric and positive leading principal minors).
  • GG times each vector as a column; products and norms.
  • Cosine with exact roots; decimals only at the end.
SymptomLikely cause
The product comes out as a matrixColumn · GG · row
A cosine greater than 1Norm miscalculated or with another GG
Two “orthogonal” vectors that are notYou used the standard product instead of GG
The fourth decimal does not matchYou rounded along the way
The remainder of the projection is not perpendicularYou projected with a non-orthogonal basis

Before handing in, ask yourself:

  • Which dot product am I given? Did I use its GG in every measurement?
  • Are my products row · GG · column?
  • Are my norms positive and my cosines between −1-1 and 11?
  • Did I check the orthogonality of what I said was orthogonal?
Keep goingAll Linear algebra articles

Did this article help you? Here is how you can support SergioLearns →

Ready for the exam?AG theory mock exam — the 20-question test with the Campus rules, no negative marking (and the catch in the several-correct ones)