Square or any Root programatically?

Ever wondered how to programatically get the root of any number programatically?

A square root of any number in excel can be found using the function “=SQRT(#);” where # is the number you want to have the root from. When you test this with the number 3 (commonly used to calculate complex “real” power consumption of a three fase system) You should get this as an result.

1,732050808

Because a “square” root is the opposite of a square power from that number you can use the following to find the same root using that same power ^ sign.

Square Root = 3^(1/2) = SQRT(#) = 3^0.5

If you add this example in excel as a check value.

=3^(1/2)

You will notice that the answer is also

1,732050808

Using the formula for complex power calculation in PHP will give you

$Cosphi = ($Cosphi > 1) ? "1" : $Cosphi;
$Phases = ($Phases < 2) ? "2" : $Phases;

$Pw = $U . $I . $Cosphi . ($Phases^(1/2));

Yea! Its that easy!! šŸ˜‰

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s