Search code examples
pythonmathlogarithmpowsquare-root

How can I invert y = pow(x, z) to get x?


As I know there is no build-in functions to do this directly, so log()? or a simple math shortcut like:

z = y ** (1/x)

x?


Solution

  • If y=pow(x,z) then x = pow(y,1.0/z):

    >>> y = pow(3,1.7)
    >>> y
    6.473007839923779
    >>> pow(y,1.0/1.7)
    3.0