O que estou fazendo de errado neste uso de divisão?

O que estou fazendo de errado neste uso de divisão?

Estou fazendo algo errado no código abaixo que faz com que a última equação não seja escrita sozinha em uma linha. O que estou tentando fazer é dividir a penúltima equação em duas linhas. Mas isso acontece:

insira a descrição da imagem aqui

A última equação continua à direita por algum motivo. Você consegue identificar qual é o problema?

\usepackage{amsmath}
\newcommand{\q}[2]{\langle #1 | #2 \rangle}
\newcommand{\qr}[1]{|#1\rangle} 
\newcommand{\ql}[1]{\langle #1|} 
\DeclareMathOperator{\mdc}{mdc}

\begin{document}
\begin{align*}
  \qr{\psi_2} &= U_f \qr{\psi_1}\\
              &= U_f \frac{1}{\sqrt{2^4}} \left[\qr0 + \qr1 + \qr2+\qr3+\qr4+\qr5+\qr6 + \qr{7}\right] \qr0 \qr0\\
              &= U_f \frac{1}{\sqrt{2^4}} \left[\qr0\qr0 + \qr1\qr0 + \qr2\qr0+\qr3\qr0+\qr4\qr0+\qr5\qr0+\qr6\qr0 + \qr{7}\qr0\right] \qr0\\
\begin{split}
              &= \frac{1}{\sqrt{2^4}} \big[U_f\qr0\qr0 + U_f\qr1\qr0 + U_f\qr2\qr0+U_f\qr3\qr0 \\
              &\qquad\qquad + U_f\qr4\qr0+U_f\qr5\qr0+U_f\qr6\qr0 + U_f\qr{7}\qr0\big] \qr0\\
\end{split}
              &= \frac{1}{\sqrt{2^4}} \left[\qr0\qr2 + \qr1\qr4 + ... + \qr{i}\qr{f(i)} + ... + \qr{7}\qr1\right] \qr0,
\end{align*}

\end{document}

EDIT: Devo estar muito cansado quando escrevi esta pergunta porque, se você conhece um pouco de computação quântica, verá que deveria ter 16 estados e não 8 como escrevi.

Responder1

Além de se livrar do splitambiente desnecessário, você pode querer (a) compor os U_ftermos de forma mais compacta, ou seja, como U_{\!f}, (b) substituir várias \left[diretivas \right]and por \bigl[e \bigr], e (c) substituir ...por \dots.

insira a descrição da imagem aqui

\documentclass{article}
\usepackage{mathtools} % for '\DeclarePairedDelimiter' macro
\DeclarePairedDelimiter\qr\lvert\rangle
\newcommand{\Uf}{U_{\!f}}

\begin{document}

\begin{align*}
\qr{\psi_2} 
&= \Uf \qr{\psi_1}\\
&= \Uf \frac{1}{\sqrt{2^4}} 
   \bigl[\qr0 + \qr1 + \qr2+\qr3 +\qr4 
   +\qr5 +\qr6 + \qr7\bigr] \qr0 \qr0\\
&= \Uf \frac{1}{\sqrt{2^4}} 
   \bigl[\qr0\qr0 + \qr1\qr0 + \qr2\qr0+\qr3\qr0
   +\qr4\qr0+\qr5\qr0+\qr6\qr0 + \qr7\qr0\bigr] \qr0\\
&= \frac{1}{\sqrt{2^4}} 
   \bigl[\Uf\qr0\qr0 + \Uf\qr1\qr0 + \Uf\qr2\qr0+\Uf\qr3\qr0 \\
&\qquad\qquad 
   + \Uf\qr4\qr0+\Uf\qr5\qr0+\Uf\qr6\qr0 
   + \Uf\qr7\qr0\bigr] \qr0\\
&= \frac{1}{\sqrt{2^4}} 
   \bigl[\qr0\qr2 + \qr1\qr4 + \dots 
   + \qr{i}\qr{f(i)} + \dots + \qr7\qr1\bigr] \qr0,
\end{align*}
\end{document}

Responder2

Sugiro usar o multlinedambiente from mathtoolse o \DeclarePairedDelimitercomando do mesmo pacote, que produzirá escalonamento \, \qre \ql:

\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiterX\norm[1]\lVert\rVert{\ifblank{#1}{\: · \:}{#1}}
\DeclarePairedDelimiterXPP{\twonorm }[1]{}{\lVert}{\rVert}{_{2}}{\ifblank{#1}{\: · \:}{#1}}
\DeclarePairedDelimiterX\q[2]{\langle}{\rangle}%
{#1\,\delimsize\vert\,\mathopen{}#2}
\DeclarePairedDelimiter{\qr}\vert\rangle
\DeclarePairedDelimiter{\ql}\langle \rvert
\DeclareMathOperator{\mdc}{mdc}

\begin{document}

\begin{align*}
  \qr{\psi_2} &= U_f \qr{\psi_1}\\
              &= U_f \frac{1}{\sqrt{2^4}} \bigl[\qr0 + \qr1 + \qr2+\qr3+\qr4+\qr5+\qr6 + \qr{7}\bigr] \qr0 \qr0\\
              &= U_f \frac{1}{\sqrt{2^4}}\bigl[\qr0\qr0 + \qr1\qr0 + \qr2\qr0+\qr3\qr0+\qr4\qr0+\qr5\qr0+\qr6\qr0 + \qr{7}\qr0\bigr] \qr0\\
              &= \begin{multlined}[t] \frac{1}{\sqrt{2^4}} \bigl[U_f\qr0\qr0 + U_f\qr1\qr0 + U_f\qr2\qr0+U_f\qr3\qr0 \\[-1.5ex]
             \qquad+ U_f\qr4\qr0+U_f\qr5\qr0+U_f\qr6\qr0 + U_f\qr{7}\qr0\bigr] \qr0
\end{multlined}\\
              &= \frac{1}{\sqrt{2^4}}\bigl[\qr0\qr2 + \qr1\qr4 + ... + \qr{i}\qr{f(i)} + ... + \qr{7}\qr1\bigr] \qr0,
\end{align*}

\end{document} 

insira a descrição da imagem aqui

Responder3

Você pode usar alignedem vez de split, mas também splitpode usar, desde que emita \\no lugar certo.

Em vez de fazer seus próprios sutiãs e kets, é melhor usar um pacote especializado como braket. Também removi todos os \leftand inúteis \right, que não fazem nada além de adicionar espaço desnecessário, usando em vez disso \bigland \bigr(not \big).

\documentclass{article}
\usepackage{amsmath}
\usepackage{braket}

\newcommand{\q}[2]{\braket{#1|#2}}
\newcommand{\qr}[1]{\ket{#1}}
\newcommand{\ql}[1]{\bra{#1}}

\DeclareMathOperator{\mdc}{mdc}

\begin{document}

\begin{align*}
\qr{\psi_2}
&= U_f \qr{\psi_1}\\
&= U_f \frac{1}{\sqrt{2^4}}
   \bigl[\qr0 + \qr1 + \qr2 + \qr3 + \qr4 + \qr5 + \qr6 + \qr{7}\bigr] \qr0 \qr0 \\
&= U_f \frac{1}{\sqrt{2^4}}
   \bigl[
     \qr0\qr0 + \qr1\qr0 + \qr2\qr0 + \qr3\qr0 + \qr4\qr0 +
     \qr5\qr0 + \qr6\qr0 + \qr{7}\qr0
   \bigr] \qr0 \\
&= \begin{aligned}[t]
   \frac{1}{\sqrt{2^4}}
   \bigl[
    &U_f\qr0\qr0 + U_f\qr1\qr0 + U_f\qr2\qr0+U_f\qr3\qr0 \\
    &\quad+ U_f\qr4\qr0+U_f\qr5\qr0+U_f\qr6\qr0 + U_f\qr{7}\qr0
   \bigr] \qr0
\end{aligned}\\
&= \frac{1}{\sqrt{2^4}}
   \bigl[
     \qr0\qr2 + \qr1\qr4 + \dots + \qr{i}\qr{f(i)} + \dots + \qr{7}\qr1
   \bigr] \qr0,
\end{align*}

\end{document}

insira a descrição da imagem aqui

Você obtém essencialmente o mesmo com split:

\documentclass{article}
\usepackage{amsmath}
\usepackage{braket}
\newcommand{\q}[2]{\braket{#1|#2}}
\newcommand{\qr}[1]{\ket{#1}}
\newcommand{\ql}[1]{\bra{#1}}

\DeclareMathOperator{\mdc}{mdc}

\begin{document}

\begin{align*}
\qr{\psi_2}
&= U_f \qr{\psi_1}\\
&= U_f \frac{1}{\sqrt{2^4}}
   \bigl[\qr0 + \qr1 + \qr2 + \qr3 + \qr4 + \qr5 + \qr6 + \qr{7}\bigr] \qr0 \qr0 \\
&= U_f \frac{1}{\sqrt{2^4}}
   \bigl[
     \qr0\qr0 + \qr1\qr0 + \qr2\qr0 + \qr3\qr0 + \qr4\qr0 +
     \qr5\qr0 + \qr6\qr0 + \qr{7}\qr0
   \bigr] \qr0 \\
\begin{split}
&=\frac{1}{\sqrt{2^4}}
   \bigl[
    U_f\qr0\qr0 + U_f\qr1\qr0 + U_f\qr2\qr0+U_f\qr3\qr0 \\
    &\qquad\qquad+ U_f\qr4\qr0+U_f\qr5\qr0+U_f\qr6\qr0 + U_f\qr{7}\qr0
   \bigr] \qr0
\end{split}\\
&= \frac{1}{\sqrt{2^4}}
   \bigl[
     \qr0\qr2 + \qr1\qr4 + \dots + \qr{i}\qr{f(i)} + \dots + \qr{7}\qr1
   \bigr] \qr0,
\end{align*}

\end{document}

Responder4

Acho que o motivo pelo qual você está obtendo esse resultado é que a segunda quebra de linha dentro do splitambiente deveria estar fora, assim:

\begin{align*}
  \qr{\psi_2} &= U_f \qr{\psi_1}\\
              &= U_f \frac{1}{\sqrt{2^4}} \left[\qr0 + \qr1 + \qr2+\qr3+\qr4+\qr5+\qr6 + \qr{7}\right] \qr0 \qr0\\
              &= U_f \frac{1}{\sqrt{2^4}} \left[\qr0\qr0 + \qr1\qr0 + \qr2\qr0+\qr3\qr0+\qr4\qr0+\qr5\qr0+\qr6\qr0 + \qr{7}\qr0\right] \qr0\\
\begin{split}
              &= \frac{1}{\sqrt{2^4}} \big[U_f\qr0\qr0 + U_f\qr1\qr0 + U_f\qr2\qr0+U_f\qr3\qr0 \\
              &\qquad\qquad + U_f\qr4\qr0+U_f\qr5\qr0+U_f\qr6\qr0 + U_f\qr{7}\qr0\big] \qr0
\end{split}\\
              &= \frac{1}{\sqrt{2^4}} \left[\qr0\qr2 + \qr1\qr4 + ... + \qr{i}\qr{f(i)} + ... + \qr{7}\qr1\right] \qr0,
\end{align*}

Além das recomendações dadas na resposta de Bernard, também sugiro usar o splitambiente interno equation*em vez de align*, pois parece que você está tentando compor apenas uma equação (embora com várias linhas):

\documentclass{article}
\usepackage{amsmath}
\newcommand{\q}[2]{\langle #1 | #2 \rangle}
\newcommand{\qr}[1]{|#1\rangle} 
\newcommand{\ql}[1]{\langle #1|} 
\DeclareMathOperator{\mdc}{mdc}

\begin{document}

\begin{equation*}
 \begin{split}
  \qr{\psi_2} &= U_f \qr{\psi_1}\\
              &= U_f \frac{1}{\sqrt{2^4}} \left[\qr0 + \qr1 + \qr2+\qr3+\qr4+\qr5+\qr6 + \qr{7}\right] \qr0 \qr0\\
              &= U_f \frac{1}{\sqrt{2^4}} \left[\qr0\qr0 + \qr1\qr0 + \qr2\qr0+\qr3\qr0+\qr4\qr0+\qr5\qr0+\qr6\qr0 + \qr{7}\qr0\right] \qr0\\
              &=\!\begin{multlined}[t] \frac{1}{\sqrt{2^4}} \big[U_f\qr0\qr0 + U_f\qr1\qr0 + U_f\qr2\qr0+U_f\qr3\qr0 \\[-1.5ex]
             \qquad+ U_f\qr4\qr0+U_f\qr5\qr0+U_f\qr6\qr0 + U_f\qr{7}\qr0\big] \qr0
\end{multlined}\\
              &= \frac{1}{\sqrt{2^4}} \left[\qr0\qr2 + \qr1\qr4 + ... + \qr{i}\qr{f(i)} + ... + \qr{7}\qr1\right] \qr0,
 \end{split}
\end{equation*}

\end{document} 

informação relacionada