Math Runs locally Ready to use Built-in examples No tracking

Exponent & Root Calculator

Compute powers x^y and roots including square, cube and arbitrary nth roots, with odd-root support for negative numbers.

Squares and cubes are easy; negatives are where things go wrong. A negative number has a real odd root (∛−27 = −3) but no real even root at all, and plenty of software quietly returns a wrong value instead of saying so. Powers and roots are split into two panels here, odd roots of negatives are computed properly, and an even root of a negative is reported as undefined instead of NaN.

The rule to remember: an even root of a negative number has no real solution (√−4 is undefined in the reals), while an odd root has exactly one. The trap is in the code — Math.pow(−27, 1/3) returns NaN in JavaScript, because 1/3 is not exact in binary floating point; the workaround is −Math.pow(27, 1/3). This tool handles that case correctly rather than passing the NaN through.

How to use

  1. Choose the powers panel (x^y, negative exponents allowed) or the roots panel.
  2. Enter the values and read the result.
  3. For a negative base, check whether the root is odd or even before trusting a value.
  4. Copy the result — a negative exponent gives a reciprocal, not an error.

How it works

Exponentiation

Exponentiation: enter a base and an exponent. 2^10 = 1024; negative bases work too — (-2)³ = -8, (-2)² = 4.

Squares and cubes at a click

Square/cube shortcuts: the "x²" and "x³" buttons set the exponent to 2 or 3 so you don't have to type it.

Roots

Roots: enter the radicand and the root index. √2 ≈ 1.4142135624; ∛(-27) = -3; a 4th root of −16 has no real solution and the tool reports it as out of domain.

Code example

JavaScript Taking an odd root of a negative number, correctly

function nthRoot(x, n) {
  if (x < 0 && n % 2 === 1) return -Math.pow(-x, 1 / n);  // odd root
  if (x < 0) return NaN;                                  // no real even root
  return Math.pow(x, 1 / n);
}

nthRoot(-27, 3);    // -3 (Math.pow(-27, 1/3) gives NaN)
nthRoot(16, 4);     // 2
Math.pow(2, -2);    // 0.25 (a negative exponent is a reciprocal)

Python The Python trap with negative roots

(-27) ** (1 / 3)     # complex! Python 3 returns a complex number

# The correct real solution:
import math
-math.pow(27, 1 / 3)   # -3.0
math.copysign(abs(-27) ** (1 / 3), -27)   # the general form

# An even root of a negative: math.sqrt(-4) raises ValueError (an explicit error)

FAQ

Can I take the square root of a negative number?

Not in the reals: every real square is non-negative, so √(−4) has no real solution (the result is the imaginary 2i, beyond this tool's scope). Negative numbers do have odd-order roots, though: ∛(−8) = −2.

Will big numbers overflow?

Results beyond JavaScript's safe representation range (e.g. 10^400) are reported as out of domain; ordinary study and engineering use (up to about 10^300) computes normally.

Can the exponent be a decimal or negative?

Both. 2^0.5 equals √2 ≈ 1.4142, and 2^−2 = 0.25. A fractional exponent is mathematically a root operation.

What are the laws of exponents?

Multiplying powers with the same base adds exponents (a^m · a^n = a^(m+n)); dividing subtracts them; raising a power to a power multiplies them ((a^m)^n = a^(mn)); and the power of a product distributes over factors ((ab)^n = a^n · b^n). Note that (a + b)^n ≠ a^n + b^n.

Square root vs. cube root — what's the difference?

A square root asks which number times itself gives the value (√9 = 3); negative numbers have no real square root. A cube root asks which number cubed gives the value (∛27 = 3), and negatives do have real cube roots (∛(−8) = −2). Even-order roots require a non-negative radicand; odd-order roots have no such restriction.

What is 0 to the power of 0?

Mathematics leaves it undefined in general, but combinatorics (binomial expansion) and most programming languages set it to 1 — JavaScript's Math.pow(0, 0) returns 1. Handle this edge case according to the convention of your context.

How do fractional exponents map to radicals?

a^(1/n) = ⁿ√a and a^(m/n) = ⁿ√(a^m). For example 8^(2/3) = ∛(8²) = ∛64 = 4. The denominator of the fraction is the root index and the numerator is the power — unifying exponentiation and roots in one notation.