Jessica Posted April 30, 2012 Share Posted April 30, 2012 y = x*(x-1)*5; Given $y, calculate $x. I can get this far, it's been so long since I took a math class that I'm not even sure this makes sense. y/5 = x*(x+1) (y/5)/x = x+1 ((y/5)/x)-1 = x My problem is: Given $y = 60, how do I get $x = 4 (using php) 60 = x*(x-1)*5; 12 = x*(x-1); 12/x = x-1 (12/x)+1 = x And I'm stuck. (I know $x = 4 because I made a spreadsheet plugging in 1-100 as x and then getting y, so where x = 4 y = 60) Quote Link to comment Share on other sites More sharing options...
xyph Posted April 30, 2012 Share Posted April 30, 2012 I'd tell you to expand the brackets, then solve, but we're on the internet here. http://www.wolframalpha.com/input/?i=y+%3D+x*%28x-1%29*5 -5x²+5x+y = 0 Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 30, 2012 Author Share Posted April 30, 2012 I don't get how that gives me x? I see on wolfram alpha the two alternate forms but neither gives you x when you know y I want to write a calculation in PHP that if I say I have 60 for y, it can tell me x = 4. Or y=100, and it tells me x = 5. And so on. If I give it 80 it should calculate for x and then round down to 4 but I can handle that part Quote Link to comment Share on other sites More sharing options...
xyph Posted April 30, 2012 Share Posted April 30, 2012 x will have two values for any given y, generally. Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 30, 2012 Author Share Posted April 30, 2012 Ah, I get it. hence the parabola. Thanks Is there any mathematical way to determine the positive value? Probably not... Quote Link to comment Share on other sites More sharing options...
kicken Posted April 30, 2012 Share Posted April 30, 2012 http://www.wolframalpha.com/input/?i=y+%3D+x*%28x-1%29*5+solve+for+x Neat tool that wolfram alpha is. I should use that more. Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 1, 2012 Author Share Posted May 1, 2012 http://www.wolframalpha.com/input/?i=y+%3D+x*%28x-1%29*5+solve+for+x Neat tool that wolfram alpha is. I should use that more. Seriously. I am bookmarking that site, I'd heard of it but never used it before. You guys rock. So let's see in PHP this would be... <?php $y = 60; $x = .1*((sqrt(5)*sqrt((4*$y)+5))+5); echo $x; ?> And it echoed 4. Perfect!! Quote Link to comment Share on other sites More sharing options...
phpdevelopers Posted September 27, 2012 Share Posted September 27, 2012 It was really a helpful content. Keep sharing… Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted September 27, 2012 Share Posted September 27, 2012 (edited) If you don't want to be big fat cheaters, the way to do this on paper is to use the quadratic formula For this equation, it's as easy as: y = x*(x-1)*5; y = 5x^2 - 5x; //jesi, you messed up here by moving X back to both sides of the equation. Don't do that 0 = 5x^2 - 5x - y; //everything has to equal zero //here, we substitute Jesi's value for Y and use the Quadratic Formula x = (5 +/- sqrt(25 - 4 * 5 * -60)) / 10; x = (5 +/- 35) / 10; x = 4,3; The parabola formed by the equation cuts the Y axis at 4 and 3. Both are valid answers, but only the larger one satisfies the original equation. Also, I just now noticed this thread is 6 months old and newbie here bumped it, but I did all the math so you're getting the post anyway. Edited September 27, 2012 by ManiacDan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.