Sunday, November 26, 2023

DM42/HP 42S: Most Probable Position

DM42/HP 42S:  Most Probable Position



Introduction


The program MPP calculates an adjusted latitude (+N, -S) and adjusted longitude (+W, -E) of an observer:  


*  The latitude and longitude of the observer's dead reckoning.  

*  The computed altitude and azimuth (N = 0°, E = 90°, S = 180°, W = 270°).

*  The height of the sextant held by the observer.  


The most probable position is calculated by:


Calculated latitude:


LAT* = L - (Hc - H0) × cos(Z)


Calculated longitude:  


LON* = λ - ( (H0 - Hc) × sin(Z) ÷ cos(L) )


where


L =  dead reckoning latitude 

λ =  dead reckoning longitude

Hc = computed altitude of the celestial object

Z = zenith of the celestial object

H0 = correct sextant height


L, λ, Hc, H0 are customarily entered in degrees-minutes or degrees-minutes-seconds format.   The program MPP requires the four variables to be entered in L, λ, Hc, and H0 to be entered in DDMM.m format (see the Instructions section).  



Instructions


Soft menu items are enclosed in parenthesis.


1.  Enter the longitude and latitude in DDMM.m format.   DD represents decimal degrees, MM represents the integer part of minutes, and .m represents the fractional part of minutes.  


Examples:


Enter 52°00'  as 5200.


Enter 17°16.56' as  1716.56.


Enter the longitude, press [ENTER], enter the latitude, then press (LA/LO).   North longitude is positive, west latitude is positive.


2.  Enter the altitude of the reference object (star, planet, sun, other celestial object) in DDMM.m format, press [ENTER], the object's zenith in degrees, then press (HC/Z).  


3.  Enter the correct sextant height in DDMM.m format, press (>H0).  The altitude intercept (Hc - H0) is displayed in miles.  (negative is towards, positive is away)


4.  Press (CALC) to get the computed latitude (LAT*), press [ R/S ] to get the computed longitude (LNG*).  


To exit the program, press (EXIT).  



DM42/HP 42S/Free42/Plus Code:  Most Probable Position


00 { 234-Byte Prgm }

01▸LBL "MPP"

02 DEG

03 "MOST PROBABLE"

04 AVIEW

05 PSE

06 "POSITION, HP 65"

07 AVIEW

08 PSE

09 "DDMM.m, +N, +W"

10 AVIEW

11 PSE

12▸LBL 30

13 "LA/LO"

14 KEY 1 XEQ 21

15 "HC/Z"

16 KEY 2 XEQ 22

17 ">H0"

18 KEY 3 XEQ 23

19 "CALC"

20 KEY 4 XEQ 24

21 "EXIT"

22 KEY 6 XEQ 26

23 MENU

24▸LBL 00

25 STOP

26 GTO 00

27▸LBL 21

28 XEQ 31

29 STO 07

30 X<>Y

31 XEQ 31

32 STO 02

33 GTO 30

34▸LBL 22

35 STO 05

36 X<>Y

37 XEQ 31

38 STO 04

39 GTO 30

40▸LBL 23

41 XEQ 31

42 STO 06

43 RCL 04

44 X<>Y

45 -

46 STO 01

47 XEQ 32

48 GTO 30

49▸LBL 31

50 →HMS

51 100

52 ÷

53 →HR

54 RTN

55▸LBL 32

56 →HMS

57 100

58 ×

59 →HR

60 RTN

61▸LBL 24

62 RCL 02

63 RCL 05

64 COS

65 RCL× 01

66 -

67 STO 03

68 XEQ 32

69 "LAT*="

70 ARCL ST X

71 AVIEW

72 STOP

73 RCL 07

74 RCL 05

75 SIN

76 RCL× 01

77 RCL 02

78 COS

79 ÷

80 +

81 1

82 →REC

83 →POL

84 X<>Y

85 STO 08

86 XEQ 32

87 "LNG*="

88 ARCL ST X

89 AVIEW

90 PSE

91 GTO 30

92▸LBL 26

93 CLMENU

94 EXITALL

95 .END.



Download mpp.raw:  

https://drive.google.com/file/d/1Jrs14guVv3wuYEMuFRYDq4N3MGHrICxL/view?usp=sharing 



Example


Data Given:

Latitude:  30°44' N

Longitude:  128°36' W

Computed Altitude of star:  21°40'

Azimuth of the star:  61°

Corrected Sextant:  19°32'


Enter:

3044 ENTER 12836 (LA/LO)

2140 ENTER 61 (HC/Z)

1932 (>H0)   


(CALC)  

LAT*=2941.57  (29°41.57' N)

LNG*=13046.25  (130°46.25' W)



Source


Hewlett Packard.  "NAV 1-20A:  MOST PROBABLE POSITION"  HP-65 Navigation Pac 1 1974.  pp. 64-65, 137




Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, November 25, 2023

HP 15C, DM42, HP 27S: Floor and Ceiling Functions

HP 15C, DM42, HP 27S:   Floor and Ceiling Functions


(Updated on 12/22/2023 - see note below for the HP 15C versions)


Notes :


HP 15C: includes  HP 15C, Original, Limited, and Collector's Edition, and apps

DM42: includes HP 42S, DM42, Free42, Plus42




Introduction:  Floor and Ceiling Functions


The floor and ceiling functions are two common functions that transfers a number to an integer.   



Floor Function



Floor:   The greatest integer that is less than or equal to x.  A common symbol for floor is |_x_| and a function call is floor(x).


Let int(x) be the integer part function (sometimes labeled intg(x) or lp(x)), and frac(x) be the fractional part function (sometimes labeled fp(x)).


#  x is an integer

If frac(x) = 0, then return floor(x) =  x     


# x is not an integer

If x ≥ 0, then return floor(x) = int(x)

If x < 0, then return floor(x) = int(x) - 1


Per the function.wolfram.com web page: an equivalent using the modulus function for floor(x) is:


floor(x) = x - x mod 1


Examples:


floor(2.8) = 2

floor(6) = 6

floor(-2.8) = -3



Ceiling Function


Ceiling:  The least integer that is greater than or equal to x.  A common symbol for ceiling is |-x-| (except the horizontal lines are the top) and a function call is either ceil(x) or ceiling(x).  


#  x is an integer

If frac(x) = 0, then return ceil(x) =  x     


# x is not an integer

If x ≥ 0, then return ceil(x) = int(x) + 1

If x < 0, then return ceil(x) = int(x) 


Per the function.wolfram.com web page: an equivalent using the modulus function for floor(x) is:


ceil(x) = x + (-x) mod 1


Examples:

ceil(2.8) = 3

ceil(6) = 6

ceil(-2.8) = -2



Calculator Code:  HP 15C, DM 42, HP 27S



HP 15C


This program is NOT accurate for -1 < x < 0 (such as x = -0.5).  Gratitude to Werner for alerting me of this.  (12/22/2023)


Three labels are used:

D:  floor function

E:  ceiling function

1:  used in calculation for both  (roll stack down one extra time when frac(x)≠0)


step #:  key code : key


000:  42, 21, 14:  LBL D

001:  __, __, 36:  ENTER

002:  __, 42, 44:  FRAC

003:  __, 43, 20:  x=0

004:  __, 22, _1:  GTO 1

005:  __, __, 33:  R↓

006:  __, 43, 44:  INT

007:  43, 30, _3:  TEST 3  (x≥0)

008:  __, 43, 32:  RTN

009:  __, __, _1:  1

010:  __, __, 30:  -

011:  __, 43, 32:  RTN


012:  42, 21, 15:  LBL E

013:  __, __, 36:  ENTER

014:  __, 42, 44:  FRAC

015:  __, 43, 20:  x=0

016:  __, 22, _1:  GTO 1

017:  __, __, 33:  R↓

018:  __, 43, 44:  INT

019:  43, 30, _2:  TEST 2 (x<0)

020:  __, 43, 32:  RTN

021:  __, __, _1:  1

022:  __, __, 40:  +

023:  __, 43, 32:  RTN


024:  42, 21, _1:  LBL 1

025:  __, __, 33:  R↓

026:  __, 43, 32:  RTN






DM42/Free 42/HP 42S


00 { 16-Byte Prgm }

01▸LBL "FLOOR"

02 ENTER

03 ENTER

04 1

05 MOD

06 -

07 RTN

08 END


00 { 15-Byte Prgm }

01▸LBL "CEIL"

02 ENTER

03 +/-

04 1

05 MOD

06 +

07 RTN

08 .END.



HP 27S


FLOOR=X-MOD(X:1)


CEIL=X+MOD(-X:1)



Sources


Wolfram Research, Inc.   "Floor Function".  Path:  Integer Functions > Floor[z] > Representations through equivalent functions > With related functions.   Retrieved October 30, 2023.


https://functions.wolfram.com/IntegerFunctions/Floor/27/01/05/



Wolfram Research, Inc.   "Ceiling Function".  Path:  Integer Functions > Ceiling[z] > Representations through equivalent functions > With related functions.   Retrieved October 30, 2023.


https://functions.wolfram.com/IntegerFunctions/Ceiling/27/01/05/




Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, November 18, 2023

HP 32S and HP 15C: Synthetic Division

HP 32S and HP 15C:   Synthetic Division



These programs perform synthetic division, where a polynomial of degree n is divided by the binomial term x - x_0:


[a_n × x^n + a_(n-1) × x^(n-1) + a_(n-2) × x^(n-2) + ... a_1 × x + a_0] ÷ (x - x_0)


With the result of the division is:


[q_(n-1) × x^(n-1) + q_(n-2) × x^(n-2) + ... + q_1 × x + q_0] + R ÷ (x - x_0)


where: 


q_(n-1) = a_n

R is the remainder.



HP 32S/32SII:  Synthetic Division


The degree of the polynomial can go up to 24, with the variables set up as:


p(x) = [ A + B × x + C × x^2 + D × x^3 + ... + Y × x^24 ] ÷ (x - Z)


where

A is the constant

B is the coefficient of x

C is the coefficient of x^2 

and so on...

Z = x_0


Flag 1 is used as an indicator that there are coefficients q_k.  



Code:


S01  LBL S

S02  CF 1

S03  1

S04  +

S05  STO i

S06  SF 1

S07  RCL (i)

S08  STOP

S09  DSE i


Z01  LBL Z

Z02  RCL× Z

Z03  RCL+ (i)

Z04  STOP

Z05  DSE i

Z06  GTO Z

Z07  CF 1

Z08  RTN


Total Memory:  S:  13.5 bytes, Z:  12.0 bytes, Total:  25.5 bytes


To run:  store the coefficients and x0.  Enter the degree of the polynomial and press XEQ S.  



HP 15C:  Synthetic Division


The degree of the polynomial can go as high as you want, as long as you have registers.   The variables set up as:


p(x) = [ R0 + R1 × x + R2 × x^2 + R3 × x^3 + ... ] ÷ (x - R0)


where

R0 is the constant

R1 is the coefficient of x

R2 is the coefficient of x^2 

and so on...

R0 = x_0


Flag 8 is used as an indicator (C on the screen) that there are coefficients q_k.  In effect, this turns on complex mode, which would create a stack of imaginary numbers.  The complex mode for the HP 15C requires five registers to run.  


Code:


001  LBL A:   42,21,11

002  CF 8:  43, 5, 8

003  1:  1

004  +:  40

005  STO I:  44, 25

006  SF 8:  43, 4, 8

007  RCL (i):  45, 24

008  R/S:   31

009  DSE I:  42, 5, 25


010  LBL 0:  42, 21, 0

011  RCL× 0:  45, 20, 0

012  RCL+ (i):  45,40,24

013  R/S:  31

014  DSE I:  42, 5,25

015  GTO 0:  22, 0

016  CF 8:  43, 5, 8

017  RTN:  43,32


To run:  store the coefficients and x0.  Enter the degree of the polynomial and press GSB A.  



Examples



Example 1:  [ 4x^3 + 3x^2 + 2x - 5 ] ÷ [ x -  1 ]


HP 32S:

A:  -5,  B:  2,  C:  3,  D:  4,  Z:  1


HP 15C: 

R1:  -5,  R2:  2,  R3:  3,  R4:  4,  R0:  1


Degree: 3


3 XEQ S/GSB A:


Results:  

4   (x^2)  R/S

7   (x)   R/S

9   (constant)  R/S

4  (remainder)


4x^2 + 7x + 9 + 4 ÷ (x-1)



Example 2:  [ x^4 - 3x^2 + 6x + 3 ] ÷ [ x + 3 ]


HP 32S:

A:  3,  B:  6,  C:  -3, D:  0,  E:  1,  Z:  -3


HP 15C:

R1:  3,  R2:  6,  R3:  -3, R4:  0,  R5:  1,  R0:  -3


Degree:  4


4 XEQ S/GSB A


Results:

3   (x^3)  R/S

6   (x^2)  R/S

-3   (x)   R/S

0   (constant)  R/S

1  (remainder)


x^3 - 3x^2 + 6x - 12 + 39 ÷ (x + 3)



Example 3:  [ x^3 - 42x^2 + 395x + 966 ] ÷ [ x - 21 ]


HP 32S:

A:  966,  B:  395,  C:  -42,  D:  1,  Z:  21


HP 15C:

R1:  966,  R2:  395,  R3:  -42,  R4:  1,  R0:  21


Degree:  3


3 XEQ S/GSB A:


Results:  

1   (x^2)  R/S

-21   (x)   R/S

-46   (constant)  R/S

0 (remainder)


x^2 - 21x - 46



Source


Hewlett Packard.  "Synthetic Division"   HP-65 Math Pac 1.   September 1974.   pp. 34-35, 99




Next blog post:  November 25, 2023


Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, November 11, 2023

HP 42S/DM42 Programs in the Style of HP 65/67 Cards

HP 42S/DM42 Programs in the Style of HP 65/67 Cards


Programming Cards


In the 1970s, a programmable scientific calculators stored programs on magnetic cards.   The magnetic cards were then loaded on to calculator.   Two such calculators that used magnetic cards are the legendary HP 65 and HP 67, both from Hewlett Packard.    


The aim of these programs is to simulate classic programs from the HP 65 and HP 67 as they are stored on the cards, with prompts and messages to enhance the user experience.

The HP 65 had five user-definable keys A-E, while the HP 67 adds five additional user-defined labels a-e through a shift-key combination.

The MENU command on the HP 42S* creates a user key menu within a program, up to six keys.   I use this command to simulate running programs from loading cards.

(*and Free42, Plus42, Swiss Micros DM42)

The file included in the link below include four programs that are ported from various application books (pacs) of the HP 65 and HP 67.   


Demonstration Program:  demo.raw


When the program is run, a card is "simulated".   


I usually have the card in this format:

Left keys:  inputs, will sometimes give outputs

Key 4 (or 5): labeled CALC, get outputs

Key 6:  EXIT.  Exits the program.  Simulates removing the card.  


Demonstration


Key 1:  enter X coordinate

Key 2:  enter Y coordinate

Key 4:  calculate the norm

Key 6:  exit the program



Notes:  before GTO 30,  I have a pause command (PSE) so the menu returns.  

If I have multiple outputs, I have a stop command (STOP).  


Message convention: 

Prompts with a colon:  (:)  input

Prompts with an equals sign:  (=)  output


#  comments


00 { 134-Byte Prgm }

01▸LBL "DEMO"

02 "VECT NORM/ANG"         #  short description of the program

03 AVIEW

04 PSE                                        #  pauses the screen (allows for print)

05 "BY EWS"

06 AVIEW

07 PSE

08▸LBL 30                           # label 30 starts the menu

09 "→X"

10 KEY 1 XEQ 21

11 "→Y"

12 KEY 2 XEQ 22

13 "CALC"

14 KEY 4 XEQ 24

15 "EXIT"

16 KEY 6 XEQ 26

17 MENU                       # menu setup

18▸LBL 00

19 STOP

20 GTO 00                     # repeats the menu unless a menu key is pressed

21▸LBL 21                   # enter X

22 STO 01

23 "X:"

24 ARCL ST X   

25 AVIEW

26 PSE

27 GTO 30

28▸LBL 22                # enter Y

29 STO 02

30 "Y:"

31 ARCL ST X

32 AVIEW

33 PSE

34 GTO 30

35▸LBL 24            # calculate

36 RCL 02

37 RCL 01

38 →POL

39 "NORM="

40 ARCL ST X

41 AVIEW

42 STOP

43 "ANGLE="

44 ARCL ST Y

45 AVIEW

46 PSE

47 GTO 30

48▸LBL 26       # exit routine

49 CLMENU

50 EXITALL

51 .END.


Sample Output:


VECT NORM/ANG

BY EWS

X:5.7500

Y:6.8500

NORM=8.9434

ANGLE=49.9894


Program Space vs. Information Labels


When messages and alpha strings are added, along with the necessary AVIEW, PSE, and STOP commands, the program space requirements increase.   I put these messages to make the program as user friendly as possible.  



What's Included in the Zip Drive


Five programs:


Demonstration Program:  demo.raw

Sight Reduction Table:  str.raw

Physiologic Shunt and Fick:  phsy.raw

1-D Normal Shocks for Ideal Gases:  shock.raw

P and S Seismic Wave Velocity:  seismic.raw


PDF file of instructions and program listing



Download here (zip file):  

https://drive.google.com/file/d/1_0F_DHCGxcLbmCtrhMQbKShjrpBUgB7i/view?usp=share_link


Enjoy and please let me know, I plan to create another volume of these style of programs.  



Note:  The next blog entry will be on November 18, 2023


Eddie 


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Sunday, November 5, 2023

Retro Review: Sharp PC-1248

Retro Review:  Sharp PC-1248





Quick Facts


Model:  PC-1248

Company:  Sharp

Years:  circa 1986, years of production unknown

Type:  Scientific, Pocket Computer

Power:  2 x CR-2032 batteries

Display:  1 line, 16 characters

Programming Language:  BASIC

Memory:  7,422 bytes


Program and Run


The Sharp PC-1248 is a credit card sized BASIC pocket computer, which is stored in a slip on hard case.  The screen is one line, containing up to 16 characters.  


There is one program space, allowing for line numbers from 1 to 999.   The range of commands are adequate for general mathematical applications.  


There are several peripherals available for PC-1248, including a printer and a cassette tape recorder to save and load programs.


Sharp also produced the PC-1246S pocket computer around the same time, only with memory capacity of 1,278 bytes.  


PC-1248 vs EL-5500 III




The PC-1248 operates similarly to the Sharp EL-5500 III pocket calculator; though it lacks the statistics mode and matrix operations.    I reviewed the EL-5500 III in 2017:  https://edspi31415.blogspot.com/2017/01/retro-review-sharp-scientific-computer.html



Keyboard:  It Could Have Been Better


To be honest, the keys are pretty hard to press.   I used a q-tip to press the keys at first when a soft-like stylus did not work.  However, the keys does have button under the keyboard.  This is the biggest complaint I have with the PC-1248.



Final Thoughts


I like the form factor of the PC-1248, and the command set is good for quick calculations on the run.   The computer is to the point, basic programming.   As I mentioned, the keys could have been better.   



Sample Programs for the PC-1248


Math Statement Builder: RUN 40


40 PAUSE "MATH STMT BUILD"

42 A = RND 21-1

44 B = RND 21-1

46 C = RND 21-1

48 D = A*B+C

50 PRINT A; "*"; B; "+''; C; "="; D:  END


Examples:  (results will vary)


4. * 3. + 7. = 19.


13. * 16. + 2. = 210.


2. * 8. + 3. = 19.


Net Present Value: RUN 60


60 PAUSE "NET PRESENT VALUE": CLEAR

62 INPUT "CF0:"; N, "RATE:"; I

64 J=1

66 INPUT "FLOW:"; F, "FREQ:"; K

68 FOR L=1 TO K: N=N+F/(1+I/100)^J: J=J+1

70 NEXT L

72 INPUT "MORE=1"; L

74 IF L=1 THEN 66

76 PRINT USING "########.##"; "NPV:"; N

78 END


Examples:


CF0:  -5000

CF1:   3000, frequency 1

CF2:  6000, frequency 1

Rate: 3%


Result:  NPV = 3568.20


CF0: -5000

CF1: 500, frequency 12

CF2:  0, frequency 6

CF3:  1000, frequency 6

Rate:  2.95%


Result:  NPV = 3207.18 



Future Value:  Continuing Compound Interest:  RUN 110


110 PAUSE "FV - CONT. CMPD. INT.": CLEAR

112 INPUT "PV? "; P

114 INPUT "RATE? "; R:  R=R/100

116 INPUT "YEARS? "; T

118 F=P*EXP(R*T)

120 PRINT USING "########.##"; "FV = "; F

122 END


Examples:


P = 5000, R = 5, T = 5.   Result:  F = 6420.12


P = 1000, R = 6, T = 20.  Result:  F = 3320.11


Source


"The Sharp PC-1246 computer":  http://pocket.free.fr/html/sharp/pc-1246s_e.html

"The Sharp PC-1248 computer": http://pocket.free.fr/html/sharp/pc-1248_e.html

The pocket computer museum.   1999-2022.  

Retrieved October 12, 2023.  


Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, November 4, 2023

HP 15C and Casio fx-9750GIII: Solving Recurrence Relations

HP 15C and Casio fx-9750GIII:   Solving Recurrence Relations


Introduction


The following program attempts to find a closed-form formula to the recurrence relation:


(I)

a_n + P × a_n-1 + Q × a_n-2 = 0


or 


(II)

a_n = -P × a_n-1 + -Q × a_n-2


Without loss of generality, usually P and Q in the latter form (II) are presented as positive constants.  


Two initial conditions are provided, a_0 and a_1 (where n = 0 and n = 1, respectively).  


Equation (I) can be transformed into the characteristic equation:


x^2 + P × x + Q = 0


where the roots are:


x = ( -P ± √(P^2 - 4 × Q)) ÷ 2


and the roots are x = S and x = T.  Assume that the roots S and T are real numbers.


If S ≠ T, the solution is in the form of:


a_n = B × S^n + C × T^n


where B and C are determined by the equations:

a_0 = B + C

a_1 = B × S + C × T


If S = T, the solution is in the form of:


a_n = B × S^n + C × n × S^n


where B and C are determined by the equations:

a_0 = B

a_1 = S × (B + C)




HP 15C:  Solving Recurrence Relations 


Store values to the following registers:


R1 = P 

R2 = Q

R3 = I 

R4 = J


Output registers:


R5 = S

R6 = T

R7 = B

R8 = C


Code:

Step :  Key :  Code


001 :  LBL A :  42,21,11    (solve for S, T)

002 :  RCL 1 :  45,1

003 :  x^2 :  43,11

004 :  4  :   4

005 : RCL× 2 : 45,20, 2

006 : - :  30

007 : √  : 11

008 : STO 0 : 44, 0

009 : RCL- 1 : 45,30, 1

010 : 2 : 2

011 : ÷ : 10

012 : STO 5 : 44, 5

013 : RCL- 0 : 45,30, 0

014 : STO 6 : 44, 6

015 : RCL 5 : 45, 5

016 : TEST 6 : 43,30, 6  (x ≠ y)

017 : GTO 1 : 22, 1


018 : RCL 3 : 45, 3  (if S = T, solve for B, C)

019 : STO 7 : 44, 7

020 : RCL 4 : 45, 4

021 : RCL 5 : 45, 5

022 : RCL× 7 : 45,20, 7

023 : - : 30

024 : RCL÷ 5 : 45,10, 5

025 : STO 8 : 44, 8

026 : GTO 2 : 22, 2


027 : LBL 1 : 42,21, 1  (if S≠T, solve for B, C)

028 : RCL 6 : 45, 6

029 : RCL× 3 : 45,20, 3

030 : RCL- 4 : 45,30, 4

031 : RCL 6 : 45, 6

032 : RCL- 5 : 45,30, 5

033 : ÷ : 10

034 : STO 7 : 44, 7

035 : RCL 5 : 45, 5

036 : CHS : 16

037 : RCL× 3 : 45,20, 3

038 : RCL+ 4 : 45,40, 4

039 : RCL 6 : 45, 6

040 : RCL- 5 : 45,30, 5

041 : ÷ : 10

042 : STO 8 : 44, 8


043 : LBL 2 : 42,21, 2 (view results)

044 : RCL 7 : 45, 7

045 : R/S : 31

046 : RCL 5 : 45, 5

047 : R/S : 31

048 : RCL 8 : 45, 8

049 : R/S : 31

050 : RCL 6 : 45, 6

051 : RTN : 45, 32


Casio fx-9750GIII Program: RCHAR


Text file listing:


'ProgramMode:RUN

"2023_-_09_-_26 EWS"

ClrText

"SOLVE"

"A(N) _+_ P_*_A(N_-_1) "

"_+_ Q_*_A(N_-_2) = 0"

"P"?->P

"Q"?->Q

"A(0)"?->I

"A(1)"?->J

(-P+Sqrt(P^<2>-4Q))/2->S

(-P-Sqrt(P^<2>-4Q))/2->T

If S<>T

Then 

(T*I-J)/(T-S)->B

(-S*I+J)/(T-S)->C

ClrText

Locate 1,3,"B_*_S_^_N _+_ C_*_T_^_N"

Else 

I->B

(J-S*B)/S->C

ClrText

Locate 1,3,"B_*_S_^_N _+_ C_*_N_*_T_^_N"

IfEnd

Locate 1,4,"B="

Locate 4,4,B

Locate 1,5,"S="

Locate 4,5,S

Locate 1,6,"C="

Locate 4,6,C

Locate 1,7,"T="

Locate 4,7,T



Notes:  

This is the text file from Casio fx-9750GIII.  

_:  space

->:  store  (→)

^<2>:  ^2

Sqrt:  √

<>: ≠


Examples


1.  a_n - 11 × a_n-1 + 24 = 0,  a_0 = 3, a_1 = 8


Characteristic Equation:  x^2 - 11x + 24 = 0


Roots:  S = 3, T =-8


Different Roots


3 = B + C

8 = 3 × B - 8 × C


B = -0.2, C = 3.2


Solution:


a_n = -0.2  × 8^n + 3.2 × 3^n



2.  a_n + 6 × a_n-1 + 9 × a_n-2 = 0, a_0 = 2, a_ 11


Characteristic Equation:  x^2 + 6x + 9 = 0


Roots:  S = T = -3


Same Roots


2 = B 

10 = -3 × (B + C)


B = 2, C = -16/3 ≈ -4.3333


Solution:


a_n = 2 × (-3)^n - 16/3 × n × (-3)^n



3.  a_n - 6 × a_n-1 + 4 × a_n-2 = 0, a_0 = 1, a_1 = 15


Characteristic Equation:  x^2 - 6x + 4 = 0


Roots:  

S = 3 + √5 ≈ 5.236067977

T = 3 - √5 ≈ 0.7639320225


Different Roots


1 = B + C

15 = (3 + √5) × B - (3 - √5) × C


B ≈ 3.183281573

C ≈ -2.183281573


Solution:


a_n ≈

3.183281573 × 5.236067977^n - 2.183281573 × 0.7639320225^n



Source


Levin, Oscar.  "2.4 Recurrence Relations"  Discrete Mathematics: An Open Introduction  openmathbooks.org  University of Northern Colorado.   Retrieved August 30, 2023.  https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Discrete_Mathematics_(Levin)/2%3A_Sequences/2.4%3A_Solving_Recurrence_Relations


Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.