Math & Sciencemulti line equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
jannetta
Posts: 46
Joined: Mon Dec 22, 2008 12:59 pm

multi line equation

Post by jannetta »

Hi Folks

I have three equations that relate to one calculation. I don't want each equation on its own line but I only want one number reference. Something like this:

Code: Select all

\begin{equation}
(m_{i}^{*},b_{i}^{*}) = \frac{argmin}{m,b}\sum_{t=i}^{i+w}\|x_{t}-m\cdot(t-i)-b\|^{2} \\
\\
y_{i}=x_{i}-m_{i}^{*}\cdot i - b_{i}^{*} \\
\\
i=1,\ldots,z
\end{equation}
However, when I use the above, everything appears on one line. I tried using 'multline' but then the three equations are staggered and not centred in the middle of the page.

Any advice would be appreciated.

Kind Regards
Jannetta

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

jannetta
Posts: 46
Joined: Mon Dec 22, 2008 12:59 pm

multi line equation

Post by jannetta »

Oh! I found a solution 5 minutes after I posted. This seems to work:

Code: Select all

\begin{equation}
\begin{array}{c c c}
(m_{i}^{*},b_{i}^{*}) = \frac{argmin}{m,b}\sum_{t=i}^{i+w}\|x_{t}-m\cdot(t-i)-b\|^{2} 
\\
y_{i}=x_{i}-m_{i}^{*}\cdot i - b_{i}^{*}
\\
i=1,\ldots,z
\end{array}
\end{equation}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

multi line equation

Post by Johannes_B »

HI, what you have found there is the math-version of a regular table. You have defined three columns, but are only using the first. You could as well use l to make it left-aligned, and r for right-aligned.

If you want to align all equations at the euqal sign, you can use the more commonly used align-environment. Please click on open in writelatex to see the output and compare the appearance of the sum.

Code: Select all

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
	\begin{array}{l}
		(m_{i}^{*},b_{i}^{*}) =
		\frac{\arg\min}{m,b}\sum_{t=i}^{i+w}\|x_{t}-m\cdot(t-i)-b\|^{2} \\
		\displaystyle(m_{i}^{*},b_{i}^{*}) = \frac{\arg\min}{m,b}\sum_{t=i}^{i+w}\|x_{t}-m\cdot(t-i)-b\|^{2} \\
		y_{i}=x_{i}-m_{i}^{*}\cdot i - b_{i}^{*} \\
		i=1,\ldots,z
	\end{array}
\end{equation}
\begin{align}
		(m_{i}^{*},b_{i}^{*}) &=
		\frac{\arg\min}{m,b}\sum_{t=i}^{i+w}\|x_{t}-m\cdot(t-i)-b\|^{2} \\
		y_{i}&=x_{i}-m_{i}^{*}\cdot i - b_{i}^{*} \\
		i&=1,\ldots,z\notag
\end{align}
\end{document}
Please also note that i changed the argmin part. You can read much more about math mode in Herberts ebook, it might even be on your machine right now. You can also look it up on CTAN -> voss-mathmode. Reading all isn't necessary, but skimming the pdf might be a good idea.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply