Visual Basic 常用数学算法集书中收录了所有代码
源代码在线查看: d9r9.txt
Private Sub Command1_Click()
'PROGRAM D9R9
'Driver for roution FGAUSS
NPT = 3
NLIN = 2
NA = 3 * NLIN
Dim A(6), DYDA(6), DF(6)
A(1) = 3#: A(2) = 0.2: A(3) = 0.5: A(4) = 1#: A(5) = 0.7: A(6) = 0.3
Print Tab(6); "X Y DATA1 DATA2 DATA3 DATA4 DATA5 DATA6"
For I = 1 To NPT
X = 0.3 * I
Call FGAUSS(X, A(), Y, DYDA(), NA)
E1 = Exp(-((X - A(2)) / A(3)) ^ 2)
E2 = Exp(-((X - A(5)) / A(6)) ^ 2)
F = A(1) * E1 + A(4) * E2
DF(1) = E1
DF(4) = E2
DF(2) = A(1) * E1 * 2# * (X - A(2)) / (A(3) ^ 2)
DF(5) = A(4) * E2 * 2# * (X - A(5)) / (A(6) ^ 2)
DF(3) = A(1) * E1 * 2# * ((X - A(2)) ^ 2) / (A(3) ^ 3)
DF(6) = A(4) * E2 * 2# * ((X - A(5)) ^ 2) / (A(6) ^ 3)
Print Tab(5)
Print Tab(5); "from FGAUSS"
Print Tab(5)
Print Tab(3); Format(X, "##.##00"); Tab(13); Format$(Y, "##.##00");
For J = 1 To 6
Print Tab(21 + (J - 1) * 9); Format$(DYDA(J), "##.####");
Next J
Print Tab(5)
Print Tab(5); "independent calc."
Print Tab(5)
Print Tab(3); Format(X, "##.##00"); Tab(13); Format$(F, "##.##00");
For J = 1 To 6
Print Tab(21 + (J - 1) * 9); Format$(DF(J), "##.####");
Next J
Print
Next I
End Sub