PHP Solve Parabolic Equation

Discussion in 'PHP' started by esgllcinc, Oct 13, 2012.

  1. #1
    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]
     
    Solved! View solution.
    esgllcinc, Oct 13, 2012 IP
  2. G.N.C.

    G.N.C. Member

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #2
    Brute-force search?
     
    G.N.C., Oct 13, 2012 IP
  3. esgllcinc

    esgllcinc Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No, it is for calculating level based on experience point. I am developing a gaming site.
     
    esgllcinc, Oct 13, 2012 IP
  4. esgllcinc

    esgllcinc Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Y is the experience point, and X is the level
     
    esgllcinc, Oct 13, 2012 IP
  5. G.N.C.

    G.N.C. Member

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #5
    What is the range of a Y?
     
    G.N.C., Oct 13, 2012 IP
  6. esgllcinc

    esgllcinc Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Y [0, 1059860]
     
    esgllcinc, Oct 13, 2012 IP
  7. G.N.C.

    G.N.C. Member

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #7
    This equation has no solutions
     
    G.N.C., Oct 13, 2012 IP
  8. #8
    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):
     
    G.N.C., Oct 14, 2012 IP
  9. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #9
    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.)
     
    Rukbat, Oct 14, 2012 IP
  10. esgllcinc

    esgllcinc Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thank you! One question, how can i add the input y into the code.
     
    esgllcinc, Oct 25, 2012 IP