The Museum of HP Calculators

# Numerical Integration, Simpson's Rule for the HP-33E/C

This program is Copyright © 1978 by Hewlett-Packard and is used here by permission. This program was originally published in "HP-33E Mathematics Applications".

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

Let x0, x1, . . ., xn be equally spaced points such that xi = x0 + ih for i = 1, 2, . . ., n at which corresponding values f(x0), f(x1), . . ., f(xn) of the function f(x) are known. The function itself need not be known explicitly but if it is, these values can be found previously by writing the function into memory and evaluating at the various points. n must be an even positive integer.

(x0..xn)f(x) dx ~ h/3[f(x0) + 4f(x1) + 2f(x2) + ... + 4f(xn-3) 2f(xn-2) + 4f(xn-1) +f(xn)]

Let the solution be indicated by I.

## Instructions

 Step Instructions Input Data/Units Keys Output Data/Units 1 Enter program 2 Store increment h STO 0 3 Enter first function value f(x0) GSB 01 Partial sum 4 Enter last function value f(xn) R/S Partial sum 5 Enter values i = 1, 2, ..., n-2 f(xi) R/S Partial sum 6 Enter value i = n-1 f(xn-1) R/S I

## Example

Compute (0..pi) sin2 x dx using Simpson's rule with h = pi/8.

The following data must be found first:
 i 0 1 2 3 4 5 6 7 8 xi 0 pi/8 pi/4 3pi/8 pi/2 5pi/8 3pi/4 7pi/8 pi f(xi) 0 0.1464 0.5 0.8536 1 0.8536 0.5 0.1464 0

Solution:
(0..pi) sin2 x dx ~ 1.5708

```Keystrokes          Display
g pi 8 ÷ STO 0
0 GSB 01            0.0000
0 R/S               0.0000
0.1464 R/S 0.5
R/S 0.8536 R/S 1
R/S 0.8536 R/S
0.5 R/S 0.1464 R/S  1.5708
```

## The Program

```LINE    CODE    KEYS
00             f CLEAR PRGM
01     24  3   RCL 0
02         3   3
03        71   ÷
04     23  0   STO 0
05        61   x
06     23  1   STO 1
07        74   R/S
08     12 18   GSB 18
09        74   R/S
10         4   4
11        61   x
12     12 18   GSB 18
13        74   R/S
14         2   2
15        61   x
16     12 18   GSB 18
17     13 09   GTO 09
18     24  0   RCL 0
19        61   x
20  23 51  1   STO + 1
21     24  1   RCL 1
22     15 12   g RTN
```

## Register Use

```R0  h/3
R1
```