我有以下方程式:
\begin{equation}\label{eq:4: Partial W }
\begin{align}
\frac{\partial s}
{\partial W}
& = \frac{\partial \sum_{i=1}^{n} (y_i -(W\cdot x_i+b))^2}
{\partial W}\\
& = \sum_{i=1}^{n} 2(y_i -W\cdot x_i-b)\cdot(-x_i))
= 2\cdot \sum_{i=1}^{n} (-y_i\cdot x_i + W\cdot x_i^2 + b\cdot x_i ) \stackrel{!}{=} 0 \\ \\
&\Longleftrightarrow W\cdot(\sum_{i=1}^{n} x_i^2) + b\cdot(\sum_{i=1}^{n}x_i) = \sum_{i=1}^{n}x_i\cdot y_i
\end{align}
\end{equation}
\begin{equation}\label{eq:5: Partial b }
\begin{align}
\frac{\partial s}
{\partial b}
& = \frac{\partial \sum_{i=1}^{n} (y_i -(W\cdot x_i+b))^2}
{\partial b}\\
& = \sum_{i=1}^{n} 2(y_i -W\cdot x_i-b)\cdot(-1))
= 2\cdot \sum_{i=1}^{n} (-y_i\cdot+ W\cdot x_i+ b) \stackrel{!}{=} 0 \\ \\
&\Longleftrightarrow W\cdot(\sum_{i=1}^{n} x_i) +\sum_{i=1}^{n}b = \sum_{i=1}^{n} y_i\\
&\Longleftrightarrow W\cdot(\sum_{i=1}^{n}x_i) + n\cdot b = \sum_{i=1}^{n} y_i
\end{align}
\end{equation}
我的问题是如何对齐第二个方程,并将两个方程 ID 放在每个方程的末尾而不是中间。
答案1
将所有内容放在一个align
环境中,不要将其封闭在equation
环境中,并\nonumber
在不应编号的行上使用。
\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
\frac{\partial s}{\partial W}
&= \frac{\partial \sum_{i=1}^{n} (y_i -(W\cdot x_i+b))^2}
{\partial W} \nonumber \\
&= \sum_{i=1}^{n} 2(y_i -W\cdot x_i-b)\cdot(-x_i))
= 2\cdot \sum_{i=1}^{n} (-y_i\cdot x_i + W\cdot x_i^2 + b\cdot x_i )
\stackrel{!}{=} 0 \nonumber\\ \nonumber\\
&\Longleftrightarrow W\cdot(\sum_{i=1}^{n} x_i^2) + b\cdot(\sum_{i=1}^{n}x_i)
= \sum_{i=1}^{n}x_i\cdot y_i \label{eq:4: Partial W } \\
\frac{\partial s}{\partial b}
&= \frac{\partial \sum_{i=1}^{n} (y_i -(W\cdot x_i+b))^2}
{\partial b} \nonumber \\
&= \sum_{i=1}^{n} 2(y_i -W\cdot x_i-b)\cdot(-1))
= 2\cdot \sum_{i=1}^{n} (-y_i\cdot+ W\cdot x_i+ b)
\stackrel{!}{=} 0 \nonumber \\ \nonumber \\
&\Longleftrightarrow W\cdot(\sum_{i=1}^{n} x_i) +\sum_{i=1}^{n}b
= \sum_{i=1}^{n} y_i \nonumber \\
&\Longleftrightarrow W\cdot(\sum_{i=1}^{n}x_i) + n\cdot b
= \sum_{i=1}^{n} y_i \label{eq:5: Partial b }
\end{align}
\end{document}