MMDE Posted December 19, 2010 Share Posted December 19, 2010 ey, I'm kind of stuck atm... $x=variable; $y=($x*pow(2*$x,2))+($x*50); $x=formula; echo $x; should output the variable so anyone who can help me with the formula? Link to comment https://forums.phpfreaks.com/topic/222161-help-with-a-formula/ Share on other sites More sharing options...
MMDE Posted December 20, 2010 Author Share Posted December 20, 2010 I changed my mind... this instead: 2*($x)*($x+2.5)*($x+10); $x=variable; $y=2*($x)*($x+2.5)*($x+10); $x=formula using $y to calculate unknown $x; echo $x; $x should be the same as what I first assigned it to be. Link to comment https://forums.phpfreaks.com/topic/222161-help-with-a-formula/#findComment-1149398 Share on other sites More sharing options...
requinix Posted December 20, 2010 Share Posted December 20, 2010 You see the curves there? It means that for a given $y there could be three different $x values. What about that? Link to comment https://forums.phpfreaks.com/topic/222161-help-with-a-formula/#findComment-1149402 Share on other sites More sharing options...
MMDE Posted December 20, 2010 Author Share Posted December 20, 2010 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 More sharing options...
MMDE Posted December 20, 2010 Author Share Posted December 20, 2010 Forgot to say, and might be very important, though very obvious... the variable is always going to be positive... and if you look at the numbers, you will see all the nulls are negative except for one, which is 0. Link to comment https://forums.phpfreaks.com/topic/222161-help-with-a-formula/#findComment-1149476 Share on other sites More sharing options...
MMDE Posted December 20, 2010 Author Share Posted December 20, 2010 $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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.