Slope of a secant line
Description
Write a program to calculate the slope of the secant line joining points (x1, y1) and (x2, y2) on a graph, where y = x2 - sin(x)
(given x in radians).
The secant slope is:
y2 - y1
———————
x2 - x1
or
(x22 - sin x2) - (x12 - 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 ENTER 1.25 GSB 9 → 1.1507
-1 ENTER 1 GSB 9 → -0.841
0.81 ENTER 0.98 GSB 9 → 1.1652
Program Resources
Labels
Name |
Description |
|
9 |
Start main program |
|
.3 |
Subroutine to evaluate x² - sin(x) |
|
Storage Registers
Name |
Description |
|
0 |
Save x2 |
|
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 x² |
|
015 |
43 36 |
g LSTΧ |
|
016 |
23 |
SIN |
|
017 |
30 |
− |
|
018 |
43 32 |
g RTN |
|