Bilinear and quadratic forms — guided practice with ramps that look like bowls, conjugates that are not perpendicular and a dot product with its cosine (and the diagonal that came out with fractions)
In the classroom worksheet on quadratic forms I diagonalised a 3 × 3 matrix by congruence and got a on the diagonal. I rubbed it out three times thinking I had made a mistake, because I was expecting whole numbers, as in the class examples. There was no mistake: the diagonal of a congruence depends on the operations you choose and, if a pivot is 2, dividing gives halves. What does not change is the sign of each number, and for classifying that is all that matters.
This practice is about doing by hand, carefully, what you saw in the theory of bilinear and quadratic forms, and checking every result in MATLAB. There are five problems with the skatepark example: the matrix of a bilinear form that is not symmetric and its change of basis, the polar form and the conjugate vectors of a ramp in , a diagonalisation by congruence with fractions, a form with a parameter that is classified with Sylvester and used as a dot product and, at the end, a problem in the format of an exam exercise. They are all medium level, with numbers chosen so that fractions appear at some step, because they do in the exam too.
Table of Contents
Before you start
Make sure you are clear on:
- The rule for the matrix of a bilinear form: the coefficient of in row , column , and .
- That the matrix of a quadratic form is symmetric and that the cross terms are divided by 2.
- The congruence algorithm: the same elementary operation on rows and columns, with the identity on the right following only the rows.
- Sylvester’s criterion and what it is for.
If any of these feels shaky, go back over the theory before carrying on.
To check in MATLAB, syms x y z and expand([x y z]*A*[x; y; z]) give you back the expression of from the matrix: if it does not match the statement, the matrix is wrong. And Ct*A*Ct' checks a congruence without doing anything by hand.
How to solve a forms problem on paper
The method is always the same, in four steps:
- Data: write the matrix and check it with one term (the coefficient of , or the cross term of split by 2). If it is a quadratic form, check that it is symmetric.
- Method: decide what you are asked. Just whether it is definite? Sylvester. Classify fully, or a basis? Congruence. A cosine? First, check it is positive definite.
- Solve showing every step: in the congruence, each row operation with its column operation written next to it. If the marker cannot see both, they will think you only did the row one.
- Check: of each basis vector must give its number in , and two vectors of the basis must be conjugate.
Problem 1: a bilinear form that is not symmetric
Statement. The program that designs the ramps uses the bilinear form on .
a) Write its associated matrix in the standard basis and say whether is symmetric. b) Compute and . c) Compute the quadratic form that defines and its polar form. d) Compute the matrix of in the basis both ways.
The idea
The matrix comes from the index rule. Since it will not be symmetric, the order of the vectors will matter in b). In c) something curious happens to the cross term, and in d) we use and check it with the definition .
Before computing , think about what happens to when both vectors are the same.
Step by step
a) Coefficient of in entry :
: it is not symmetric.
b) With the row · matrix · column product:
Different: with a non-symmetric form, order matters.
c) With :
The cross term disappears! The antisymmetric part, , always gives 0 when both vectors are equal. The polar form is the symmetric one whose matrix is read off : , that is,
It is the «average» of and : . That is why a quadratic form has infinitely many «associated» bilinear forms (here, and give the same ) but a single polar one.
d) Method 1, with (the vectors of in columns):
Method 2, entry by entry with and :
| Entry | Sum | Value |
|---|---|---|
| 5 | ||
| 3 | ||
| 1 | ||
| 2 |
They match. And is still not symmetric, like : congruence preserves whether a form is symmetric or not.
If the product in method 1 went too fast, here it is entry by entry. The idea in words: first joins the rule with the new vectors (each column of is times a vector of ); then puts the other new vector in front, as a row. Each entry of is a row of times a column of :
| Entry | Row of | Column of | Sum | Why |
|---|---|---|---|---|
| Row 1 of is and column 1 of is : it is | ||||
| in front, behind: | ||||
| Now goes in front: since is not symmetric, it need not give 3 | ||||
It is the method 2 table counted another way: that is why the two methods always match.
Check you’ve got it: what would happen if you used C⁻¹AC, as with transformations?
You would get a different matrix, and it would be wrong. Step by step: and . One entry is enough to see it fails: entry should be , and here it comes out as 4. In a transformation the input and the output are vectors and one is undone with ; in a bilinear form both vectors go in, and both are changed with .
Check it in MATLAB
A = [3 1; -1 2]; u = [1; 2]; v = [3; -1]; u'*A*v, v'*A*u % b) order matters syms x y w = expand([x y]*A*[x; y]) % c) the cross term disappears (A + A')/2 % matrix of the polar form C = [1 0; 1 1]; % B' in columns C'*A*C % d)
Output:
ans =
-2
ans =
12
w =
3*x^2 + 2*y^2
ans =
3 0
0 2
ans =
5 3
1 2
u'*A*v is exactly: the apostrophe transposes the first vector into a row. And (A + A')/2 is the symmetric part of , the matrix of the polar form.
Questions you might ask
Why does the cross term disappear in ? Because and with are and : they cancel. The whole antisymmetric part of a bilinear form is invisible to its quadratic form.
So is the matrix of equal to ? No: the matrix of is always symmetric, that of . Here, . is the matrix of , which is not the polar form.
Why is not needed in d)? Because in a bilinear form both coordinates change with and one of them comes out transposed. belongs to transformations.
What kind of ramp is ? A bowl: only squares with positive coefficients, positive definite. Steeper in the direction (coefficient 3).
Computing by moving only one vector across and getting again. If the matrix is not symmetric, the result changes; if you get the same, check that the first vector is in the row.
Try it yourself
- Write the matrix of , check that it is antisymmetric and that its quadratic form is zero.
- Compute the matrix of in the basis both ways.
Problem 2: the polar form and the conjugates of a ramp in ℝ³
Statement. The height of a new ramp is .
a) Write the matrix of and the expression of its polar form . b) Check the value of with the formula . c) Compute a basis of the subspace of vectors conjugate to . d) Compute a non-zero vector conjugate to both and .
The idea
Squares on the diagonal and each cross term, split by 2, in its two entries. The conjugates are implicit equations: the given vector as a row, the unknown as a column. With two given vectors, two equations.
is simply the first row of . For the vectors conjugate to , the equation is read straight off row .
Step by step
a) Diagonal: 1, 3 and . Cross terms: in and ; in and ; in and :
Each cross term of appears twice in with half the coefficient: gives back when .
b) With and , from the matrix: . From the formula: , , , and
The same. The formula is what tells you where the polar form comes from; the matrix is the quick way to use it.
c) Conjugates of : the first row of times :
A plane. With as parameters, :
d) Being conjugate to adds the equation from the third row, . Both together:
With : , . Vector: . Check with row 3: .
Check it in MATLAB
format rat A = [1 2 -1; 2 3 3; -1 3 -1]; syms x y z expand([x y z]*A*[x; y; z]) % gives back the w in the statement null([1 0 0]*A, 'r') % c) conjugates of (1,0,0) null([1 0 0; 0 0 1]*A, 'r') % d) conjugates of both
Output:
ans =
x^2 + 4*x*y - 2*x*z + 3*y^2 + 6*y*z - z^2
ans =
-2 1
1 0
0 1
ans =
1/5
2/5
1
null(u'*A, 'r') solves : the basis of the conjugate subspace comes out in paper format. With two vectors, you put them in rows and both equations come out at once. The appears scaled to because null sets the last free variable to 1.
Questions you might ask
Why is the subspace in c) a plane and the one in d) a line? Each given vector adds an equation (if it is not redundant). In , one equation leaves a plane and two leave a line.
Is conjugate to itself? Only if . Here it is 1, so no. Vectors conjugate to themselves () are called isotropic, and they only exist if the form is not definite.
What kind of ramp is this? Look at the diagonal: there is a in the corner. That alone tells you it is not positive definite (). To know whether it is indefinite or semidefinite, you would have to diagonalise; try it in «Try it yourself».
Is the polar form unique? Yes: it is the only symmetric bilinear form that gives . That is why the matrix of is unique too.
Looking for the conjugates with the usual dot product, . Those are the ordinary perpendicular vectors. With the form, the equation is the row of : .
Try it yourself
- Diagonalise by congruence and check that its signature is : indefinite.
- Compute the vectors conjugate to and say whether is among them.
Problem 3: diagonalising by congruence with fractions
Statement. Let .
a) Diagonalise by congruence and give a basis in which its matrix is diagonal. b) Compute its signature and its rank, and classify it. c) Check the classification with the leading principal minors.
The idea
The algorithm, pivot by pivot. First zeros in row and column 1 using ; then in row and column 2 with the new pivot, which will be a 2. That is where halves appear.
At each step, first the row operation across the whole strip and then the column operation only on the part. If it helps, write both on the same arrow, one above the other.
Step by step
a) The matrix, splitting the cross terms (, , ):
First pivot, the 1: and , with the same on columns:
Check one entry: was 2; with the row, , and with the column, was already 0, so it stays . Entry : and then .
The whole first step, without skipping anything. Notice the order: first the two row operations on the whole strip, and then the two column operations, only on the part.
| Step | Operation | Result | Why |
|---|---|---|---|
| 1 | The pivot is 1 and below it there is a : adding row 1 once cancels it | ||
| 2 | Below there is a 2: you have to subtract row 1 twice | ||
| 3 | (on ) | Column 2 goes from to | The row left zeros below the pivot, but the is still in row 1: the column removes it and the matrix is symmetric again |
| 4 | (on ) | Column 3 goes from to | The same with the 2 in entry |
| 5 | Nothing on the right | , , | Columns do not touch the identity: that is where is built |
After the rows, column 1 of is already : that is why the columns only change the first row.
Second pivot, the 2 in the center: to remove the 1 in , and :
Entry : . And on the right, row 3 is .
If you do not like fractions, you can use (twice as much) as the third vector: it is still conjugate to the other two, and the diagonal entry would become . The number changes, but not its sign.
b) Two positive and one negative: , . Indefinite: a saddle in three dimensions. For instance, and .
c) , , . They are neither all positive nor alternating from negative: it is not definite, and Sylvester says no more. But notice: , and are exactly the diagonal we got. It always happens when the congruence is done without swapping rows, and it is a great check.
Check it in MATLAB
format rat A = [1 -1 2; -1 3 -1; 2 -1 2]; Ct = [1 0 0; 1 1 0; -5/2 -1/2 1]; % rows = B' Ct*A*Ct' % paper D det(A(1,1)), det(A(1:2,1:2)), det(A)
Output:
ans =
1 0 0
0 2 0
0 0 -5/2
ans =
1
ans =
2
ans =
-5
The first output is the paper , with . The three minors are 1, 2 and , and their ratios, the same diagonal.
Questions you might ask
Why did I not do to avoid the half? You can (multiplying a row by a non-zero number is a valid operation in congruence), but then you must multiply the column too, and the diagonal number is multiplied by 4. The signature does not change. Choose whatever gives you fewer mistakes.
What if the pivot is 0? For example, , with matrix . Then, before anything else, and , which puts a 2 in the corner. Swapping rows and columns at the same time also works.
Are the numbers in the eigenvalues? No. The eigenvalues of this are not integers (MATLAB gives them with decimals). What matches is how many are positive and negative: two and one.
Why is made of the rows and not the columns on the right? Because on the right you are left with , and the basis vectors are the columns of , that is, the rows of .
Applying the column operation to the identity part too. Then the right side is no longer and the basis comes out wrong. The column operation only acts on : the identity follows only the rows.
Try it yourself
- Diagonalise the same starting with the bottom pivot (the 2 in ) and check that the signature is again .
- Diagonalise with the trick from the zero-pivot question and classify it.
Problem 4: a parameter, Sylvester and a dot product
Statement. For each , let .
a) Classify depending on the values of . b) For , justify that defines a dot product and compute, with respect to it, the cosine of the angle between and and the «length» of .
The idea
With a parameter, Sylvester is fastest for the «definite» part: the minors come out as expressions in . For the values where it fails, congruence. And in b), the cosine with the formula from the theory, .
does not mix with anything (there is no or ): the matrix has a block and a loose 2. The loose 2 always contributes a positive sign.
Step by step
a) . Leading principal minors:
- If : and all three are positive. Positive definite.
- If : . Sylvester does not decide. By congruence, , leaves : , signature , rank 2. Positive semidefinite (a half-pipe: with , ).
- If : with the same congruence, : , signature . Indefinite.
It is never negative definite: always.
The same classification, in a table. The idea: does not depend on , and is times the lone 2 of , so everything is decided by the sign of .
| Values of | Classification | Why | |||
|---|---|---|---|---|---|
| Positive definite | All three minors positive: Sylvester decides on its own | ||||
| 0 | 0 | Positive semidefinite | Sylvester does not decide; congruence gives : no negatives and one 0 | ||
| Indefinite | has positives and one negative |
And where does the half-pipe vector come from? With , . A sum of two squares is 0 only if both are: and . With , .
b) With , : positive definite. Since it is also symmetric, its polar form is a dot product. The cosine between and :
The length of : . With the usual dot product it would be .
Check it in MATLAB
format short syms a Aa = [1 a 0; a 4 0; 0 0 2]; det(Aa(1:2,1:2)), det(Aa) % minors with the parameter A1 = [1 1 0; 1 4 0; 0 0 2]; % a = 1 eig(A1) % all positive: positive definite e1 = [1;0;0]; e2 = [0;1;0]; u = [1;1;0]; c = (e1'*A1*e2)/sqrt((e1'*A1*e1)*(e2'*A1*e2)) sqrt(u'*A1*u) % length of (1,1,0): sqrt(7)
Output:
ans =
4 - a^2
ans =
8 - 2*a^2
ans =
0.6972
2.0000
4.3028
c =
0.5000
ans =
2.6458
The minors come out as and (MATLAB multiplies them out). The eigenvalues of are not pretty, but all three are positive: the same conclusion. And the cosine, 0.5000, which is ; the length, 2.6458, which is .
Questions you might ask
Why is it not enough to check that the diagonal of is positive? Because the cross terms can win. With , the diagonal is , all positive, and still .
What is the «length» with respect to a form? The square root of , just as the usual length is the square root of . It only makes sense if is positive definite (otherwise could be negative).
And if I am asked for the angle with ? It cannot be done: is not positive definite, so it is not a dot product. The right answer is to justify that and compute nothing.
Does the 60° angle depend on the basis? The angle between two given vectors does not: it is a property of the vectors and the dot product. What depends on the basis is the matrix you use to compute it.
Concluding «positive definite for every » because . Sylvester needs all minors positive, and changes sign at .
Try it yourself
- With , find a vector «perpendicular» (conjugate) to according to and check that the cosine comes out 0.
- Classify depending on using the result of a), without doing any sums.
Problem 5: this is how the exam asks it
Exam-style exercise. [9 points] On , let the bilinear form be , with and . a) (2 points) Find the expression of the quadratic form associated with . b) (4 points) Diagonalise and classify , and give a basis in which its matrix is diagonal. c) (3 points) Study whether is a dot product and, if so, compute the cosine of the angle between the vectors and .
The idea
It is the structure of the forms exercise in recent exams: expression, diagonalisation with a basis and classification, and the dot product question with a cosine. Everything comes from the matrix, which here is symmetric, so it is both that of and that of .
In c), the classification from b) already answers half: a dot product is a symmetric bilinear form with positive definite. If b) comes out positive definite, only the cosine is left.
Step by step
a) The matrix, by the index rule:
It is symmetric: is symmetric and its quadratic form has the same matrix. With , the two terms in each cross pair add up:
b) Congruence. First pivot, the 2: and , and the same on columns:
Second pivot, the : and :
, : positive definite. Check with Sylvester: , , . All positive.
The congruence in b), row by row. Here the pivot is 2, so the multipliers are halves: to cancel a number below the pivot , you subtract times the pivot row.
| Step | Operation | Result | Why |
|---|---|---|---|
| 1 | Below the 2 there is a : | ||
| 2 | Below there is a 1: you subtract of row 1 | ||
| 3 | , | Row 1 of goes from to | The same multipliers on columns: and |
| 4 | New pivot and another below it: the multiplier is 1 | ||
| 5 | Entry goes from to 0; entry stays at 1 | The column only clears what the row left above |
Check with the rule from problem 3: , and . It is the diagonal of , because you have not swapped rows.
c) is symmetric and is positive definite: is a dot product. Cosine between and :
Check it in MATLAB
format rat A = [2 -1 1; -1 1 0; 1 0 2]; syms x y z expand([x y z]*A*[x; y; z]) % a) Ct = [1 0 0; 1/2 1 0; -1 -1 1]; % rows = B' Ct*A*Ct' % b) D det(A(1,1)), det(A(1:2,1:2)), det(A) % Sylvester e1 = [1;0;0]; e2 = [0;1;0]; (e1'*A*e2)/sqrt((e1'*A*e1)*(e2'*A*e2)) % c) cosine
Output:
ans =
2*x^2 - 2*x*y + 2*x*z + y^2 + 2*z^2
ans =
2 0 0
0 1/2 0
0 0 1
ans =
2
ans =
1
ans =
1
ans =
-985/1393
The cosine comes out as , the fraction format rat uses to approximate .
Checking and how it is marked
Two ten-second checks: , the last number of ; and and are conjugate: .
A rough split of the 9 points (it is mine, not the lecturer’s official one):
| Part | What is assessed | Points |
|---|---|---|
| a) | Matrix of laid out correctly | 1 |
| a) | Expression of with the cross terms added | 1 |
| b) | Congruence operations on rows and columns, written out | 2 |
| b) | and the basis (rows of ) | 1 |
| b) | Signature and justified classification | 1 |
| c) | Dot product: symmetric and positive definite | 1.5 |
| c) | Cosine and angle | 1.5 |
Questions you might ask
Can I classify with Sylvester alone in b)? For classifying, yes (it comes out positive definite). But b) also asks you to diagonalise and give the basis, and that only comes from congruence (or from eigenvalues, with ugly numbers). Doing both also gives you a free check.
Can I give with instead of ? Yes: it is twice as much, still conjugate to the other two. But then changes in that entry (). Give the that matches your basis.
Why is the angle obtuse? Because . With this way of measuring, and «face each other» at more than 90°.
If b) came out indefinite, what do I write in c)? That is not a dot product because its quadratic form is not positive definite, and so the cosine makes no sense. That earns the marks for c).
Check you’ve got it: what would happen if the terms x1y3 and x3y1 in f had a 2 instead of a 1?
would no longer be a dot product, and in c) there would be no cosine to compute. Step by step: the matrix would be , still symmetric. Its minors: , and . The last one is negative and the other two positive, so it is not positive definite. Congruence confirms it: , and then (with the same on columns) give : signature , indefinite. A vector that proves it is the last row on the right, : . That is why c) is always answered by looking at b).
Adding the cross terms wrongly in a): gives , not . In the matrix each entry holds half, but in the whole term appears.
Try it yourself
- Redo b) starting with the center pivot (swapping rows and columns 1 and 2 first) and check that you get another with all three positive.
- Compute the cosine of the angle between and with respect to .
Common mistakes in this practice
- The whole cross term in the matrix. In the matrix of , the coefficient of is split between and ; in the expression of , it appears whole.
- Congruence on rows only. Every row operation is followed by the same one on columns, and the column one does not touch the identity.
- The basis in the columns on the right. The right side is : the basis is its rows.
- Sylvester as if it classified everything. It only decides «definite». With a zero minor or signs that follow no pattern, diagonalise.
- A cosine without checking it is a dot product. First symmetric and positive definite; then the formula.
- instead of . Bilinear forms change with the transpose.
Try it in the MATLAB playground
In the MATLAB playground you can run this script, which checks a congruence, classifies by eigenvalues and finds a vector with negative height on an indefinite ramp.
format rat A = [1 -1 2; -1 3 -1; 2 -1 2]; % the ramp from problem 3 Ct = [1 0 0; 1 1 0; -5 -1 2]; % B' without fractions D = Ct*A*Ct' % the diagonal changes, the signs do not format short eig(A) % eigenvalues: two positive and one negative v = Ct(3,:)'; % the third vector of B' v'*A*v % negative height: indefinite
Things to look at:
- With instead of , the diagonal gives instead of : same sign.
- The eigenvalues look nothing like the diagonal of , but they have the same signs.
- Change to the one from problem 5 and check that all the eigenvalues come out positive.
- Try
v = [1; 0; 0]and look at the sign ofv'*A*v: an indefinite ramp rises in some directions and falls in others.
Summary
- The matrix of a bilinear form has the coefficient of in ; and, if it is not symmetric, order matters.
- The matrix of a quadratic form is symmetric: squares on the diagonal and cross terms split by 2. The antisymmetric part of a bilinear form does not show in its quadratic form.
- The conjugates of a vector are read off its row of : , one equation per vector.
- In congruence, the same operation on rows and columns; on the left and on the right, with the basis in its rows. The diagonal can have fractions; the signs do not change.
- Sylvester decides «definite» with the leading principal minors; for semidefinite and indefinite, diagonalise.
- A dot product is a symmetric bilinear form with positive definite, and with it .
Checklist: have you practised it?
- Can you write the matrix of a form (bilinear or quadratic) without forgetting to split the cross terms?
- Do you know how to compute the conjugates of one and of two vectors?
- Have you done a full congruence with its basis and checked it with of each vector?
- Do you know when Sylvester does not decide and what to do then?
- Have you run the five MATLAB scripts and checked that the outputs match your paper?
- Have you tried the «Try it yourself» tasks without looking at the theory?
If you answered yes to almost everything, you are ready for the bilinear and quadratic forms exercises, where I no longer give you the steps and there is a quiz like the Campus ones. See you there!
Next step: exercisesBilinear and quadratic forms — exam-style exercises with a deceptive ramp, a parameter Sylvester cannot settle and a dot product that is not one (and the basis read off the columns)Did this article help you? Here is how you can support SergioLearns →



