02-24-2016, 03:57 PM (This post was last modified: 02-24-2016 03:58 PM by Namir.)
Post: #1 Namir Senior Member Posts: 679 Joined: Dec 2013
This is a program that calculates the area under a function using teh Gauss-Chebyshev quadrature. The program prompts you for:

1. The lower limit of the integral, A.
2. The upper limit of the integral, B.
3. The number of points to use for the calculations, N. This is also the order of Chebyshev polynomial used in the calculations.

LBL E has the code for the function you want to integrate. Currently, the program integrates the function f(x)=1/x. The version of the quadrature implemented has equal weights of pi/N.

The memory map is:
Code:
 R0 = A R1 = B R2 = N R4 = T1 = (B-A)/2 R5 = T2 = (B+A)/2 R6 = T3 = pi/N/2 R7 = Sum = sum of f(T1*X+T2) R8 = Y = COS((2i-1)*T3) R9 = X = f(T1*X+T2)

Code:
1    LBL "GCQD"         2    LBL A         3    "A?"         4    PROMPT         5    STO 00         6    "B?"         7    PROMPT         8    STO 01         9    "N?"         10    PROMPT         11    STO 02         12    RCL 01         13    RCL 00         14    -         15    2         16    /         17    STO 04        # calculate T1 18    RCL 01         19    RCL 00         20    +         21    2         22    /         23    STO 05        # calculate T2 24    PI         25    RCL 02         26    /         27    2         28    /         29    STO 06        # calculate T3 30    RAD         31    0         32    STO 07        # Sum = 0 33    LBL 00        # start loop ----------------------- 34    RCL 02         35    2         36    *         37    1         38    -         39    RCL 06         40    *         41    COS         42    STO 08        # calculate Y 43    RCL 04         44    *         45    RCL 05         46    +         47    STO 09        # calculate X 48    XEQ E        # calculate f(x) 49    1         50    STO- 02        # N = N - 1 51    RCL 08         52    X^2         53    -         54    SQRT         55    *         56    STO+ 07        # sum = sum + F * sqrt(1-Y*Y) 57    RCL 02         58    X#0?         59    GTO 00        # resume loop iterations 60    RCL 07         61    RCL 04         62    *         63    RCL 06         64    *         65    2         66    *         67    BEEP         68    RTN         69    LBL E        # subroutine for f(x) 70    1/X         71    RTN
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)