TL;DR
A bilinear form is a rule that takes two vectors and returns a single number. It is linear in each vector separately, so doubling either input doubles the output, and adding to either input adds to the output. Every bilinear form on ordinary coordinates is a matrix sandwiched between the two vectors, which makes it easy to compute and to study.
Builds on: linear maps, Matrix Multiplication, Matrix Transpose · Leads to: quadratic forms, positive definite matrices, and the dot product as a special case
Where it's used
Measuring angles and lengths in physics. The dot product is a bilinear form, and it gives lengths and angles in ordinary space. In general relativity the metric plays the same role in four-dimensional spacetime, and it is a bilinear form that can take negative values. That sign change is why distances in spacetime behave differently from distances on a map.
Covariance in statistics. The covariance of two random variables is linear in each of them: scaling one scales the covariance, and adding a variable adds to it. A covariance matrix therefore encodes a bilinear form on the space of linear combinations of variables.
Scoring pairs in machine learning. A recommender can score a user and an item by a bilinear form , where is the user's vector, the item's vector, and a learned matrix. Some tensor-based knowledge-graph models score facts the same way. Attention in transformers also compares a query and a key through a bilinear product.
How it works
Take two vectors in the plane, and , and a matrix
The bilinear form is . Compute it one step at a time.
-
Apply the matrix to . . Check: the first entry is , and the second is .
-
Take the dot product with . . Check: the two steps used one matrix and two vectors, and the result is one number.
-
Test linearity in the first slot. Replace with . Then is , which is . Check: doubling the first input doubled the output.
-
Test linearity in the second slot. Replace with for , so . Then and . Also and . Check: the output for the sum equals the sum of the outputs.
The flow of the computation is:
flowchart LR y["Vector y"] --> A["Multiply by matrix A"] A --> d["Dot product with x"] x["Vector x"] --> d d --> out["One number B(x, y)"]
The math
Definition
Let be a vector space over the real numbers. A bilinear form on is a function such that for all vectors and all real numbers ,
In words: fix one input and the output is a linear function of the other.
Note that is not in general . The form is linear in each slot separately, not in both at once.
Defining the matrix
In coordinates, write and with the standard basis vectors. Linearity in each slot lets you expand:
Define . Then . In the walkthrough, is the entry in row 1, column 2, and it multiplies .
Step 1 in symbols: the matrix applied to y
The product is the matrix times vector with entries . This is the first part of the expansion above, with the sum over taken first.
Step 2 in symbols: the dot product
The final step is . This is a dot product of with the vector . Doubling doubles every term, and the same holds for through , which is why the form is linear in both slots.
The special cases
If is the identity matrix, , the ordinary dot product. If is symmetric, then for all and . Setting gives the quadratic form .
Worked examples
Use the matrix , and .
- The four terms are: ; ; ; .
- Add them: .
- Compare with the walkthrough: , which matches.
Answer: . The sum over all index pairs gives the same number as the matrix-vector route.
Use , which is symmetric, and .
- Compute .
- Compute the dot product .
- This is , the quadratic form at .
- Check by expanding: with , gives .
Answer: . Both routes agree, and the symmetric matrix gives the same value for and .
A recommender represents a user by and an item by . It scores the pair with , where the learned matrix is .
- Apply to : .
- Take the dot product with : .
- The score is . A larger score means the model expects the user to like the item more.
- Check the linearity: if the user vector doubles to , the score doubles to .
Answer: the score is , and doubling the user's vector doubles it.
Try it: Use the same and , but a new item . What is ? Answer: , and . The score is .
Common mistakes and tradeoffs
It is tempting to think a bilinear form is linear in both inputs at once, so . In fact it is linear in each slot separately, and the expansion of the sum produces four terms, and two of them are cross terms, and .
It is tempting to think every bilinear form must be symmetric, so that . In fact symmetry is an extra property. The matrix from the walkthrough is not symmetric, and gives a different number.
It is tempting to think the matrix is a fixed property of the form. In fact it depends on the basis. If you change basis with an invertible matrix , the matrix becomes . The form itself does not change, only its coordinates do.
Use a bilinear form when you want to compare two vectors in a way that is linear in each, such as covariance, a dot product in a changed geometry, or a learned score for a pair. Do not use it when you only need to transform one vector, where a linear map is the right tool. Alternatives include a plain dot product, when the geometry is standard, and a quadratic form, when you only ever compare a vector with itself.
History
Bilinear and quadratic forms grew out of 19th-century work on systems of equations and matrices. In the 1850s James Joseph Sylvester proved that a quadratic form has a fixed number of positive and negative terms however it is simplified, a result now called Sylvester's law of inertia. Bilinear forms were later generalised to inner products, which gave geometry on abstract spaces, and in the 20th century they became central to quantum mechanics and to the metric of general relativity.
Recap
- A bilinear form takes two vectors and returns one number, linear in each vector when the other is fixed.
- In coordinates it is for a unique matrix , and the matrix depends on the basis.
- The dot product is the case , and a symmetric gives a quadratic form when the two vectors are equal.
- The same structure appears in covariance, metrics in physics and learned scoring functions in machine learning.
- Read next: quadratic forms and positive definite matrices, which use the symmetric case.
Check yourself
QuestionWhat does it mean for a form to be bilinear?Show answer
It is linear in the first input when the second is held fixed, and linear in the second input when the first is held fixed. It is not required to be linear in both inputs at the same time.
QuestionLet , and . What is ?Show answer
, and .
QuestionWhy does the dot product count as a bilinear form, and what matrix does it correspond to?Show answer
For fixed , the map is linear, and the same holds in . Writing gives the identity matrix as its matrix.
QuestionA recommender uses with , and . What is the score, and what does doubling do to it?Show answer
, and . Doubling doubles the score to , because the form is linear in its second input.