The quadratic formula is $$\frac{-b\pm\sqrt{b^2-4ac}}{2a}$$
I tried converting this to RPN; I am new to doing this, and I have thus: b-ac*4*-b2^+±a2*/. Am I correct?
Edit 1: Forgot the radical.
b-ac*4*-b2^+ña2/
The quadratic formula is $$\frac{-b\pm\sqrt{b^2-4ac}}{2a}$$
I tried converting this to RPN; I am new to doing this, and I have thus: b-ac*4*-b2^+±a2*/. Am I correct?
b-ac*4*-b2^+ña2/
Since someone brought up a tree, I'll add an answer, which is less of an answer and more of a discussion. If I was trying to write this from "left-to-right" (which I cannot and will not try to define), I would probably do the following (things inside parenthesis are functions):
b(neg)b2(y^x)4ac**-√(+/-)2a*/Which gives the following tree:
Another way could be to start inside the square root:
b2(y^x)4a*c*-√b(neg)(+/-)2a*/Which gives the following (equivalent) tree:
And a slightly different tree could be:
I would argue that the last tree is probably the "best" (even though they are all equivalent)...think in terms of the how large the stack needs to be in each case.
p.s. The $\pm$ needs different meanings, but I'm trying to compactly represent two different calculations--the $+$ is fine in the last two cases, but the $-$ requires a negation and then an add (in the last two cases)--this is because addition is commutative but subtraction is not.