How can I write a code in PHP that will solve for x in this equation 1.2(x^3) - 15(x^2) + 100x - 140 = y In this case, y is the input and x is the output with the restriction of X: [1,100]
Example code for simple equation: <? set_time_limit(1000); #y $y=0; #x min $x=-100; $x_max=100; $array=array(); $equ=array(); #timestart $time=time(); while(true){ #Equation $ex=$x*$x-$x-2; if($ex==$y){ $equ[]=$x; } if($x==$x_max){break;} $x+=1; } print_r($equ); ?> Code (markup): Example code for your equation: <? set_time_limit(1000); #y $y=0; #x min $x=1; $x_max=100; $array=array(); $equ=array(); #timestart $time=time(); while(true){ #Equation $ex=1.2*($x*$x*$x)-15*($x*$x)+100*$x-140; if($ex==$y){ $equ[]=$x; } if($x==$x_max){break;} $x+=1; } print_r($equ); ?> Code (markup):
Post the equation in the form x = ..... and someone (me, if no one else) will give you the code for it. (We have to leave SOME work for you to do.)