Jump to content

help with a formula


MMDE

Recommended Posts

GraphPickup?key=7992198276817090209

You see the curves there? It means that for a given $y there could be three different $x values. What about that?

I know, but are you telling me I can't do what I'm trying to?

I've got help with workarounds for 2nd degree before, would it be better if I skipped the 3rd degree and just had 4th, 2nd and 1st? =o

Link to comment
https://forums.phpfreaks.com/topic/222161-help-with-a-formula/#findComment-1149405
Share on other sites

$x=5; // can be any positive number
echo 'x='.$x.'<br />';
$y=2*($x)*($x+2.5)*($x+10); // 2x^3 + 25x^2 + 50x
echo 'y='.$y.'<br />';
$a=2;
$b=25;
$c=50;
$d=-$y; // 2x^3 + 25x^2 + 50x + 0 - $y = 0
$x=pow((((-pow($b,3))/(27*pow($a,3)))+(($b*$c)/(6*pow($a,2)))-($d/(2*$a)))+sqrt(pow(((-pow($b,3))/(27*pow($a,3)))+(($b*$c)/(6*pow($a,2)))-($d/(2*$a)),2)+pow(($c/(3*$a))-((pow($b,2))/(9*pow($a,2))),3)),1/3)+pow((((-pow($b,3))/(27*pow($a,3)))+(($b*$c)/(6*pow($a,2)))-($d/(2*$a)))-sqrt(pow(((-pow($b,3))/(27*pow($a,3)))+(($b*$c)/(6*pow($a,2)))-($d/(2*$a)),2)+pow(($c/(3*$a))-((pow($b,2))/(9*pow($a,2))),3)),1/3)-($b/(3*$a));
echo 'x='.$x; // should echo the same as what you first assigned $x to be

 

Took me some time to write the cubic formula, but it was worth it, it worked!

Link to comment
https://forums.phpfreaks.com/topic/222161-help-with-a-formula/#findComment-1149536
Share on other sites

Archived

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

×
×
  • 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.