Monday, January 2, 2012

3rd Order Runge-Kutta - HP 15C

This program uses a 3rd Order Runge-Kutta method to assist in solving a first order-differential equation.

Given the initial condition (x0, y0) to the differential equation:

dy/dx = f(x, y)

Find the value of y1 where h is a given step size (preferably small). The value of y1 is given by the following equations:

y1 = y0 + k1/4 + (3 * k3)/4

Where:
k1 = h * f(x0, y0)
k2 = h * f(x0 + h/3, y0 + k1/3)
k3 = h * f(x0 + (2 * h)/3, y0 + (2 * k2)/3)

Error estimated on the order of h^4

Source: Smith, Jon M. Scientific Analysis on the Pocket Calculator. John Wiley & Sons, Inc.: New York 1975 pg 174

Memory Registers Used

R0 = h
R1 = x
R2 = y
R3 = x1 (result)
R4 = y1 (result)
R5 = x0 (copied from R1)
R6 = y0 (copied from R2)
R7 = k1
R8 = k2
R9 = k3

Labels Used

Label A = Main Program
Label 0 = Program where equation is maintained

Instructions

1. Store h, x0, and y0 in memory registers R0, R1, and R2 respectively.
2. Enter or edit the equation in program mode using Label 0. Use RCL 1 for x and RCL 2 for y.
3. Run Program A. The first answer is x1. Press [R/S] for y1.
4. To find (x2, y2), store x1 in R1 and y1 in R2 and run Program A again. You can do this by pressing [STO] [ 2 ] [x<>y] [STO] [ 1 ] [ f ] [ √ ] (A) immediately following program execution.


There are 59 program steps in the main program.


Key Code
LBL A 42 21 11
RCL 1 45 1
STO 5 44 5
RCL+ 0 45 40 0
STO 3 44 3
RCL 2 45 2
STO 6 44 6
GSB 0 32 0
RCLx 0 45 20 0
STO 7 44 7
RCL 5 45 5
RCL 0 45 0
3 3
÷ 10
+ 40
STO 1 44 1
RCL 6 45 6
RCL 7 45 7
3 3
÷ 10
+ 40
STO 2 44 2
GSB 0 32 0
RCLx 0 45 44 0
STO 8 44 8
RCL 5 45 5
RCL 0 45 0
2 2
x 20
3 3
÷ 10
+ 40
STO 1 44 1
RCL 6 45 6
RCL 8 45 8
2 2
x 20
3 3
÷ 10
+ 40
STO 2 44 2
GSB 0 32 0
RCLx 0 45 20 0
STO 9 44 9
RCL 3 45 3
R/S 31
RCL 6 45 6
RCL 7 45 7
4 4
÷ 10
+ 40
RCL 9 45 9
3 3
x 20
4 4
÷ 10
+ 40
STO 4 44 4
RTN 43 32



Example 1

dy/dx = x^2 + sin(x * y)

Initial Conditions: (1, 1), let h = 0.01

Program for equation:

 
LBL 0
RAD
RCL 1
x^2
RCL 1
RCLx 2
SIN
+
RTN

Results:

x y
1.0000 1.0000
1.0100 1.0186
1.0200 1.0375
1.0300 1.0568


Example 2

dy/dx = x^3 * y - y

Initial Condition: (1,1); Step size h = 0.01

Program for the equation:
 
LBL 0
RCL 1
3
y^x
RCLx 2
RCL- 2
RTN

Results:

x y
1.0000 1.0000
1.0100 1.0002
1.0200 1.0006
1.0300 1.0014




This blog is property of Edward Shore. © 2012

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...