2 min read

Categories

The mathematical symbol x in a room with a ceiling and a floor, digital art, vibrant
Generated using DALL-E-2 with the prompt "The mathematical symbol x in a room with a ceiling and a floor, digital art, vibrant". The 'abs' columns round x were not actually specified in the prompt but came for free!"

Contents

Introduction

In this blog post, we will learn how to write the ceiling, floor and absolute value functions in LaTeX, both in mathematical notation and as text.

Ceiling Function:

The ceiling function rounds up a number to the nearest integer greater than or equal to it. For instance, $\lceil 3.2 \rceil = 4$.

To write the ceiling function in LaTeX, you can use the following notation:

\left\lceil x \right\rceil

which renders as $\left\lceil x \right\rceil$.

Here, the “\left” and “\right” commands are used to automatically adjust the size of the brackets surrounding the input ‘x’ based on the content.

For example if you had not used the “\left” and “\right” commands, a ceiling function with a large input would look like this:

$\lceil \frac{1}{x} \rceil$

whereas using the “\left” and “\right” commands, you get:

$\left\lceil \frac{1}{x} \right\rceil$

To simplify the usage, you can define a new command called “\ceil” in the preamble of your LaTeX document:

\newcommand{\ceil}[1]{\left\lceil #1 \right\rceil}

Now, you can use the “\ceil” command to write the ceil function as follows:

$\ceil{x}$

Floor Function:

The floor function rounds down a number to the nearest integer less than or equal to it. For example, $\lfloor 3.8 \rfloor = 3$.

To write the floor function in LaTeX, you can use the following notation:

\left\lfloor x \right\rfloor

which renders as $\left\lfloor x \right\rfloor$.

Similarly to the ceiling function, the “\left” and “\right” commands are employed to adjust the size of the brackets automatically.

To define a command for the floor function, add the following line to your LaTeX preamble:

\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}

Text Mode

The floor, ceil, and abs commands can also be used in text mode by enclosing them within “\text” commands. For example:

$\text{ceil}\left(x\right)$

which renders as $\text{ceil}\left(x\right)$.

Here, the “\text” command ensures that the function names are rendered in regular text font within a mathematical expression.

Absolute Value Function

The absolute value function returns the magnitude of a number. For instance, $|3| = |-3| = 3$.

To write the absolute value function in LaTeX, you can use the following notation:

\left \lvert x \right \rvert

You can also just use \vert instead of \lvert and \rvert:

\left \vert x \right \vert

or you can simply use the vertical bar symbol

\left | x \right |

all of which render as $\left \lvert x \right \rvert$.

You can define a command for the absolute value function as follows:

\newcommand{\abs}[1]{\left \lvert #1 \right \rvert}

Conclusion

To summarise, we have learned how to write the ceil, floor and abs functions in LaTeX. We explored the notation for each function using the “\left” and “\right” commands to adjust the size of the brackets automatically. Additionally, we defined custom commands, “\ceil,” “\floor”, and “\abs” to simplify the usage of these functions in LaTeX documents.