Степенева залежність
Текст програми CLS REM MNK DIM X(50), Y(50) INPUT "Vvedit kilkist doslidiv N "; N FOR I = 1 TO N PRINT "Vvedit "; I; "znachennia X,Y" INPUT X(I), Y(I) NEXT I PRINT "stepeneva" LET S1 = N: LET S2 = 0: LET S3 = 0 LET S4 = 0: LET S5 = 0 FOR I = 1 TO N LET S2 = S2 + LOG(X(I)): LET S3 = S3 + LOG(Y(I)) LET S4 = S4 + LOG(X(I)) * LOG(X(I)) LET S5 = S5 + LOG(X(I)) * LOG(Y(I)) NEXT I LET B = (S2 * S3 - S1 * S5) / (S2 ^ 2 - S1 * S4) LET A = EXP((1 / S1) * (S3 - B * S2)) PRINT "Y="; A; "*"; "X^"; B LET S = 0 FOR I = 1 TO N LET S = S + (Y(I) - (A * X(I) ^ B)) ^ 2 NEXT I LET S = SQR(S / (N - 2)) PRINT "Seredne kvadratychne vidhylennia", USING "###.######"; S OPEN "stepen.dat" FOR OUTPUT AS #1 PRINT #1, "stepeneva zalejnist" PRINT #1, "Y="; A; "*X^"; B PRINT #1, "Seredne kvadratychne vidhylennia", USING "###.######"; S PRINT #1, "X", "Y", "Yr" FOR I = 1 TO N PRINT #1, X(I), Y(I), A * X(I) ^ B NEXT I CLOSE #1 END Результати stepeneva zalejnist Y = 58.84853 *X^ 8.969842E-02 Seredne kvadratychne vidhylennia 9.981964 X Y Yr 0,1 54,1 47,86711 10 60,1 72,34926 20 66,1 76,9903 30 71,2 79,84194 40 76,1 81,92905 50 80,8 83,58543 60 85,7 84,96362 70 90,6 86,14658 80 95,6 87,18461 90 99,8 88,11059 100 104,6 88,94724 Графік
|