Math & Science ⇒ Brackets for equality
Brackets for equality
I'm attempting to define a function (the Collatz conjecture - see http://en.wikipedia.org/wiki/Collatz_conjecture)
I set up the equality
f(n) = {n/2 if n is even
{3n+1 if n is odd
I'd like to combine the brackets, just like in the link above. Is this possible?
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
Brackets for equality
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
f(n) =
\begin{cases}
n/2 &\text{if $n$ is even} \\
3n+1 &\text{if $n$ is odd}
\end{cases}
\]
\end{document}
Re: Brackets for equality
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Brackets for equality
What about using the equation environment? Perhaps some basic reading would be good for you.generator wrote:[…] However, I'd also like to put this into an equation, numbered for clarity. How would I do this?
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Brackets for equality
Brackets for equality
Code: Select all
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
f(n) =
\begin{cases}
n/2 &\text{if $n$ is even} \\
3n+1 &\text{if $n$ is odd}
\end{cases}
\label{collatzfunction}
\end{equation}
As you can see in (\ref{collatzfunction}), blah blah blah.
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Brackets for equality
[1] View topic: LaTeX Resources for Beginners
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10