12-07-2019, 04:21 PM
Euler-Taylor method
===================
To integrate f'(x,y) from x=a to x=b, give y(a), we use an extended version of the Euler method that includes the first AND second derivatives. Since we know f'(x,y) we can derive f''(x,y) and use the following formula:
y = y + h*f'(x,y) + h^2/2*f''(x,y)
Memory Map
==========
LABELS
======
A - Main routine.
B - calculate first derivative f'(x,y).
C - calculate second derivative f''(x,y).
E - calculate exact f(x,y) (used for results comparison). If the exact solution is not known, then just have the label just return a value like 0 or insert "N/A" into register X.
Listing
=======
Usage
=====
1. Run the program using XEQ "ELRTLR" or pressing key [A].
2. Program prompts "A/^B?". Key in the value for a, press [ENTER], key in the value for b, and then press [R/S] key.
3. Program prompts "Y/^H?". Key in the value for y(a), press [ENTER], key in the value for increment h, and then press [R/S] key.
4) Program displays intermediate values of the integrated y. The program stops with the calculated value of y at x=b.
5) Press [X<>Y] to view the exact value of y at x=b.
You calculate the value for y at any value of x by entering the value of x and the pressing the [E] key.
===================
To integrate f'(x,y) from x=a to x=b, give y(a), we use an extended version of the Euler method that includes the first AND second derivatives. Since we know f'(x,y) we can derive f''(x,y) and use the following formula:
y = y + h*f'(x,y) + h^2/2*f''(x,y)
Memory Map
==========
Code:
R00 = a,x
R01 = b
R02 = h
R03 = y
R04 = nsteps
R05 = used
LABELS
======
A - Main routine.
B - calculate first derivative f'(x,y).
C - calculate second derivative f''(x,y).
E - calculate exact f(x,y) (used for results comparison). If the exact solution is not known, then just have the label just return a value like 0 or insert "N/A" into register X.
Listing
=======
Code:
1 LBL "EULTLR"
2 LBL A
3 A/^B?
4 PROMPT
5 STO 01
6 RDN
7 STO 00
8 Y/^H?
9 PROMPT
10 STO 02
11 RDN
12 stO 03
13 RCL 01
14 RCL 00
15 -
16 RCL 02
17 /
18 0.5
19 +
20 INT
21 0.001
22 +
23 STO 04 # calclate and store nsteps
24 LBL 00
25 XEQ B # calculate f'(x,y)
26 RCL 02
27 *
28 STO 05
29 XEQ C # calculate f''(x,y)
30 RCL 02
31 STO+00
32 X^2
33 *
34 2
35 /
36 STO+ 05
37 RCL 05
38 STO+ 03
39 VIEW 03
40 DSE 04
41 GTO 00
42 CLD
43 RCL 01
44 XEQ E
45 RCL 03 # recall calculated y at x=b
46 RTN
47 LBL B # calculate f'(x,y) = y * x
48 RCL 03
49 RCL 00
50 *
51 RTN
52 LBL C # calculate f''(x,y) = x*dy/dx + y
53 XEQ B
54 RCL 00
55 *
56 RCL 03
57 +
58 RTN
59 LBL E # exact f(x,y) = g(x) = exp(0.5*x^2)
60 X^2
61 2
62 /
63 EXP
64 RTN
Usage
=====
1. Run the program using XEQ "ELRTLR" or pressing key [A].
2. Program prompts "A/^B?". Key in the value for a, press [ENTER], key in the value for b, and then press [R/S] key.
3. Program prompts "Y/^H?". Key in the value for y(a), press [ENTER], key in the value for increment h, and then press [R/S] key.
4) Program displays intermediate values of the integrated y. The program stops with the calculated value of y at x=b.
5) Press [X<>Y] to view the exact value of y at x=b.
You calculate the value for y at any value of x by entering the value of x and the pressing the [E] key.