## Sunday, December 18, 2011

### HP 15C Programming Tutorial - Part 15: Memory Exchange (Area of a Polygon)

Memory Exchange

We will introduce another powerful feature of the HP 15C: memory exchange. This will allow the user to exchange the contents of the X register with a designated memory register.

Key strokes: [ f ] [ 4 ] (x > <)

Example: Store 2 in memory register 5. Call the constant π and exchange it with the contents of memory register 5.

Key strokes:
2 [STO] 5 (Display: 2.0000)
[ g ] [EEX] ( π ) (Display: 3.1416)
[ f ] [ 4 ] (x > <) 5 (Display: 2.0000) - now π in in R5
Check: [RCL] [ 5 ] (Display: 3.1416)

We will use this in a program.

Area of a Polygon with Transverse Coordinates

This program calculates the area of a polygon which vertices are given by (x,y) coordinates by the approximation:

R ≈ 0.5 × abs(∑(y_i * x_i+1 - y_i+1 * x_i, i = 0, n-1))

In geographic terms:

`          |  y > 0, North          |          |x< 0,     |West      |       ---------------------------          |    x > 0, East          |          |          |          |   y < 0, South`

Labels Used:
LBL A - Initialize the program and enters the initial coordinates
LBL B - Enters additional coordinates
LBL C - Calculates area

Memory Registers Used:
R0 = Area
R1 = x_i
R2 = y_i
R3 = x_i+1
R4 = y_i+1
R5 = temporary use
R6 = temporary use

Program:
`KEY CODES			KEYS001	42	21	11	LBL A002			0	0003		44	5	STO 5004		44	6	STO 6005			33	R ↓ 006		44	1	STO 1007			34	x<>y008		44	2	STO 2009			2	2010		43	32	RTN011	42	21	12	LBL B012		44	3	STO 3013			34	x<>y014		44	4	STO 4015			34	x<>y016	45	20	2	RCLx 2017	44	40	6	STO+ 6018		45	4	RCL 4019	45	20	1	RCLx 1020	44	40	5	STO+ 5021		45	3	RCL 3022	42	4	1	x<>1	* Exchange X with R1023		45	4	RCL 4024	42	4	2	x<>2	* Exchange X with R2025		43	32	RTN026	42	21	13	LBL C027		45	5	RCL 5028	45	30	6	RCL- 6029		43	16	ABS030			2	2031			10	÷032		44	0	STO 0033		43	32	RTN`

Instructions:

1. Enter the initial y coordinate, hit [ENTER], the initial x coordinate, and press [ f ] [ √ ] (A).
2. For the additional points, enter the y coordinate, press [ENTER], enter the x coordinate, and the [ f ] [e^x] (B).
3. To calculate the area, press [ f ] [10^x] (C).

Example:

Find the area of the polygon with the following vertices:
(0, 0)
(4, 4)
(0, 8)
(-2, 8)
(-3, -1)

Key Strokes:

0 [ENTER] 0 [ f ] [ √ ] (A)
4 [ENTER] 4 [ f ] [e^x] (B)
8 [ENTER] 0 [ f ] [e^x] (B)
8 [ENTER] 2 [CHS] [ f ] [e^x] (B)
1 [CHS] [ENTER] 3 [CHS] [ f ] [e^x] (B)
[ f ] [10^x] (C)

Area = 37

I hope you find this program useful and fun. Until next time,

Eddie

This tutorial is property of Edward Shore. © 2011

### Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation The HP 16C’s #B Function The #B function is the HP 16C’s number of...