Page 1 of 1
Rational number exponented to a rational number
Posted: Wed Mar 19, 2008 4:34 pm
by Ambush Commander
pow(), bcpow() and gmp_pow() all have a restriction in that the exponent must be an integer. However, I have the need to calculate 5.66 to the 3.44 power to an arbitrary precision. How can I do this in PHP?
Re: Rational number exponented to a rational number
Posted: Wed Mar 19, 2008 4:52 pm
by Ambush Commander
Ok, my mistake: pow() can do the calculation for decimal exponents.
But are there any arbitrary precision functions that can do this?
Re: Rational number exponented to a rational number
Posted: Wed Mar 19, 2008 5:42 pm
by Christopher
I confirmed that you are right. Do it manually with a loop? Ugh...
Re: Rational number exponented to a rational number
Posted: Wed Mar 19, 2008 9:10 pm
by Ambush Commander
Well, I'm sure there's an algorithm for it, but implementing it in PHP would probably be very slow.
Re: Rational number exponented to a rational number
Posted: Fri Mar 21, 2008 9:14 pm
by Ambush Commander
Anyone?
Re: Rational number exponented to a rational number
Posted: Fri Mar 21, 2008 11:47 pm
by Chris Corbyn
My only suggestions was going to be bcpow(), but according to the user comments it does not support decimal powers. I suspect that's your options exhausted, far from a custom (and more than likely slow) implementation.
Re: Rational number exponented to a rational number
Posted: Sat Mar 22, 2008 8:25 am
by Oren
arborint wrote:I confirmed that you are right. Do it manually with a loop? Ugh...
No, don't! Unless you are working with very small numbers.
The built in functions probably use algorithms much faster than whatever you can come up with.