OKPEDIA PYTHON EN

How to calculate nth root on Python

To calculate the nth root of a number in the python language, use the pow() function using a fractional exponent.

pow(a,1/b)

  • The first parameter is the radical of the root. It is a real number.
  • The second parameter is the inverse of the root index.
    • 1/2 = square root
    • 1/3 = cubic root
    • 1/4 = fourth root
    • 1/5 = fifth rood
    • 1/n = nth root ( index n )

The function calculates the square, cubic or nth root on any index.

the root of a radical number

Note. The computation of the nth root using pow() is based on a simple mathematical equivalence relationship between powers and roots.
the equivalence between the power and the root of a number

Practical examples

Example 1

This instruction takes the square root of 9.

pow(9,1/2)

3.0

A number raised to 1/2 equals the square root of the number.

square root example

Number 3 is the square root of 9.

Example 2

This statement calculates the cube root of 27.

pow(27,1/3)

3.0

A number raised to 1/3 is equivalent to calculating the cubic root of the number.

the cubic root

The result is 3 because 3 · 3 · 3 = 27.

Example 3

This statement calculates the fourth root of a number

pow(81,1/4)

3.0

The function returns the nth root with n = 4 of 81.

the root with index four of a radical

The result is 3 because 34 = 81

https://how.okpedia.org/en/python/how-to-calculate-nth-root-on-python


Report an error or share a suggestion to enhance this page



FacebookTwitterLinkedinLinkedin