# alignment problem

I have the following:

\documentclass{article}
\usepackage{nicefrac}
\usepackage{amsmath,amssymb}
\begin{document}

\begin{align*}
f_X(x)&=\frac{1}{2 \pi} \exp ( -x^2/2 )   &\forall x \in \mathbb{R} \\
g(x)&=(x^2-1)/2   &\forall x \in \mathbb{R} \\
\intertext{ so}
g'(x) &= x\\
g^{-1}(y)&= \pm \sqrt{2y+1}\\
\intertext{ Then}
f_Y(y) &= \frac{f_X(g^{-1}(y))}{g'(g^{-1}(y))}\\
&=  \frac{1}{|\pm \sqrt{2y+1}|}   \frac{1}{\sqrt{2 \pi}} \exp \left( -y-\nicefrac{1}{2} \right)\\
\intertext{where the support for $f_Y$ is $y \in [(0-1)/2, \infty) = [-\nicefrac{1}{2} , \infty)$}
&= \frac{2}{\sqrt{2y+1}\sqrt{2 \pi}}  \exp \left( -y-\nicefrac{1}{2} \right)  &\forall y \in  [-\nicefrac{1}{2} , \infty)
\end{align*}

\end{document}


The problem is that I would like all the \forall to be aligned, but only the top 2 are, and the one on the bottom line is positioned to the left of the 2 at the top. I was under the impression that using & would cause the relevant items immediately following to be aligned, which is working fine for the = but not the \foralls.

-
The rule for the align environments is: rlrlrl…. You need an additional & in front of \forall. – Qrrbrbirlbel Oct 13 '12 at 21:31
Are you sure you want to use \nicefrac? The result doesn't seem good at all. – egreg Oct 13 '12 at 21:32
@egreg thanks for your comment (much appreciated as I am a beginner in LaTeX). Do you think this is better $\left[-\frac{1}{2} , \infty \right)$ ? – Robert Long Oct 13 '12 at 21:52
@egreg Actually, it was the \nicefrac after the exp that seemed better to me. This didn't look good to me:  \exp \left( -y-\frac{1}{2} \right) – Robert Long Oct 13 '12 at 22:01
@longrob Definitely $[-1/2,\infty)$ or, less preferably, $[-\frac{1}{2},\infty)$. I'd perhaps use \frac{1}{2} in the arguments to \exp. Your usages of \left and \right are not needed and should be avoided here and in these situations. – egreg Oct 13 '12 at 22:01

You just need an additional & before the \foralls.

The reason for this is given in Qrrbrbirlbel's comment to the question, the alignment of an align are rlrlrl..., a right-aligned column followed by a left-aligned column, right, left etc. Hence, with just one &, the \foralls end up in a right-aligned column, while you want them left-aligned.

See also section 3.6 Equation groups with mutual alignment in the amsmath manual.

\documentclass{article}
\usepackage{nicefrac,amsmath,amssymb}
\begin{document}

\begin{align*}
f_X(x)&=\frac{1}{2 \pi} \exp ( -x^2/2 )  & &\forall x \in \mathbb{R} \\
g(x)&=(x^2-1)/2   & &\forall x \in \mathbb{R} \\
\intertext{ so}
g'(x) &= x\\
g^{-1}(y)&= \pm \sqrt{2y+1}\\
\intertext{ Then}
f_Y(y) &= \frac{f_X(g^{-1}(y))}{g'(g^{-1}(y))}\\
&=  \frac{1}{|\pm \sqrt{2y+1}|}   \frac{1}{\sqrt{2 \pi}} \exp \left( -y-\nicefrac{1}{2} \right)\\
\intertext{where the support for $f_Y$ is $y \in [(0-1)/2, \infty) = [-\nicefrac{1}{2} , \infty)$}
&= \frac{2}{\sqrt{2y+1}\sqrt{2 \pi}}  \exp \left( -y-\nicefrac{1}{2} \right) & &\forall y \in  [-\nicefrac{1}{2} , \infty)
\end{align*}

\end{document}


-
Brilliant ! +1 thanks so much for the explanation. – Robert Long Oct 13 '12 at 21:54