Slope of a secant line

Description

HP-15C Owner's Handbook - Pages 102-103

Write a program to calculate the slope of the secant line joining points (x1, y1) and (x2, y2) on a graph, where y = x² - sin(x) (given x in radians).
The secant slope is:

y2 - y1
-------
x2 - x1

or

(x2² - sin x2) - (x1² - sin x1)
-------------------------------
x2 - x1

The program assumes that x1 has been entered into the Y-register and x2 into the X-register.

Example results:
0.52, 1.25 : 1.1507
-1, 1 : -0.841
0.81, 0.98 : 1.1652

Program Resources

Labels

Name Description
 9 Start main program
.3 Subroutine to evaluate x² - sin(x)

Storage Registers

Name Description
 0

Program

Line Display Key Sequence
000
001 42,21, 9 f LBL 9
002 43 8 g RAD
003 44 0 STO 0
004 34 x↔y
005 44,30, 0 STO 0
006 32 .3 GSB . 3
007 16 CHS
008 34 x↔y
009 32 .3 GSB . 3
010 40 +
011 45,10, 0 RCL ÷ 0
012 43 32 g RTN
013 42,21, .3 f LBL . 3
014 43 11 g
015 43 36 g LSTx
016 23 SIN
017 30
018 43 32 g RTN