Set up the columns 1, t and t squared for a parabola fit
Give the design matrix for y = C + D t + E t squared, one row per point and columns 1, t, t squared. The idea in plain words, a worked example, and a check with the answers shown — part of the free Linear Algebra guides.
A line has two coefficients, so its design matrix has two columns. A parabola has three —, and — so its design matrix has three.
The construction is exactly the same, one row per point:
Reading off the coefficients of each unknown, in the order:
The three columns are the three fixed functions of: the constant, the time, and the square. They are not the data points, and the rows are not the coefficients — the roles are worth saying out loud, because reversing them is the error that survives every shape check.
Why a curve is still a linear problem. The unknowns each appear to the first power. Squaring does not make the problem nonlinear, because is data, not an unknown — is a number you already have, exactly as is.
The row of must reproduce one equation. Row dotted with gives. For this to equal the model at time — which is — we need, and. Each entry is the coefficient of that unknown at that data point, and nothing else would do.
This is a general recipe, not a fact about parabolas. For the fourth column is. For the second column is. For a model with two separate predictors, the columns are those two measurements. The rule is always: column holds the values of the function multiplying unknown, evaluated at every data point.
Why the columns are independent when the times are distinct. Suppose is zero at every data point. A nonzero quadratic has at most two roots, so three distinct times force.
Fit to,,,. Set up only.
Step 1, one equation per point.
Step 2, read the coefficients.
| point | for | for | for | height | |---|---|---|---|---| | | | | | | | | | | | | | | | | | | | | | | | |
Step 3, stack.
Step 4, the normal equations, since a full setup usually asks for them too:
Check the pattern: top-left ✓; the entry is ✓; the entry is ✓; the entry is again, which is why it equals the entry — a real symmetry to spot rather than a coincidence. The right-hand side is. All four sums are verified in the SymPy check below.
Step 5, the check. This data does lie on an exact parabola: it is. So the fit is exact, the residual is zero, and must reproduce row by row:
That is worth keeping rather than tidying away: my first draft of this example had, and the substitution check is what caught it. and are not and; the true values are and. Multiplying a correct by the answer you expect and comparing with is a two-line check that finds exactly this class of error, and it is the check to run on an exam before you hand the sheet in.
- Give the design matrix for y = C + D t + E t squared, one row per point and columns 1, t, t squared
- Count the columns from the number of coefficients, not the number of data points
- Write A transpose A as a three by three matrix of power sums
- State how many distinct times a unique parabola fit requires and why
Points,,, model.
- 1. Write and.
- 2. What is?
- 3. Do these three points lie exactly on a parabola? How can you tell from alone?
Answers
- 1. and.
- 2.: the sums are over, so,, and.
- 3. Yes — is square ) with three distinct times, so it is invertible and has an exact solution. (It is.) A square design matrix means the "fit" is an interpolation: no error is being minimised because none is needed.