# LaTeX square root

## This tutorial teaches you the simplest and clearest method to typeset square roots. You will learn how to typeset nth root, adjust root exponent position and radical symbol height.

In mathematics, a square root of a number $$a$$ is the number $$b$$ such that $$b^2= a$$. The mathematical symbol for square root is √· where the square root of $$a$$ is written symbolically $$\sqrt{a}$$.

## The LaTeX square root command is \sqrt{arg}

The following code highlights the use of square root command in LaTeX

% LaTeX square root command
\documentclass{article}

% Math package
\usepackage{amsmath}

\begin{document}

$\sqrt{a}=b \qquad \text{iff} \quad b^2=a$

\end{document}

Compiling this code yields:

$$\sqrt{a}=b \qquad \text{iff} \quad b^2=a$$

The above code makes use of 6 commands:

1. \documentclass {class }: this command specifies(defines) the type of document you are dealing with and in this case, the type of document is an article.
2. \usepackage {amsmath}: it is placed in our preamble (area before \begin{document}). It takes the argument amsmath which is capable to interpreting and facilitating the writing of mathematical symbols, formulas and improves the quality of the mathematics output in our document.
3. \begin {document} \end {document}: defines the document environment (i.e where all our text and equations enter).
4. \sqrt{} command: LaTeX command for square root. \sqrt{} takes an argument in the braces and return it inside a square symbol e.g \sqrt{a}: takes and and returns $$\sqrt{a}$$ .
5. \text{…} command: LaTeX command which formats it’s argument by causing it to remain plain text even in math mode, read this post: “Write Text inside Math Mode: Tips + Examples“.

## How do you write nth root in latex?

The nth root of a number $$x$$ is the number $$y$$ such that $$y^n=x$$, it is denoted $$\sqrt[n]{x}$$. In LaTeX, the nth root is obtained by the command: \sqrt[n]{arg}. We have from the command, [..] which takes the root (natural numbers i.e 1,2,3,. . . ) and the {…} which takes the argument whose root is represented or evaluated.

Example: The cube root in LaTeX is obtained by the command \sqrt[3]{x}, which yields $$\sqrt[3]{x}$$.

## How to adjust the index (root exponent) position?

The position of the root exponent (index) can be adjusted in LaTeX using the commands \leftroot{} and/or \uproot{}. Check the following code:

% Adjust the index position
\documentclass{article}

% Math package
\usepackage{amsmath}

\begin{document}

$\sqrt[\leftroot{10} \uproot{5} n]{b}$

\end{document}

Compiling this code yields the following output (right side) where you can compare it with the default one (left side):

• \leftroot{} moves n to the left – or to the right with a negative argument.
• \uproot{} moves n up – or down with a negative argument.

It is not necessary to use both commands, e.g. if you would like to move the root exponent up use only \uproot{} command.

The following LaTeX code:

% Adjust the radical symbol height
\documentclass{article}

% Math package
\usepackage{amsmath}

\begin{document}

$\sqrt{e}\, \sqrt{T}\,\sqrt{T^2_1}$

\end{document}

yields the following output:

where radical symbol height depends on its argument. To get the same height, we can create a phantom vertical spacing equivalent to the argument with a big height. This can be achieved using the command \vphantom{}.

In the previous example, we can use \vphantom{T^2_1} inside each \sqrt{} command. Here is a modified code:

% Adjust the radical symbol height
\documentclass{article}

% Math package
\usepackage{amsmath}

\begin{document}

$\sqrt{e\vphantom{T^2_1}}\, \sqrt{T\vphantom{T^2_1}}\,\sqrt{T^2_1}$

\end{document}

compiling this code yields:

## Conclusion

This tutorial gives you a brief description of the concept square root and at the same time gives an in depth knowledge of nth root and how to adjust root exponent position and radical symbol height.

Stay tuned for more in depth tutorials and don’t forget to share with others if this has added value to you!