Jump to content

Recommended Posts

Hi I need to write a PHP function for this equation:

 

[ ((2/3)(x-50))^(1/3) ] + 4

 

The problem is that PHP converts the 1/3 to a decimal or something, but I need it to take the cube root. Right now with that equation above in PHP any X value under 50 produces a nonreal answer and thus NaN as a result. The equation works fine on my Ti-84.

 

So basically I need to figure out how to take cube roots in PHP.

For some reason if you try to cube root -16 it breaks...

 

So I changed $x to equal 3 instead of two. All number from -99 to 99 have been tested.

 

function cube( $c ) {

$x = 3;

 

do {

$x = $x - (pow($x,3) - $c)/(3*pow($x,2));

 

$count++;

} while($count < 50);

return $x;

 

}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.