Tuesday, 12 July 2011

Approximate Integration - execution of the program

This program will produce the definite integral of the function f(x)=x2 between the limits x=A and x=B (B>A). On running the program, the display shows A? (the lower limit of integration). To begin with, enter 0 and then press [EXE]. The display then shows B? (the upper limit of integration). Enter 3 and press [EXE]. The display then shows D?. This is the number of pairs of strips that the interval between x=A and x=B is to be divided into. Enter 2 and press [EXE]. The display then shows M and 9.

This value is correct because the integral of f(x)=x2 between the limits x=0 and x=a is (1/3)a3 and with a=3, this is (1/3)33=9. This is a useful way to check that the code has been implemented correctly.

Let's try something harder. It is very difficult to obtain an expression for the integral of the function f(x)=exp(-x3) with respect to x but an estimate of the definite integral can be obtained numerically. Changing the function in the program from x2 to exp(-x3) can be done by following the notes in this previous post. For the new function key in [SHIFT] [ex] [(-)] [ALPHA] [X] [x3] [)].

Integrating this new function between the limits of x=0 and x=1 we obtain the following results as the number of pairs of strips is increased from 1 to 9:-

D=1 M=0.816311175
D=2 M=0.807843586
D=3 M=0.807572494
D=4 M=0.807530216
D=5 M=0.807518914
D=6 M=0.807514894
D=7 M=0.807513181
D=8 M=0.807512351
D=9 M=0.807511911

As can be seen, the results show that an estimate of this integral is 0.808 to 3 significant figures (as there is no change in the fifth significant figure for D>5) and this value agrees with other estimates.

Monday, 11 July 2011

Approximate Integration - further comments on the program

One of the other things to note about this program is that I have had to reuse several of the memory variables. The fx-50F comes with six memory variables (A, B, C, D, X and Y) and one independent memory (M) but this was not sufficient for the purposes of the program. For example, I calculate the value of the x-ordinate and store it in memory variable X, but then immediately calculate the y-ordinate, x2, and store that in memory X too. This can be done because the x-ordinate is not needed after the y-ordinate has been calculated.