简体   繁体   中英

Calculate the base of power function

Given function:

 y=power(x, z)

Where y is the base x raised to the power of z.

In Java and many other language, there is function Math.pow() to calculate this.

My question is: how to calculate x, given y and z? Is there a standard library function for this?

This is done easily enough by remembering a mathematical law:

  • x ab = (x a ) b

And now because z*(1/z)=1, the inverse of raising to the power z is raising to the power 1/z. So in your case

  • x = y 1/z

Once you've got your power() function, that's all you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM