NivaarExam PrepOfficial exam papers ↗

04-BS-5 · December 2018

Question 4 of 7: Least-Squares Parabola Proof and Lagrange Interpolation

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)

Notes on this paper

National Examinations, December 2018 — 04-BS-5 Advanced Mathematics, 3 hours, closed book (approved Casio/Sharp calculator and one double-sided aid sheet permitted). Any five of the seven questions constitute a complete paper and all questions are of equal value; all seven are answered below as a full study resource.

Reference texts: Kreyszig, Advanced Engineering Mathematics, 10th ed. (Wiley) — Ch. 11 (Sturm–Liouville Problems, Fourier Series, Fourier Integrals and Transforms), Ch. 19 (Numerics in General: interpolation, numerical differentiation, Romberg integration, iterative equation solving), Ch. 20 (Numeric Linear Algebra: Cholesky factorization). Supporting: Chapra & Canale, Numerical Methods for Engineers, 7th ed. — Ch. 5–6 (bracketing and open root-finding methods), Ch. 17 (least-squares regression), Ch. 18 (interpolation), Ch. 22 (Romberg integration).

Question 4: Least-Squares Parabola Proof and Lagrange Interpolation (a: 10 marks; b: 10 marks)

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

Given. (A) $n$ data points $(X_i,Y_i)$ fitted by the no-intercept model $Y=\alpha X+\beta X^2$. (B) Four points $(-3,0),(-2,4),(0,-6),(2,0)$.

Find. (A) Derive $\alpha,\beta$ from the least-squares normal equations. (B) The cubic through the four given points.

Approach. (A) Minimize the sum of squared residuals $S=\sum(Y_i-\alpha X_i-\beta X_i^2)^2$, set $\partial S/\partial\alpha=\partial S/\partial\beta=0$, and solve the resulting $2\times2$ linear system by Cramer's rule. (B) Build the degree-3 Lagrange basis directly from the four nodes.

  1. (A) Form the normal equations. With $S=\sum_{i=1}^n(Y_i-\alpha X_i-\beta X_i^2)^2$, $$\frac{\partial S}{\partial\alpha}=-2\sum X_i(Y_i-\alpha X_i-\beta X_i^2)=0\ \Rightarrow\ \sum X_iY_i=\alpha\sum X_i^2+\beta\sum X_i^3$$ $$\frac{\partial S}{\partial\beta}=-2\sum X_i^2(Y_i-\alpha X_i-\beta X_i^2)=0\ \Rightarrow\ \sum X_i^2Y_i=\alpha\sum X_i^3+\beta\sum X_i^4$$ Write $S_1=\sum X_iY_i$, $S_2=\sum X_i^2Y_i$, $A=\sum X_i^2$, $B=\sum X_i^3$, $C=\sum X_i^4$, so the system is $S_1=\alpha A+\beta B$, $S_2=\alpha B+\beta C$.
  2. Solve by Cramer's rule. With determinant $D=AC-B^2$, $$\boxed{\alpha=\dfrac{S_1C-S_2B}{D}=\dfrac{\big(\sum X_iY_i\big)\big(\sum X_i^4\big)-\big(\sum X_i^2Y_i\big)\big(\sum X_i^3\big)}{\big(\sum X_i^2\big)\big(\sum X_i^4\big)-\big(\sum X_i^3\big)^2}}$$ This matches the printed formula for $\alpha$ exactly, confirming the method.
  3. Solve for $\beta$ and compare with the printed formula. $$\boxed{\beta=\dfrac{AS_2-BS_1}{D}=\dfrac{\big(\sum X_i^2\big)\big(\sum X_i^2Y_i\big)-\big(\sum X_i^3\big)\big(\sum X_iY_i\big)}{\big(\sum X_i^2\big)\big(\sum X_i^4\big)-\big(\sum X_i^3\big)^2}}$$ The printed source formula instead reads $\beta=\big[(\sum X_i^2)(\sum X_i^2Y_i)-(\sum X_i)(\sum X_i^3Y_i)\big]/D$, mixing in $\sum X_i$ and $\sum X_i^3Y_i$ terms that never appear in the two normal equations above; on the same sample data it gives a numerically different (wrong) value. See the check callout below.
  4. (B) Build the Lagrange cubic. With nodes $X_0,\dots,X_3=-3,-2,0,2$ and values $Y_0,\dots,Y_3=0,4,-6,0$, $$P(X)=\sum_{k=0}^{3}Y_k\prod_{\substack{j=0\\j\ne k}}^{3}\frac{X-X_j}{X_k-X_j}$$ Only the two nonzero-value nodes contribute: $$P(X)=4\cdot\frac{(X+3)(X-0)(X-2)}{(-2+3)(-2-0)(-2-2)}+(-6)\cdot\frac{(X+3)(X+2)(X-2)}{(0+3)(0+2)(0-2)}$$
  5. Expand and simplify. The first term is $4\cdot\dfrac{X(X+3)(X-2)}{8}=\dfrac{X(X+3)(X-2)}{2}$; the second is $-6\cdot\dfrac{(X+3)(X^2-4)}{-12}=\dfrac{(X+3)(X^2-4)}{2}$. Adding and expanding both numerators over the common denominator $2$: $$\boxed{P(X)=X^{3}+2X^{2}-5X-6}$$ Check at all four nodes: $P(-3)=-27+18+15-6=0$✓, $P(-2)=-8+8+10-6=4$✓, $P(0)=-6$✓, $P(2)=8+8-10-6=0$✓.
Check The source's printed $\beta$ formula, $\beta=\big[(\sum X_i^2)(\sum X_i^2Y_i)-(\sum X_i)(\sum X_i^3Y_i)\big]/D$, does not follow from the two normal equations derived in Step 1 (it introduces $\sum X_i$ and $\sum X_i^3Y_i$, neither of which the $2\times2$ system contains) and was confirmed wrong against a direct least-squares solve. The correct result, boxed in Step 3, is $\beta=\big[(\sum X_i^2)(\sum X_i^2Y_i)-(\sum X_i^3)(\sum X_iY_i)\big]/D$.
QuantityResult
$\alpha$ (least squares)$(S_1C-S_2B)/D$ — matches source
$\beta$ (least squares, corrected)$(AS_2-BS_1)/D$ — source formula in error, see the check note
Lagrange cubic $P(X)$$X^3+2X^2-5X-6$