Square Root in LaTeX

Write a square root with \sqrt{…}: \sqrt{x^2 + 1}. For a cube or nth root put the index in square brackets: \sqrt[3]{x}, \sqrt[n]{x}. The radical sign grows to fit whatever is inside the braces.

Root commands

  • \sqrt{x}
    x

    Square root.

  • \sqrt[3]{x}
    x 3

    Cube root.

  • \sqrt[n]{x}
    x n

    nth root.

  • \sqrt{\frac{a}{b}}
    a b

    Root of a fraction; the sign stretches.

  • \sqrt{x^2 + y^2}
    x 2 + y 2

    Root over a longer expression.

  • x^{1/2}
    x 1 / 2

    Exponent form, when a radical would be too tall.

  • \sqrt[\leftroot{-2}\uproot{2} n]{x}
    x n

    Moves the index (amsmath \leftroot, \uproot).

  • \surd
    √

    The √ sign alone, without a bar.

Try it live

Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.

Templates

Square root examples

Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.

  • Quadratic formula

    x = − b ± b 2 − 4 a c 2 a
    LaTeX
    x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
  • Distance formula

    d = ( x 2 − x 1 ) 2 + ( y 2 − y 1 ) 2
    LaTeX
    d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}
  • Cube root

    27 3 = 3
    LaTeX
    \sqrt[3]{27} = 3
  • Nested radicals

    2 + 2 + 2
    LaTeX
    \sqrt{2 + \sqrt{2 + \sqrt{2}}}
  • Root of a fraction

    1 − cos ⁡ θ 2
    LaTeX
    \sqrt{\frac{1 - \cos \theta}{2}}
  • Even root heights

    a + b vs b a + b
    LaTeX
    \sqrt{a} + \sqrt{b} \quad \text{vs} \quad \sqrt{\vphantom{b} a} + \sqrt{b}

    \vphantom{b} adds the height of a b without printing it, so both radicals line up.

  • Standard deviation

    σ = 1 N ∑ i = 1 N ( x i − μ ) 2
    LaTeX
    \sigma = \sqrt{\frac{1}{N} \sum_{i=1}^{N} (x_i - \mu)^2}

How to write a root step by step

Use \sqrt in math mode and put everything under the radical in braces. Without braces only the next character goes under it: \sqrt x+1 means √x + 1.

For other roots add the index in square brackets before the braces: \sqrt[3]{x}. The index is set small in the notch of the radical.

Roots over letters of different heights come out uneven (√a is shorter than √b). Add a \vphantom or \mathstrut inside the lower one to match them.

Radical or exponent?

A radical over a tall fraction or a long sum becomes large and heavy. In those cases, and inside running text, (…)^{1/2} is easier to read and keeps the line height normal.

LaTeX
\[ \left( \frac{\sum_{i} x_i^2}{n} \right)^{1/2} \]

Common mistakes

  • Parentheses do not group in LaTeX. Only the “(” goes under the radical.

    Instead of
    \sqrt(x+1)
    Write
    \sqrt{x+1}
  • The index goes in square brackets. \sqrt{3}{x} is √3 followed by x.

    Instead of
    \sqrt{3}{x}  (meant as a cube root)
    Write
    \sqrt[3]{x}
  • A superscript on \sqrt is not an index; it raises a stray 3 after the radical sign.

    Instead of
    \sqrt^3{x}
    Write
    \sqrt[3]{x}

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    \sqrt and \sqrt[n] work in any document. \leftroot and \uproot for adjusting the index need \usepackage{amsmath}.

  • MathJax and KaTeX

    MathJax and KaTeX support \sqrt, \sqrt[n] and \vphantom, so the same code works in Markdown, Jupyter and on web pages.

  • Microsoft Word

    Word has radical templates, but pasted LaTeX is not converted reliably. Write the root here and use Copy for Word to paste an editable Word equation.

Square root in LaTeX: questions

What is the LaTeX command for square root?
\sqrt{…} in math mode, for example $\sqrt{2}$.
How do I write a cube root in LaTeX?
Give the index in square brackets: \sqrt[3]{x}. The same works for any root, such as \sqrt[4]{x} or \sqrt[n]{x}.
How do I write the square root of 2?
\sqrt{2}. For a single digit \sqrt2 also works, but braces are clearer and needed for anything longer.
How do I get just the √ symbol?
\surd prints the radical sign without the bar. Outside math mode you can also type the Unicode character √ with XeLaTeX or LuaLaTeX.

Have the formula as a picture?

Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.

Convert an image to LaTeX