An important part of the program I presented previously is defining the function that is being integrated. I chose the simple function f(x)=x2 and the statement in the code :X²→X: achieves this. In order to integrate a different funtion the program must be edited. For example, if I wanted to have f(x)=cos(x), then I would replace :X²→X: with :cos(X)→X:.
To edit a program it is best to ensure that your calculator is in insert mode by keying [SHIFT] [INS]. This will insert text before the vertical cursor and not overwrite existing text. To edit the program key [MODE] [6] [1] and then your program number. Use the replay button to move the blinking vertical cursor | to after X², so that it looks like :X²|→X:. Then press [DEL] twice and replace the function by keying [COS] [AlPHA] [X] [)], say.
It is a bit tedious, but I haven't found a way round this on the fx-50F.
Wednesday, 25 May 2011
Approximate Integration - comments on the program
Tuesday, 24 May 2011
Approximate Integration - the program
The logic for the approximate integration program was presented previously. Here is the logic converted into a program for the fx-50F:-
?→A:?→B:?→D:0→M:(B-A)÷(2D)→Y:1→C:While C≤D:1→B:Lbl 0:
B=1=>A+2(C-1)Y→X:B=2=>A+2CY→X:B=3=>A+(2C-1)Y→X:X²→X:
YX÷3→X:B=3=>4X→X:XM+:B+1→B:B≤3=>Goto 0:C+1→C:WhileEnd:
M▲
This is pretty much how the program looks when keyed into the calculator in edit mode except it all appears on one continuous line. Special Program Commands (? → => : Lbl While WhileEnd = ≤ ▲ Goto) are input using the [SHIFT] [P-CMD] keys. The cursor key (marked Replay) is used to switch between various screens of commands. Memory variables A, B, C, D, M, X and Y are input using [ALPHA] [A], [B] etc keys. The ":" Separator Code command is used frequently and can be alternatively input using the [EXE] key.
This program is 136 steps in length.
?→A:?→B:?→D:0→M:(B-A)÷(2D)→Y:1→C:While C≤D:1→B:Lbl 0:
B=1=>A+2(C-1)Y→X:B=2=>A+2CY→X:B=3=>A+(2C-1)Y→X:X²→X:
YX÷3→X:B=3=>4X→X:XM+:B+1→B:B≤3=>Goto 0:C+1→C:WhileEnd:
M▲
This is pretty much how the program looks when keyed into the calculator in edit mode except it all appears on one continuous line. Special Program Commands (? → => : Lbl While WhileEnd = ≤ ▲ Goto) are input using the [SHIFT] [P-CMD] keys. The cursor key (marked Replay) is used to switch between various screens of commands. Memory variables A, B, C, D, M, X and Y are input using [ALPHA] [A], [B] etc keys. The ":" Separator Code command is used frequently and can be alternatively input using the [EXE] key.
This program is 136 steps in length.
Wednesday, 4 May 2011
Approximate Integration - the logic
I previously gave a formula (Simpson's Rule) for finding the approximate integral of a function f(x) between x=a and x=b (b>a). This consisted of a sum of n bracketed terms corresponding to the approximate area under the curve of n pairs of strips, with each strip being of width h.
This sum provides the logic for calculating the area under the curve and hence a value for the definite integral as follows:-
Input A (the lower limit of the integration)
Input B (the upper limit of the integration)
Input D (the number of pairs of strips)
Store 0 in M (this will hold the sum of the area)
Store (B-A)/2D in Y (the value of h, the width of a strip)
Store 1 in C (C indicates which pair of strips is being processed)
While C is less than or equal to D
Store 1 in B (B now indicates one of three ordinates)
Label 0
If B=1 then
Store A+2(C-1)Y in X (left ordinate)
EndIf
If B=2 then
Store A+2CY in X (right ordinate)
EndIf
If B=3 then
Store A+(2C-1)Y in X (middle ordinate)
EndIf
Store f(X) in X
Store YX/3 in X
If B=3 then
Store 4X in X
EndIf
Store M+X in M (the summation)
Store B+1 in B
If B is less than or equal to 3 then
Goto Label 0
EndIf
Store C+1 in C
WhileEnd
Display M
This sum provides the logic for calculating the area under the curve and hence a value for the definite integral as follows:-
Input A (the lower limit of the integration)
Input B (the upper limit of the integration)
Input D (the number of pairs of strips)
Store 0 in M (this will hold the sum of the area)
Store (B-A)/2D in Y (the value of h, the width of a strip)
Store 1 in C (C indicates which pair of strips is being processed)
While C is less than or equal to D
Store 1 in B (B now indicates one of three ordinates)
Label 0
If B=1 then
Store A+2(C-1)Y in X (left ordinate)
EndIf
If B=2 then
Store A+2CY in X (right ordinate)
EndIf
If B=3 then
Store A+(2C-1)Y in X (middle ordinate)
EndIf
Store f(X) in X
Store YX/3 in X
If B=3 then
Store 4X in X
EndIf
Store M+X in M (the summation)
Store B+1 in B
If B is less than or equal to 3 then
Goto Label 0
EndIf
Store C+1 in C
WhileEnd
Display M
Monday, 2 May 2011
Approximate Integration
Sometimes it is necessary to obtain a numerical estimate of the definite integral of a function f(x) between x=a and x=b (where b>a). This integral is represented by the area bounded by the curve y=f(x), the x-axis and the ordinates at x=a and x=b. One reasonably accurate method of estimating this area, and hence this integral, is to use Simpson's Rule. Here the area is approximated by
(h/3)(y0 + 4y1 + y2) + (h/3)(y2 + 4y3 + y4) + ... + (h/3)(y2n-2 + 4y2n-1 + y2n)
The area is divided into 2n strips of width h=(b-a)/2n and the ordinates are given by y0=f(a), y1=f(a+h), y2=f(a+2h) etc. The method uses a quadratic of the form AX2+BX+C to approximate the function between three adjacent points on the curve (i.e. between two adjacent strips).
(h/3)(y0 + 4y1 + y2) + (h/3)(y2 + 4y3 + y4) + ... + (h/3)(y2n-2 + 4y2n-1 + y2n)
The area is divided into 2n strips of width h=(b-a)/2n and the ordinates are given by y0=f(a), y1=f(a+h), y2=f(a+2h) etc. The method uses a quadratic of the form AX2+BX+C to approximate the function between three adjacent points on the curve (i.e. between two adjacent strips).
Subscribe to:
Posts (Atom)