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:
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 split
ambiente desnecessário, você pode querer (a) compor os U_f
termos 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
.
\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 multlined
ambiente from mathtools
e o \DeclarePairedDelimiter
comando do mesmo pacote, que produzirá escalonamento \, \qr
e \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}
Responder3
Você pode usar aligned
em vez de split
, mas também split
pode 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 \left
and inúteis \right
, que não fazem nada além de adicionar espaço desnecessário, usando em vez disso \bigl
and \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}
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 split
ambiente 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 split
ambiente 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}