(71B) Euler-Taylor method for the HP-71B
|
12-07-2019, 04:36 PM
(This post was last modified: 12-11-2019 10:04 PM by Namir.)
Post: #1
|
|||
|
|||
(71B) Euler-Taylor method for the HP-71B
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) HP-71B Listing ============== Code: 10 REM EULER METHOD WITH 2 DERIVATIVES Usage ===== 1) With the values in the DATA statements being the ones you want and the definitions of functions FNE, FNX, and FND representing your problem to solve, just press the [RUN] button. The program displays "WAIT PLEASE ..." as it calculates y at x=b. 2) Displays the value of y at x=b. Press [f][Cont] to resume. 3) Displays the exact value of y at x=b. Press [f][Cont] to resume. 4) Displays the % error between the calculated and exact values of y at x=b. Code Customization ================== 1) Edit the DATA statement to use different values for a, b, y(a), and h. 2) Edit the definitions of functions FNE, FNX, and FND to use a different exact function, a different first derivative, and a different second derivatve, respectively. In the case of FNE, edit the DEF FNE(X) statement to implement the eaxct solutions as a function of variable x only. If that solution is not available use something like: DEF FNE(X)=1E99 HP-71B Listing 2 ================ This version should be faster since the FOR loop calculates the values of the first and second derivative directly and does not resort to calling functions defined in DEF statements. Code: 10 REM EULER METHOD WITH 2 DERIVATIVES ===== 1) With the values in the DATA statements being the ones you want and the definitions of functions FNE, FNX, and FND representing your problem to solve, just press the [RUN] button. The program displays "WAIT PLEASE ..." as it calculates y at x=b. 2) Displays the value of y at x=b. Press [f][Cont] to resume. 3) Displays the exact value of y at x=b. Press [f][Cont] to resume. 4) Displays the % error between the calculated and exact values of y at x=b. Code Customization ================== 1) Edit the DATA statement to use different values for a, b, y(a), and h. 2) Edit line 90 to change how the first derivative is calculated and assigned to variable D1. 3) Edit line 100 to change how the first derivative is calculated and assigned to variable D2. You can use variable D1 when the value of teh first derivative is needed. 4) Edit the DEF FNE(X) statement to implement the eaxct solutions as a function of variable x only. If that solution is not available use something like: DEF FNE(X)=1E99 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)