请教如何用迭代法解此方程
展开全部
Dim a, b
Private Sub Command1_Click()
temp = (Val(a) + Val(b)) / 2
If h(temp) = Abs(h(temp)) And h(a) < 0 Then b = temp
If h(temp) = Abs(h(temp)) And h(b) < 0 Then a = temp
If h(temp) > Abs(h(temp)) And h(a) > 0 Then b = temp
If h(temp) > Abs(h(temp)) And h(b) > 0 Then a = temp
Print a
Print b
End Sub
Function h(x)
h = Val(x) ^ 6 - 5 * Val(x) ^ 5 + 3 * Val(x) ^ 4 + Val(x) ^ 3 - 7 * Val(x) ^ 2 + 7 * Val(x) - 20
End Function
Private Sub Form_Load()
a = -2
b = 5
End Sub
点再精确
Private Sub Command1_Click()
temp = (Val(a) + Val(b)) / 2
If h(temp) = Abs(h(temp)) And h(a) < 0 Then b = temp
If h(temp) = Abs(h(temp)) And h(b) < 0 Then a = temp
If h(temp) > Abs(h(temp)) And h(a) > 0 Then b = temp
If h(temp) > Abs(h(temp)) And h(b) > 0 Then a = temp
Print a
Print b
End Sub
Function h(x)
h = Val(x) ^ 6 - 5 * Val(x) ^ 5 + 3 * Val(x) ^ 4 + Val(x) ^ 3 - 7 * Val(x) ^ 2 + 7 * Val(x) - 20
End Function
Private Sub Form_Load()
a = -2
b = 5
End Sub
点再精确
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询