in reply to Re^2: Reverse Polish Notation Question
in thread RPN Question
As for the first comment, we have a first degree equation, so, yes, I assumed a straight line on that specific condition, although I was more broadly trying to implement a more general solution.
For your second comment, yes, you are absolutely right, calculating the slope would far easier, especially for a linear equation, and I would not even need to painfully consider whether the various calculated values are positive or negative. And even for a polynomial equation, say second or third degree, calculating the slope would narrow down faster on the solution (something similar to the Newton-Raphson method).
My error was to initially think it could be done in 15 minutes and 20 lines of code, so I started to code something without carefully thinking of the problem, and discovered only when doing it that it was more complicated than I thought. If I have time this weekend, I'll try to come up with a better design.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Reverse Polish Notation Question
by hdb (Monsignor) on May 02, 2015 at 14:55 UTC | |
by Laurent_R (Canon) on May 02, 2015 at 22:13 UTC | |
by Laurent_R (Canon) on May 02, 2015 at 17:44 UTC |