# Amsmath equation align last line to the right

I'm trying to obtain something similar to:

with the following code, using amsmath package:

$$\begin{split} Q_\nu(a,b) &= \frac{1}{2}\mathrm{erfc}\left ( \frac{b+a}{\sqrt2} \right )+\frac{1}{2}\mathrm{erfc}\left ( \frac{b-a}{\sqrt2} \right ) \\ & \quad +\frac{1}{a\sqrt{2\pi}}\sum_{k=0}^{\nu-1.5}\frac{b^{2k}}{2^k}\sum_{q=0}^{k}\frac{(-1)^q(2q)!}{(k-q)!q!} \\ & \quad \times \sum_{i=0}^{2q}\frac{1}{(ab)^{2q-i}i!}\left [ (-1)^ie^{-\frac{(b-a)^2}{2}} -e^{-\frac{(b+a)^2}{2}}\right ], \\ a> 0,\; \; \; \; \; \;b\geq 0 \end{split}$$


but I am getting the following:

Is there any code that would permit to right align the last line?

• Wouldn't it be more useful for the reader if where $a>0 and$b\geq 0. was added as text after the equation. Aug 19, 2015 at 13:49 ## 3 Answers yet another answer, taking advantage of some additional possibilities from mathools: \documentclass[12pt]{article} \usepackage{mathtools} \begin{document} \begin{alignedat}{2} Q_\nu(a,b) &= \frac{1}{2}\mathrm{erfc}\left ( \frac{b+a}{\sqrt2} \right )+\frac{1}{2}\mathrm{erfc}\left ( \frac{b-a}{\sqrt2} \right ) \\ & \quad +\frac{1}{a\sqrt{2\pi}}\sum_{k=0}^{\nu-1.5}\frac{b^{2k}}{2^k}\sum_{q=0}^{k}\frac{(-1)^q(2q)!}{(k-q)!q!} \\ & \quad \times \sum_{i=0}^{2q}\frac{1}{(ab)^{2q-i}i!}\left [ (-1)^ie^{-\frac{(b-a)^2}{2}} -e^{-\frac{(b+a)^2}{2}}\right ], \\ && \mathllap{ a> 0, \quad b\geq 0 } \end{alignedat} \end{document}  (nonetheless, the suggestion by @daleif, to add wherea>0 and $b\geq 0$, makes the best sense.)

The following is close to what is being sought.

\documentclass[12pt]{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
Q_{\nu}(a,b) &= \frac{1}{2} \, \mathrm{erfc}\left( \frac{b+a}{\sqrt2} \right) + \frac{1}{2} \, \mathrm{erfc}\left(
\frac{b-a}{\sqrt2} \right) \nonumber \\
& \quad + \frac{1}{a\sqrt{2\pi}} \, \sum_{k=0}^{\nu-\frac{3}{2}} \frac{b^{2k}}{2^k} \, \sum_{q=0}^{k}\frac{(-1)^q(2q)!}
{(k-q)!q!} \nonumber \\
& \quad \times \sum_{i=0}^{2q} \frac{1}{(ab)^{2q-i}i!} \, \left[ (-1)^ie^{-\frac{(b-a)^2}{2}} -e^{-\frac{(b+a)^2}{2}}
\right ], \nonumber \\
& \hspace{45mm} a > 0, \quad b \geq 0
\end{align}

\end{document}


A different solution:

\documentclass[12pt]{article}
\usepackage{amsmath}

\begin{document}

\begin{multline}
Q_{\nu}(a,b) = \frac{1}{2} \, \mathrm{erfc}\left( \frac{b+a}{\sqrt2} \right) + \frac{1}{2} \, \mathrm{erfc}\left(
\frac{b-a}{\sqrt2} \right)\\
\quad + \frac{1}{a\sqrt{2\pi}} \, \sum_{k=0}^{\nu-\frac{3}{2}} \frac{b^{2k}}{2^k} \, \sum_{q=0}^{k}\frac{(-1)^q(2q)!}
{(k-q)!q!}  \\
\quad \times \sum_{i=0}^{2q} \frac{1}{(ab)^{2q-i}i!} \, \left[ (-1)^ie^{-\frac{(b-a)^2}{2}} -e^{-\frac{(b+a)^2}{2}}
\right ], \\
a > 0, \quad b \geq 0
\end{multline}

\end{document}