Visual Basic 常用数学算法集书中收录了所有代码
源代码在线查看: d3r2.txt
Private Sub Command1_Click()
'PROGRAM D3R2
'Driver for routine QTRAP
PIO2 = 1.5707963
A = 0#
B = PIO2
Print
Print Tab(5); "Integral of FUNC computed with QTRAP"
Print
Print Tab(5); "Actual value of integral is:";
Print Tab(34); Format$((FINT(B) - FINT(A)), "0.####00")
Print
Call QTRAP(A, B, S)
Print Tab(5); "Result from routine QTRAP is:";
Print Tab(35); Format$(S, "0.####00")
End Sub
Function FUNC(X)
FUNC = (X ^ 2) * (X ^ 2 - 2#) * Sin(X)
End Function
Function FINT(X)
'Integral of FUNC
AAA = 4# * X * (X ^ 2 - 7#) * Sin(X)
FINT = AAA - (X ^ 4 - 14# * X ^ 2 + 28#) * Cos(X)
End Function