How to correctly format (and align) a LaTeX proof?
\documentclass{article}
\usepackage{amsmath,amsthm,amssymb}
\begin{document}
\begin{proof}
Let $t,u \in \mathbb{R}$ where $t=xy$ and $u=zw$. So,
\begin{align*}
4xyzw &= 2\cdot2tu \\
&\le 2\cdot(t^2+u^2) \\
&= 2\cdot((xy)^2+(zw)^2) &&\text{(substituting variables)} \\
&= 2\cdot(x^2y^2+z^2w^2) \\
&= 2x^2y^2+2z^2w^2 \\
&\le ((x^2)^2+(y^2)^2)+((z^2)^2)+(w^2)^2) \\
&= x^4+y^4+z^4+w^4 &&\qedhere
\end{align*}
\end{proof}
\end{document}
The alignment is better (eqnarray
should never be used for serious mathematical writing) and, moreover, the "end-of-proof" can be placed aligned with the last equation; \qedhere
is necessary only when the proof ends with an alignment environment or with a list (enumerate
, itemize
or description
); the &&
before \qedhere
is only necessary when there are other comments.
I didn't check the math, though. ;-)
Adding to egreg
's remarks: to add right-aligned annotation — in parentheses — you can use the \tag
macro; to have annotation without parentheses, use the \tag*
macro. (This must be given before the line-break; for this reason, I like to put the line break immediately before the following line, but that's just my personal style.) And again, as egreg
noted, you should use \qedhere
on the last line of an equation environment, if your proof ends at an equation.
\begin{align*}
4xyzw
&= 2\cdot2tu
\\ &\le 2\cdot(t^2+u^2) \tag{a remark in parentheses}
\\ &= 2\cdot((xy)^2+(zw)^2)
\\ &= 2\cdot(x^2y^2+z^2w^2) \tag*{a remark without parentheses}
\\ &= 2x^2y^2+2z^2w^2
\\ &\le ((x^2)^2+(y^2)^2)+((z^2)^2)+(w^2)^2)
\\ &= x^4+y^4+z^4+w^4 \qedhere
\end{align*}
If you find yourself having multi-line equations where you want equation numbers — but only on the last line — the macro \notag
will also come in handy. (I insert them just before the line-breaks, to make it easy to copy the sequence \notag \\ &=
for multi-line equations.)
\begin{align}
4xyzw
&= 2\cdot2tu
\notag\\ &\le 2\cdot(t^2+u^2) \tag{a remark in parentheses}
\\ &= 2\cdot((xy)^2+(zw)^2)
\notag\\ &= 2\cdot(x^2y^2+z^2w^2) \tag*{a remark without parentheses}
\\ &= 2x^2y^2+2z^2w^2
\notag \\ &\le ((x^2)^2+(y^2)^2)+((z^2)^2)+(w^2)^2)
\notag \\ &= x^4+y^4+z^4+w^4
\end{align}
Edited to add: don't use \tag
or \tag*
for remarks, unless you're happy with them appearing on the left (instead of on the right) whilst using the lefteqn
option.
One may also use the alignat
environment. See the following:
\documentclass[letterpaper]{article}
\usepackage{amsmath,amssymb}
\newcommand{\justif}[2]{&{#1}&\text{#2}}
\begin{document}
\begin{alignat*}{2}
4xyzw &= 2\cdot2tu \justif{\quad}{remark}\\
&\le 2\cdot(t^2+u^2) \justif{\quad}{remark}\\
&= 2\cdot((xy)^2+(zw)^2) \justif{\quad}{remark}\\
&= 2\cdot(x^2y^2+z^2w^2) \justif{\quad}{remark}\\
&= 2x^2y^2+2z^2w^2 \\ % no remark
&\le ((x^2)^2+(y^2)^2)+((z^2)^2)+(w^2)^2) \justif{\quad}{remark}\\
&= x^4+y^4+z^4+w^4
\end{alignat*}
\end{document}
Note the introduction of a \justif{<horizontal space>}{<content>}
command that takes as arguments the separation and content (remark).