blob: f022808475acf64e503887e387e89fb9f1779f9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
100 DEFDBL A-H, O-Z
102 C2 = SIN(EXP(1!) / 2!) * SIN(EXP(1!) / 2!)
105 DEF FNA (x AS DOUBLE) = SQR(1! - C2 * SIN(x) ^ 2)
106 DEF FNB (x AS DOUBLE) = -.5 * C2 * SIN(2! * x) / FNA(x)
107 DEF FNC (x AS DOUBLE) = -C2 * COS(2! * x) / FNA(x) - .25 * C2 * C2 * SIN(2! * x) ^ 2 / FNA(x) ^ 3
108 DEF FND (x AS DOUBLE) = 2! * C2 * SIN(2! * x) / FNA(x) - .75 * C2 * C2 * SIN(4! * x) / FNA(x) ^ 3 - .375 * C2 ^ 3 * SIN(2! * x) ^ 3 / FNA(x) ^ 5
109 DEF FNE (x AS DOUBLE) = 4! * C2 * COS(2! * x) / FNA(x) + C2 ^ 2 * SIN(2! * x) ^ 2 / FNA(x) ^ 3 - 3! * C2 ^ 2 * COS(4! * x) / FNA(x) ^ 3 - 1.125 * C2 ^ 3 * SIN(4! * x) * SIN(2! * x) / FNA(x) ^ 5 - (18! / 8!) * C2 ^ 3 * SIN(2! * x) ^ 2 * COS(2! * x) / FNA(x) ^ 5 - (15! / 16!) * C2 ^ 4 * SIN(2! * x) ^ 4 / FNA(x) ^ 7
110 A = 0!
112 INPUT "Left endpoint = "; B
114 IF (A > B) OR (B > 3.141592653589793# / 2!) THEN PRINT "Input out of range": GOTO 112
116 OPEN "92_12_14.txt" FOR APPEND AS #1
120 REM Left endpoint <= 3.141592653589793# / 2!
130 SUM1 = 0!: SUM2 = 0!: SUM3 = 0!: SUM4 = 0!
150 N = 512: H = (B - A) / N
160 FOR I = 1 TO N STEP 2: REM The "FOR" loop is done n/2 times.
170 SUM1 = SUM1 + FNB(A + (I - 1) * H)
172 SUM2 = SUM2 + FNC(A + (I - 1) * H)
174 SUM3 = SUM3 + FND(A + (I - 1) * H)
176 SUM4 = SUM4 + FNE(A + (I - 1) * H)
180 SUM1 = SUM1 + 4! * FNB(A + I * H)
182 SUM2 = SUM2 + 4! * FNC(A + I * H)
184 SUM3 = SUM3 + 4! * FND(A + I * H)
186 SUM4 = SUM4 + 4! * FNE(A + I * H)
190 SUM1 = SUM1 + FNB(A + (I + 1) * H)
192 SUM2 = SUM2 + FNC(A + (I + 1) * H)
194 SUM3 = SUM3 + FND(A + (I + 1) * H)
196 SUM4 = SUM4 + FNE(A + (I + 1) * H)
200 NEXT I
210 L$ = "##.##### ##.##### ##.##### ##.##### ##.#####"
300 PRINT USING L$; FNA(B) - FNA(A); FNB(B) - FNB(A); FNC(B) - FNC(A); FND(B) - FND(A)
310 PRINT USING L$; SUM1 * H / 3!; SUM2 * H / 3!; SUM3 * H / 3!; SUM4 * H / 3!
320 PRINT #1, USING L$; FNA(B) - FNA(A); FNB(B) - FNB(A); FNC(B) - FNC(A); FND(B) - FND(A)
330 PRINT #1, USING L$; SUM1 * H / 3!; SUM2 * H / 3!; SUM3 * H / 3!; SUM4 * H / 3!
340 CLOSE #1
|