|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
不敢称老师,就是二分法求解,写的不好见笑了
- Public Function p(x As Double, y As Double) As Double
- p = WorksheetFunction.Pi() * ((x / 2) + (y / 2)) * (1 + 3 * (((x / 2) - (y / 2)) / ((x / 2) + (y / 2))) ^ 2 / (10 + Sqr(4 - 3 * (((x / 2) - (y / 2)) / ((x / 2) + (y / 2))) ^ 2)))
- End Function
- Public Function b(c As Double, a As Double) As Double
- Dim x As Double, y As Double, z As Double
- x = 0
- y = a
- If c < p(a, 0) Then
- b = -1
- Exit Function
- End If
- While c > p(a, y)
- x = y
- y = y + 100
- Wend
- Do
- z = (x + y) / 2
- If c > p(a, z) Then
- x = z
- Else
- y = z
- End If
- Loop While Abs(c - p(a, z)) > 0.0000000001
- b = z
- End Function
复制代码
|
评分
-
1
查看全部评分
-
|