HP Forums

Full Version: (35S ALG) Quadratic Equation Solver (with complex solutions support)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Based on this article:
http://www.hpmuseum.org/cgi-sys/cgiwrap/...?read=1003

It is a simple program using the traditional quadratic root formula:
$$\frac{-b±\sqrt{b^{2}-4ac}}{2a}$$

the program is converted for use in ALG mode:

Code:

Q001 LBL Q
Q002 CF 10
Q003 INPUT A
Q004 INPUT B
Q005 INPUT C
Q006 -B÷(2×A)       ;the first - is the +/- key
Q007 LASTx STO R    ;LASTx is blue ENTER, a black > will show instead of STO
Q008 B^2-4×A×C      ;using y^x instead of x^2
Q009 x>=0?
Q010 GTO Q015
Q011 -LASTx         ;press +/- key followed by LASTx
Q012 SQRT(LASTx)
Q013 i×LASTx
Q014 GTO Q016
Q015 SQRT(LASTx)
Q016 LASTx÷(2×A)
Q017 R+LASTx
Q018 R-REGY         ;for REGY press Roll Down (E-key) & if necessary underline Y
Q019 RTN

Press x<>y to see the other root.

In RPN mode the 35s will dispay 2 lines, thus both roots.
In ALG mode only one line is displayed. After running the program, use x<>y to swap between roots.
Reference URL's