- 积分
- 67145
- 回帖
- 0
- 西莫币
-
- 贡献
-
- 威望
-
- 存款
-
- 阅读权限
- 120
- 最后登录
- 1970-1-1
签到天数: 5 天 连续签到: 2 天 [LV.2]偶尔看看I
|
楼主 |
发表于 2012-11-14 09:10
|
显示全部楼层
来自: 中国广西玉林
我百度出来的仅供参考,500大洋还是等大家去拿
vb6.0怎样用辛普森法求积分
Private Function xinpusen(a As Single, b As Single, e As Single, he As Single) As Single
k = 2
s0 = 0
h = (b - a) / k
ya = hanshu(a)
yb = hanshu(b)
yi = hanshu(x = a + h)
p = ya + yb
d = yi
Do
s = (p + 4 * d) * h / 3
no = no + 1
If Abs(s - s0) <= e And h < he Then
xinpusen = s
Exit Function
Else
h = h / 2
k = k * 2
s0 = s
p = p + 2 * d
d = 0
For i = 1 To k - 1 Step 2
yi = hanshu(a + i * h)
d = d + yi
Next i
End If
Loop
End Function
需要参数:下限、上限、允许误差、最小划分宽度。
还需要自己协议各function,名字叫函数,一个参数,就是自变量,返回被积分函数的值 |
|