LINEAR-ALGEBRA

The Hidden Equivalence: Completing the Square = Gaussian Elimination

IKey Formulas

Formula Name Description
xTAx=ax12+2bx1x2+cx22x^{T}Ax = ax_1^2 + 2bx_1x_2 + cx_2^2 Quadratic form (2ร—2) A=(abbc)A = \begin{pmatrix} a & b \\ b & c \end{pmatrix} symmetric
ax12+2bx1x2+cx22=a(x1+bax2)2+(cโˆ’b2a)x22ax_1^2 + 2bx_1x_2 + cx_2^2 = a\left(x_1 + \tfrac{b}{a}x_2\right)^2 + \left(c - \tfrac{b^2}{a}\right)x_2^2 Completing the square Sum-of-squares decomposition
pivots: d1=a,ย ย d2=cโˆ’b2ad_1 = a,\ \ d_2 = c - \tfrac{b^2}{a} Gaussian elimination Outer coefficients in sum-of-squares
multiplier: โ„“21=ba\ell_{21} = \tfrac{b}{a} Elimination step Inner shift inside the square
Aโ‰ป0โ€…โ€ŠโŸบโ€…โ€ŠA \succ 0 \iff all pivots >0> 0 Positivity test Definiteness from row reduction

IIVisualization 1 โ€” Pivots Decide the Shape

The signs of the pivots d1,d2d_1, d_2 turn the level set of xTAxx^{T}Ax into an ellipse, parallel lines, or a hyperbola.

An ellipse is the level set of a bowl; two crossing lines belong to a saddle; parallel lines mark the degenerate trough.

IIIVisualization 2 โ€” Completing the Square = Elimination

Each step of completing the square on A=(266c)A = \begin{pmatrix} 2 & 6 \\ 6 & c \end{pmatrix} is exactly one step of Gaussian elimination.

Step 1 โ€” The quadratic form
xTAx=2x12+12x1x2+cโ€‰x22x^{T}Ax = 2x_1^2 + 12x_1x_2 + c\,x_2^2
A=(266c)A = \begin{pmatrix} 2 & 6 \\ 6 & c \end{pmatrix}
Step 2 โ€” Gaussian elimination
First pivot d1=a=2d_1 = a = 2; multiplier โ„“21=ba=62=3\ell_{21} = \tfrac{b}{a} = \tfrac{6}{2} = 3.
R2โ†R2โˆ’3R1R_2 \leftarrow R_2 - 3R_1
Step 3 โ€” Complete the square
2(x12+6x1x2)+cโ€‰x222\big(x_1^2 + 6x_1x_2\big) + c\,x_2^2
=2(x1+3x2)2โˆ’18x22+cโ€‰x22= 2\big(x_1 + 3x_2\big)^2 - 18x_2^2 + c\,x_2^2
The inner shift +3x2+3x_2 is the multiplier โ„“21\ell_{21}.
Step 4 โ€” The pivot test
xTAx=2(x1+3x2)2+(cโˆ’18)โ€‰x22x^{T}Ax = 2\big(x_1 + 3x_2\big)^2 + (c - 18)\,x_2^2
Pivots d1=2d_1 = 2, d2=cโˆ’18d_2 = c - 18: so Aโ‰ป0โ€…โ€ŠโŸบโ€…โ€Šc>18A \succ 0 \iff c > 18. At c=18c = 18 a trough, below it a saddle.

The multipliers become the inner shifts of the squares; the pivots become their outer coefficients.

IVPractice Questions

Test your understanding with the questions below.

Question 1

Consider the symmetric matrix A=(36614).A = \begin{pmatrix} 3 & 6 \\ 6 & 14 \end{pmatrix}. Apply Gaussian elimination. What are the two pivots?

โœ… Correct! Both pivots are positive, so AA is positive definite.

โŒ Not quite. You wrote down the diagonal entries of AA, not the pivots. The second pivot changes after elimination.

โŒ Not quite. Check the elimination step: d2=cโˆ’b2/ad_2 = c - b^2/a, not cโˆ’bc - b.

โŒ Sign error. d2=14โˆ’12=+2d_2 = 14 - 12 = +2, not โˆ’2-2.

โŒ Not quite. Try again โ€” the hints above can help.

Show solution

Solution:

The first pivot is the (1,1) entry: d1=3d_1 = 3.

The multiplier is โ„“21=6/3=2\ell_{21} = 6/3 = 2. Subtracting 22 times row 1 from row 2 gives a new (2,2) entry:

d2=14โˆ’2โ‹…6=14โˆ’12=2.d_2 = 14 - 2 \cdot 6 = 14 - 12 = 2.

Equivalently, d2=cโˆ’b2/a=14โˆ’36/3=14โˆ’12=2.d_2 = c - b^2/a = 14 - 36/3 = 14 - 12 = 2.

Pivots: 3 and 2. Both positive โ€” so AA is positive definite.

Question 2

True or False: If every entry of a symmetric matrix AA is positive, then AA is positive definite.

โœ… Correct! Positive entries do not guarantee positive definiteness โ€” only positive pivots do.

โŒ Not quite. This is a common trap. The matrix (2667)\begin{pmatrix} 2 & 6 \\ 6 & 7 \end{pmatrix} has all positive entries but is indefinite.

โŒ Not quite. Try again โ€” the hints above can help.

Show solution

Solution:

False. Positivity of entries is not the test โ€” the test is positivity of the pivots.

Counter-example from the video: A=(2667)A = \begin{pmatrix} 2 & 6 \\ 6 & 7 \end{pmatrix} has all positive entries, but

d2=7โˆ’622=7โˆ’18=โˆ’11<0.d_2 = 7 - \frac{6^2}{2} = 7 - 18 = -11 < 0.

So AA is indefinite. Indeed, plugging in x=(โˆ’3,1)x = (-3, 1):

xTAx=2(9)+12(โˆ’3)(1)+7(1)=18โˆ’36+7=โˆ’11.x^{T}Ax = 2(9) + 12(-3)(1) + 7(1) = 18 - 36 + 7 = -11.

The correct test: AA is positive definite if and only if all pivots are positive.

Question 3

Completing the square on xTAxx^{T}Ax for A=(26620)A = \begin{pmatrix} 2 & 6 \\ 6 & 20 \end{pmatrix} gives the decomposition

xTAx=2(x1+3x2)2+2x22.x^{T}Ax = 2(x_1 + 3x_2)^2 + 2 x_2^2.

Where does the inner coefficient 3 come from in the language of Gaussian elimination?

โœ… Correct! Pivots become the outer coefficients of the squares; multipliers become the inner shifts.

โŒ Not quite. The first pivot is d1=2d_1 = 2 (the outer coefficient of the first square), not 3.

โŒ Not quite. The second pivot is d2=2d_2 = 2 (the outer coefficient of the second square).

โŒ Not quite. detโกA=2โ‹…20โˆ’36=4\det A = 2 \cdot 20 - 36 = 4, not 3.

โŒ Not quite. Try again โ€” the hints above can help.

Show solution

Solution:

The decomposition is

xTAx=d1โ€‰(x1+โ„“21x2)2+d2โ€‰x22.x^{T}Ax = d_1\,(x_1 + \ell_{21} x_2)^2 + d_2\,x_2^2.

For A=(26620)A = \begin{pmatrix} 2 & 6 \\ 6 & 20 \end{pmatrix}:

  • First pivot d1=2d_1 = 2 (outer coefficient of the first square)
  • Multiplier โ„“21=b/a=6/2=3\ell_{21} = b/a = 6/2 = 3 (the inner shift inside the first square)
  • Second pivot d2=20โˆ’62/2=2d_2 = 20 - 6^2/2 = 2 (outer coefficient of the second square)

So 3 is the elimination multiplier โ„“21\ell_{21} โ€” the number you multiply row 1 by before subtracting it from row 2 to zero out the (2,1) entry.

The video's punchline: pivots โ†’ outer coefficients, multipliers โ†’ inner shifts.

Question 4

Consider A=(1224)A = \begin{pmatrix} 1 & 2 \\ 2 & 4 \end{pmatrix}. Classify its quadratic form xTAxx^{T}Ax.

โœ… Correct! One pivot is zero, so the form is a single square (x1+2x2)2(x_1+2x_2)^2 โ€” non-negative, but zero along the line x1=โˆ’2x2x_1 = -2x_2.

โŒ Not quite. The second pivot is d2=4โˆ’4=0d_2 = 4 - 4 = 0, not positive. Try x=(โˆ’2,1)x = (-2, 1): xTAx=0x^{T}Ax = 0, so the form is not strictly positive.

โŒ Not quite. The decomposition is (x1+2x2)2(x_1 + 2x_2)^2, a perfect square โ€” it is never negative.

โŒ Not quite. With all entries positive and x=(1,0)x = (1,0) giving xTAx=1>0x^{T}Ax = 1 > 0, the form cannot be negative definite.

โŒ Not quite. Try again โ€” the hints above can help.

Show solution

Solution:

Run elimination on A=(1224)A = \begin{pmatrix} 1 & 2 \\ 2 & 4 \end{pmatrix}:

  • First pivot: d1=1d_1 = 1
  • Multiplier: โ„“21=2/1=2\ell_{21} = 2/1 = 2
  • Second pivot: d2=4โˆ’2โ‹…2=0d_2 = 4 - 2 \cdot 2 = 0

Sum-of-squares decomposition:

xTAx=1โ‹…(x1+2x2)2+0โ‹…x22=(x1+2x2)2.x^{T}Ax = 1\cdot(x_1 + 2x_2)^2 + 0 \cdot x_2^2 = (x_1 + 2x_2)^2.

This is never negative (it's a square), but it equals zero along the line x1=โˆ’2x2x_1 = -2x_2 (a whole line of nonzero vectors). So the form is positive semi-definite.

The signature is the missing (zero) pivot โ€” not a negative one.

Solved: 0 / 4