Nth root in code
Unicode escapes, LaTeX, and the actual x^(1/n) formula across JavaScript, Python, Excel, and half a dozen other languages — including why odd and even indexes behave completely differently on negative numbers.
Or generate your exact symbol now →Unicode escapes & HTML entities
The 4th root, ∜, is Unicode code point U+221C and drops into a string literal like any other escape. Every other index has to be built from two escapes: a superscript digit followed by U+221A, the base radical.
"\u221C" // ∜"\u221c" # ∜"\u2075\u221A" // ⁵√∜ (no named entity)content: "\221C";LaTeX
\sqrt renders a proper radical with a bar over its argument in LaTeX, MathJax, and KaTeX — the bracketed value is what sets the index, whether that's a literal number or the letter n.
\sqrt[n]{x}\sqrt[5]{x}\sqrt[3]{x}Calculating an nth root in code
Unlike square or cube root, no mainstream language ships a dedicated "nth root" function — every one of these computes it as x raised to the power of 1/n. Here's the syntax for each language on the 5th root of 32.
Math.pow(32, 1 / 5);
// 2
Math.pow(-243, 1 / 5);
// NaN — even though the real answer is -3, see gotchas32 ** (1/5)
# 2.0
(-243) ** (1/5)
# complex! see gotchas below=A1^(1/B1)
=SIGN(A1)*ABS(A1)^(1/B1) // safe for negative A1, odd B1Math.pow(32, 1.0 / 5);
// 2.0#include <math.h>
pow(32, 1.0 / 5);
// 2pow(32, 1 / 5);
// 2SELECT POWER(32, 1.0/5);
-- 2import Foundation
pow(32.0, 1.0 / 5.0)
// 2.032 ^ (1/5)
# 2Gotchas worth knowing
Odd vs. even index changes whether negative numbers even have a real answer
The 5th root of -243 is a real number, -3, the same way cube roots of negative numbers work — any odd index does. The 4th root of -16 isn't a real number at all, the same way square roots of negative numbers aren't — any even index behaves this way. Whether x^(1/n) is even meaningful for negative x depends entirely on whether n is odd or even, before you even get to how a specific language implements it.
Generic power functions get negative bases wrong even when a real answer exists
Math.pow(-243, 1/5) returns NaN in JavaScript, even though the mathematically correct answer is -3 — Math.pow() computes fractional exponents using logarithms, which are undefined for negative bases, so it can't tell an odd index apart from an even one. Python's (-243) ** (1/5) returns a complex number instead of -3, for the same underlying reason. Neither language has a dedicated "nth root" function the way JavaScript has Math.cbrt() for cube roots specifically — you either write a helper that checks whether n is odd, or restrict yourself to non-negative inputs.
A safe nth-root helper needs to branch on the sign and parity
A reliable version looks like: if x is negative, only compute a real result when n is odd, and in that case take the nth root of the absolute value and reapply the negative sign — Math.sign(x) * Math.abs(x) ** (1/n) in JavaScript, or math.copysign(abs(x) ** (1/n), x) in Python. For negative x with an even n, there's no real result to return at all — decide upfront whether your code should throw, return NaN, or return a complex value.
Excel and Google Sheets have no NTHROOT function
There's no dedicated formula in either app. =A1^(1/B1) works whenever the result should be real and non-negative-input, but returns a #NUM! error for a negative A1 paired with certain B1 values. =SIGN(A1)*ABS(A1)^(1/B1) fixes the case where B1 is odd; it still won't produce a real result when B1 is even and A1 is negative, because none exists.
Floating-point precision compounds with higher indexes
32 ** (1/5) can land on 1.9999999999999998 instead of exactly 2 in some languages, and the gap tends to grow with higher indexes since 1/n itself is often an imprecise binary fraction. Round before comparing an nth root result for exact equality, the same caution that applies to square roots but slightly more pronounced.
Just need the symbol itself?
The copy formats page has every version ready to paste — the dedicated 4th-root character, composed higher-index symbols, and the spreadsheet formula — no code editor required.
Open copy formatsFrequently asked questions
What is the Unicode escape for an nth root symbol in code?
For the 4th root specifically, use \u221C (JavaScript, Java, C#) or \u221c (Python) — both resolve to ∜. For any other index, concatenate a superscript-digit escape with \u221A (the base radical): \u2075\u221A produces ⁵√ in JavaScript, for example.
How do I calculate an nth root in JavaScript?
Use Math.pow(x, 1 / n) — for example Math.pow(32, 1/5) returns 2. This works cleanly for non-negative x. For a negative x with an odd n, Math.pow() incorrectly returns NaN even though a real answer exists; you need a helper that checks the sign and parity of n first (see the gotchas below).
How do I calculate an nth root in Python?
For non-negative numbers, x ** (1/n) or math.pow(x, 1/n) both work, e.g. 32 ** (1/5) returns 2.0. For a negative x, x ** (1/n) returns a complex number rather than a real one, even when n is odd and a real answer exists — use math.copysign(abs(x) ** (1/n), x) to get a real result in that case.
What's the Excel or Google Sheets formula for an nth root?
Neither app has a built-in NTHROOT function. Use =A1^(1/B1), with the index in B1. If A1 can be negative and B1 is odd, use =SIGN(A1)*ABS(A1)^(1/B1) instead, since a plain power formula errors on a negative base otherwise.
What's the LaTeX command for an nth root?
\sqrt[n]{x} for a variable index, or replace n with a specific number — \sqrt[5]{x} for a 5th root, \sqrt[12]{x} for a 12th. Dropping the bracketed argument entirely, \sqrt{x}, renders a plain square root. Works in LaTeX, MathJax, and KaTeX.
Why does Math.pow(-243, 1/5) return NaN instead of -3?
Math.pow() (and the equivalent in most C-family languages) computes fractional exponents using logarithms, which are undefined for a negative base regardless of whether the index is odd or even — so it returns NaN across the board rather than recognizing that an odd-index root of a negative number is a well-defined real value. Dedicated cube-root functions like Math.cbrt() handle this correctly because they're implemented separately for that one specific, common index; there's no equivalent built-in for an arbitrary nth root.