Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • Your function works! Would you mind explaning what was your thought process when you were writing/thinking about it? Commented Aug 31, 2011 at 8:20
  • Your function is mathematically incorect. You're missing the case $y == $x && $z == $x. In such a case, the esemble R - { 1 } is solution of the equation. Commented Aug 31, 2011 at 8:49
  • Also, if i call eq(0, 0, 1);, your function yields -1, yet ((x * n) + y)/(n + 1) = z) gives ((0 * -1) + 0)/(-1 + 1) = 1) which is impossible Commented Aug 31, 2011 at 8:58
  • My get out clause is that my algebra is old and flakey and not something I use everyday. The main thing was to check for division by 0 (hence the check for Z<>X). My thinking behind the solution was to get the equation into the form of x*n=c (even if x is a fraction). Once it's in that form, the solution was a simple re-write of the equation into PHP Commented Aug 31, 2011 at 9:13
  • @pinouchon - obviously, more checks can be added for special cases. However, I'm a programmer and not a mathematician so my caveat is still valid - my algebra is old and flakey but I think this is right Commented Aug 31, 2011 at 9:21