*The Museum of HP Calculators*

#
Quadratic Equation: Real and Complex Solutions for the HP-33S

This program is by Eddie Shore and is used here by permission.

This program is supplied without representation or warranty of any kind.
Eddie Shore and The Museum of HP Calculators therefore assume no responsibility
and shall have no liability, consequential or otherwise, of any kind arising
from the use of this program material or any part thereof.

##
Overview

This program solves the equation: Ax^2 + Bx + C = 0
x can be either real or complex solutions. This program uses one label (Q) and seven variables (A,B,C,D,E,F,G). Comments of entering the program will be noted on the program line.

To use: XEQ Q, enter A, R/S, enter B, R/S, enter C, R/S; the HP-33S displays the first root, note it (store if you wish), then press R/S for the second root. The root is complex if Flag 1 is set (flag 1 is a user flag).

Roots = -B/(2A) +- SQRT(B^2-4AC)/(2A)

I wrote this program on the HP 33S, but it should work with the 32S series as I understand the 33S is built on the 32S software.

##
Listing

Q0001 LBL Q ' Set label Q
Q0002 INPUT A
Q0003 INPUT B
Q0004 INPUT C
Q0005 SQ(B)-4xAxC ' Equation (enter by RS [right shift] EQN)
Q0006 STO D
Q0007 RCL D ' Is the discriminant negative?
Q0008 x<0?
Q0009 SF 1 ' Flag 1 - indicate that the roots are complex
Q0010 RCL D
Q0011 FS? 1
Q0012 +/- ' The HP 33 can not take square roots of x<0
Q0013 square root
Q0014 STO E ' E = abs(sqrt(D))
Q0015 -B/(2xA) ' enter this as an equation
Q0016 STO F
Q0017 E/(2xA) ' enter this an an equation
Q0018 STO G
Q0019 RCL G
Q0020 0
Q0021 FS? 1
Q0022 x<>y
Q0023 RCL F
Q0024 0
Q0025 CMPLX+
Q0026 STOP ' press the R/S key: display first root
Q0027 RCL G
Q0028 +/-
Q0029 0
Q0030 RS? 1
Q0031 x<>y
Q0032 RCL F
Q0033 0
Q0034 CMPLX+
Q0035 STOP
Q0036 CF 1 ' clean up command
Q0037 RTN
Checksum = 7F5B; Lines = 185

Go back to the software library

Go
back to the main exhibit hall