CLS e = .0001 PRINT TAB(20); "labrab 2" PRINT " x S yt p kol" FOR x = .2 TO 1 STEP .1 n = 1: S = 0: kol = 0: sm = 1: np = 1 DO np = np * x V = sm * np / n S = S + V n = n + 1 kol = kol + 1 sm = -sm LOOP UNTIL ABS(V) <= e yt = LOG(1 + x) P = ABS((S - yt) * (yt)) * 100 PRINT USING "#.# ##. ##. ##. ##"; x; S; yt; P; kol NEXT x END
Результат выполнения программы: labrab 2 x S yt p kol 0.2 0.1823 0.1823 0.0002 5 0.3 0.2624 0.2624 0.0002 7 0.4 0.3365 0.3365 0.0007 8 0.5 0.4054 0.4055 0.0012 10 0.6 0.4700 0.4700 0.0009 14 0.7 0.5306 0.5306 0.0019 18 0.8 0.5878 0.5878 0.0023 27 0.9 0.6419 0.6419 0.0027 51
e = .0001
PRINT TAB(20); "labrab 2"
PRINT " x S yt p kol"
FOR x = .2 TO 1 STEP .1
n = 1: S = 0: kol = 0: sm = 1: np = 1
DO
np = np * x
V = sm * np / n
S = S + V
n = n + 1
kol = kol + 1
sm = -sm
LOOP UNTIL ABS(V) <= e
yt = LOG(1 + x)
P = ABS((S - yt) * (yt)) * 100
PRINT USING "#.# ##. ##. ##. ##"; x; S; yt; P; kol
NEXT x
END
Результат выполнения программы:
labrab 2
x S yt p kol
0.2 0.1823 0.1823 0.0002 5
0.3 0.2624 0.2624 0.0002 7
0.4 0.3365 0.3365 0.0007 8
0.5 0.4054 0.4055 0.0012 10
0.6 0.4700 0.4700 0.0009 14
0.7 0.5306 0.5306 0.0019 18
0.8 0.5878 0.5878 0.0023 27
0.9 0.6419 0.6419 0.0027 51