【题目】利用二分法,计算下列函数在[a,b]范围的实根,程序计算后的结果如图1所示.

【题目】利用二分法,计算下列函数在[a,b]范围的实根,程序计算后的结果如图1所示.

题目
【题目】利用二分法,计算下列函数在[a,b]范围的实根,程序计算后的结果如图1所示.
Option Base 1
Private Function fun1(x As Single) As Single
fun1 = x * x * x - 3 * x * x - 2 * x + 1
End Sub
Private Function root(a As Single,b As Single) As Single
Dim rot As Single
f0 = fun1(a)
rot = (a + b) / 2
For Abs(a - rot) > 0.000001 Then
If f0 * fun1(rot) > 0 Then
root = root(rot,b)
Else
root = root(a,rot)
End If
Else
root = rot
End If
End Function
Private Sub Command1_Click()
Dim x As Single,a As Single,b As Single
a = Val(Text1(0).Text)
b = Val(Text1(1).Text)
f0 = fun1(a)
f1 = fun1(b)
If f0 * f1 = 0 Then
MsgBox "此区间方程无解!"
Else
rot = root(a,b)
End If
Text1(2).Text = rot
End Sub
答案
0.3433796,-0.8342433,3.490864'每次只找其中的一个Option Base 1Const wucha As Double = 0.000001Private Function fun1(x As Single) As Singlefun1 = x * x * x - 3 * x * x - 2 * x + 1End FunctionPrivate Fun...
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
热门考点

超级试练试题库

© 2017-2019 超级试练试题库,All Rights Reserved.