Jump to content

Archived

This topic is now archived and is closed to further replies.

chrisbcats

Caculate Exponents

Recommended Posts

How do I caculate exponents (powers) in php?

Here is my formula:

$netValue = ($margin_benefit * (1 + $weightAverage)^(($improvment/365) - $margin_benefit));


I need:
[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]($margin_benefit * (1 + $weightAverage) [!--colorc--][/span][!--/colorc--]

to be raised to the

[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--](($improvment/365) - $margin_benefit))[!--colorc--][/span][!--/colorc--]

power

Share this post


Link to post
Share on other sites
I beleive the pow() function should do it.

[a href=\"http://us2.php.net/manual/en/function.pow.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.pow.php[/a]

Share this post


Link to post
Share on other sites
k, that works. Here is my new problem:

pow ( base, exp );

PHP cannot handle negative bases.

I have a negative exponent. The function returns 0.

$netValue = pow(4140000,-3599999.9);

How can I comupte a negative exponent?

Share this post


Link to post
Share on other sites
Calculate for the positive exponent and then take the reciprocal.

x^-y = 1/x^y

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.