Tricki
a repository of mathematical know-how
Add article
Navigate
Tags
Search
Forums
Help
Top level
›
What kind of problem am I trying to solve?
›
Equation-solving front page
›
Transform equation to reach a solved pattern
View
Edit
Revisions
Complete the square
Title:
*
Area of mathematics:
*
A comma-separated list of areas of mathematics to which this article applies. Use ">" to tag in a subcategory. Example: Analysis > Harmonic analysis, Combinatorics
Keywords:
A comma-separated list of keywords associated with this article. Example: free group
Used in:
A comma-separated list of examples of where this technique is used. Example: Cauchy-Schwarz inequality
Parent articles:
Order
-1
0
1
-1
0
1
Body:
[QUICK DESCRIPTION] When faced with a expression involving both purely quadratic terms (e.g. $ax^2$) and linear terms (e.g. $bx$) in one or more variables $x$, translate the variable $x$ in order to absorb the linear terms into the quadratic ones. This can create additional constant terms, but all other things being equal, constant terms are preferable to deal with than linear terms. [PREREQUISITES] High school algebra [EXAMPLE|The quadratic formula] This is the classic example of the completing the square trick. Suppose one wants to find all solutions to the quadratic equation [math] ax^2 + bx + c = 0[/math] where $a,b,c$ are parameters. The linear term prevents one from solving this equation directly; however, observe that $a(x+x_0)^2 = ax^2 + 2ax x_0 + ax_0^2$ for any shift $x_0$. Thus, (assuming $a \neq 0$) if one picks $x_0 := b/2a$, one can absorb the linear factor into the quadratic one, obtaining an equation [math] a(x+\frac{b}{2a})^2 - a (\frac{b}{2a})^2 + c = 0[/math] which only involves quadratic and constant terms. Now, the rules of high school algebra can solve this equation. Dividing by $a$ and rearranging, one gets [math] (x + \frac{b}{2a})^2 = \frac{b^2-4ac}{4a^2}; [/math] taking square roots, we arrive at the famous formula [math] x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}[/math] for the two solutions to the quadratic equation, bearing in mind that the square root may well be imaginary if $b^2-4ac$ is negative. (For the $a=0$, the above formula does not make sense, but in that case the equation degenerates to the linear equation $bx+c=0$, which has one solution $x=-\frac{c}{b}$, unless $b$ managed to degenerate to zero also, in which case there are no solutions when $c \neq 0$ and an infinite number of solutions when $c=0$.) See "[[how to solve quadratic equations]]" for more discussion. [EXAMPLE] A ''quadratic form'' is an expression like $x^2+2y^2-z^2+3xy-3xz$. That particular example is a quadratic form on $\R^3$, and in general a quadratic form over $\R^n$ is a function $q$ obtained by taking a [[w:symmetric bilinear form]] $\beta$ on $\R^n$ and defining $q(\mathbf{x})$ to be $\beta(\mathbf{x},\mathbf{x})$. In the example above, the bilinear form is $\beta((x,y,z),(x',y',z'))=xx'+2yy'-zz'+\frac 32(xy'+x'y-xz'-x'z)$. It is often convenient to ''diagonalize'' a quadratic form, which means writing it as a linear combination of squares of linearly independent linear forms. Let us do this for the example above, by completing the square. Our aim will be to achieve this by removing from $x^2+2y^2-z^2+3xy-3xz$ the square of a linear form in such a way that $x$ is no longer involved. To do this, we first pick out the terms that involve $x$, which are $x^2+3xy-3xz$. We then try to find a linear form $ax+by+cz$ such that when you square it the terms involving $x$ are precisely these ones. With a bit of experience in completing the square, we know that $x+\frac 32 y-\frac 32 z$ will do the job. Indeed, [maths](x+\frac 32 y-\frac 32 z)^2=x^2+3xy-3xz+\frac 94y^2-\frac 92yz+\frac 94z^2.[/maths] Therefore, [maths]x^2+2y^2-z^2+3xy-3xz=(x+\frac 32 y-\frac 32 z)^2-\frac 14y^2+\frac 92yz-\frac{13}4z^2.[/maths] We would now like to finish this process by diagonalizing $-\frac 14y^2+\frac 92yz-\frac{13}4z^2$, which we can make look slightly nicer by writing it as $-\frac 14(y^2-18yz+13z^2)$. Completing the square again, we find that [maths]y^2-18yz+13z^2=(y-9z)^2-81z^2+13z^2=(y-9z)^2-68z^2.[/maths] Plugging this in, we deduce that [maths]x^2+2y^2-z^2+3xy-3xz=(x+\frac 32 y-\frac 32 z)^2-\frac 14(y-9z)^2+17z^2,[/maths] and the quadratic form has been diagonalized. [EXAMPLE] Completing the square can be used to compute the Fourier transform of gaussians. In one dimension, this was done in "[[Use rescaling or translation to normalize parameters]]"; we do the multi-dimensional case here. Specifically, let us compute the Fourier transform [math ftg] \int_{\R^d} e^{-\pi x \cdot M x} e^{-2\pi i x \cdot \xi}\ dx[/math] of the Gaussian $e^{-\pi x \cdot M x}$, where $M$ is a positive definite real symmetric $d \times d$ matrix, and $\xi \in \R^d$. Observe that [math] (x+x_0) \cdot M (x+x_0) = x \cdot Mx + 2 x \cdot M x_0 + x_0 \cdot M x_0[/math] for all $x, x_0 \in \C^d$. Thus, if we pick $x_0 = i M^{-1} \xi$, we can complete the square and rewrite [eqref ftg] as [math] \int_{\R^d} e^{-\pi (x + i M^{-1} \xi) \cdot M (x + i M^{-1} \xi)} e^{\pi (i M^{-1} \xi) \cdot M (i M^{-1} \xi)}\ dx.[/math] The constant term $e^{\pi (i M^{-1} \xi) \cdot M (i M^{-1} \xi)}$, being independent of $x$, can be pulled out of the integral and simplified, leaving us with [math] e^{-\pi \xi \cdot M^{-1} \xi} \int_{\R^d} e^{-\pi (x + i M^{-1} \xi) \cdot M (x + i M^{-1} \xi)}\ dx;[/math] [[shift the contour of integration|contour shifting]] in each of the $d$ variables of integration separately then allows us to rewrite this as<comment thread="383" /> [math] e^{-\pi \xi \cdot M^{-1} \xi} \int_{\R^d} e^{-\pi x \cdot M x}\ dx.[/math] Making the change of variables $y := M^{1/2} x$ to [[Use rescaling or translation to normalize parameters|normalize the integrand]], we can simplify this as [math] e^{-\pi \xi \cdot M^{-1} \xi} \frac{1}{(\det M)^{1/2}} \int_{\R^d} e^{-\pi |y|^2}\ dy,[/math] which by [[the tensor power trick|factoring the integral]] and using the standard integral $\int_\R e^{-\pi x^2}\ dx = 1$ (proven at [[square and rearrange]]) simplifies to [math] \frac{1}{(\det M)^{1/2}} e^{-\pi \xi \cdot M^{-1} \xi}.[/math] [remark] Of course, one could also go about this computation by diagonalizing $M$ first to place it in a normal form; it is instructive to see how both computations end up at the same answer at the end of the day.[/remark] [EXAMPLE] The standard proof of the [[how to use the Cauchy-Schwarz inequality|Cauchy-Schwarz inequality]] $\langle x, y \rangle \leq \|x\| \|y\|$ in a Hilbert space (which we take here to be real, for simplicity) can be viewed as a variant of the completing-the-square trick, but now one converts linear term into quadratic and constant terms rather than vice versa. Indeed, since [math] \| x - ay \|^2 = \|x\|^2 - 2 a \langle x, y \rangle + a^2 \|y\|^2 [/math] for any $a \in \R$, we can write [math] \langle x, y \rangle = \frac{1}{2a} \|x\|^2 + \frac{a}{2} \|y\|^2 - \frac{1}{a} \|x-ay\|^2 [/math] for any $a > 0$; in particular, [math] \langle x, y \rangle \leq \frac{1}{2a} \|x\|^2 + \frac{a}{2} \|y\|^2.[/math] If we then [[Keep parameters unspecified until it is clear how to optimize them|optimize]] in $a$, we obtain the Cauchy-Schwarz inequality. [EXAMPLE] Suggestions welcome! [GENERAL DISCUSSION] Completing the square can also be done in several variables, whenever one is adding a quadratic form $Q(x) = B(x,x)$ to a linear form $L(x)$ plus some constant terms, provided that the quadratic form is non-degenerate (this is analogous to the $a \neq 0$ condition in the quadratic formula). The method also works to some extent for higher degree polynomials, but is significantly weaker. For instance, with cubic equations $ax^3+bx^2+cx+d=0$, one can complete the cube to eliminate the quadratic factor $bx^2$ (at the expense of modifying the lower order terms $cx+d$), but the linear term remains, and further tricks are needed to solve this equation. See "[[How to solve cubic and quartic equations]]".
This is a stub
A stub is an article that is not sufficiently complete to be interesting.
Notifications
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
Images are larger than
640x480
will be resized. The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png svg
.
Revision information
Log message:
An explanation of the additions or updates being made to help other authors understand your motivations.
Search this site:
Recent articles
View a list of all articles.
Littlewood-Paley heuristic for derivative
Geometric view of Hölder's inequality
Diagonal arguments
Finding an interval for rational numbers with a high denominator
Try to prove a stronger result
Use self-similarity to get a limit from an inferior or superior limit.
Prove a consequence first
Active forum topics
Plenty of LaTeX errors
Tutorial
A different kind of article?
Countable but impredicative
Tricki Papers
more
Recent comments
I don't think this statement
choice of the field
Incorrect Image
Article classification
Higher dimensional analogues
more