Rational number exponented to a rational number
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Rational number exponented to a rational number
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?
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: Rational number exponented to a rational number
Ok, my mistake: pow() can do the calculation for decimal exponents.
But are there any arbitrary precision functions that can do this?
But are there any arbitrary precision functions that can do this?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Rational number exponented to a rational number
I confirmed that you are right. Do it manually with a loop? Ugh...
(#10850)
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Re: Rational number exponented to a rational number
Well, I'm sure there's an algorithm for it, but implementing it in PHP would probably be very slow.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Rational number exponented to a rational number
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
No, don't! Unless you are working with very small numbers.arborint wrote:I confirmed that you are right. Do it manually with a loop? Ugh...
The built in functions probably use algorithms much faster than whatever you can come up with.