Find Cube root of a number using Log function | Python3 program to find cube root of a number using logarithm ; Function to find the cube root ; Calculate the cube root ; Return the final answer ; Driver code
import numpy as np NEW_LINE def cubeRoot ( n ) : NEW_LINE INDENT ans = pow ( 3 , ( 1.0 / 3 ) * ( np . log ( n ) / np . log ( 3 ) ) ) NEW_LINE return ans NEW_LINE DEDENT N = 8 NEW_LINE print ( " % .2f " % cubeRoot ( N ) ) NEW_LINE