The Museum of HP Calculators


Quadratic Equation for the HP-25

This program is Copyright © 1975 by Hewlett-Packard and is used here by permission. This program was originally published in "HP-25 Applications Programs".

This program is supplied without representation or warranty of any kind. Hewlett-Packard Company 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

The roots x1, x2 of   ax2 + bx +c = 0

are given by  x1,2 = (-b ± √(b2 - 4ac))/2a

If  D = (b2 - 4ac)/4a2

is positive or zero, the roots are real. In these cases, better accuracy may sometimes be obtained by first computing the root with the larger absolute value:

If  -b/2a ≥ 0,  x1 = -b/2a + √(D)

If  -b/2a < 0,  x1 = -b/2a - √(D)

In either case, x2 = c/( x1 a).

If D<0, the roots are complex, being

u ± iv = -b/2a ± (√(4ac-b2)/2a)×i

Instructions

Step Instructions Input Data/Units Keys Output Data/Units
1 Enter program      
2 Initialize   f PRGM  
3 Enter coefficients and display D c ENTER↑  
    b ENTER↑  
    R/S (D) (pause)
4 If D ≥ 0, roots are real     x1
       R/S  x2
     or       
  If D < 0, roots are complex of form u ± iv    
      R/S v
5 For new case, go to step 3      

Example

Find the solution to x2 + x - 6 = 0.

Press f PRGM to initialize. Key 6, CHS, ENTER, 1, ENTER, 1, and press R/S. D's value of 6.25 flashes on the display indicating real roots followed by the first root: -3. Pressing R/S displays the 2nd root: 2.

The Program

LINE    CODE    KEYS
 00
 01        31   ENTER↑
 02        22   R↓
 03        71   ÷
 04        02   2
 05        71   ÷
 06        32   CHS
 07        31   ENTER↑
 08     15 02   g x2
 09        22   R↓
 10        22   R↓
 11        21   x⇔y
 12        71   ÷
 13     23 00   STO 0
 14        41   -
 15     14 74   f PAUSE
 16     15 41   g x<0
 17     13 31   GTO 31
 18     14 02   f √x
 19        21   x⇔y
 20     15 41   g x<0
 21     13 24   GTO 24
 22        51   +
 23     13 26   GTO 26
 24        21   x⇔y
 25        41   -
 26        74   R/S
 27     15 22   g 1/x 
 28     24 00   RCL 0 
 29        61   x  
 30     13 00   GTO 00 
 31        32   CHS
 32     14 02   f √x
 33        21   x⇔y
 34        74   R/S
 35        21   x⇔y
 36     13 00   GTO 00

Register Use

R0  c/a

Go back to the software library
Go back to the main exhibit hall