·VB用迭代法求立方根 10
用迭代法求x=a^(1/3),求立方根的迭代公式为:xi+1=2/3xi+a/3xi*xi迭代到xi+1-xi的绝对值小于十的负五为止,xi+1为方程的近似值,显示a=3...
用迭代法求x=a^(1/3),求立方根的迭代公式为:xi+1=2/3xi+a/3xi*xi
迭代到xi+1-xi的绝对值小于十的负五为止,xi+1为方程的近似值,显示a=3,27的值,并通过求a^(1/3)的表达式加以验证
急啊急啊急啊急啊急啊急啊 展开
迭代到xi+1-xi的绝对值小于十的负五为止,xi+1为方程的近似值,显示a=3,27的值,并通过求a^(1/3)的表达式加以验证
急啊急啊急啊急啊急啊急啊 展开
展开全部
Option Explicit
Private Sub Command1_Click()
Dim a&, b!, c!
a = 3
b = a
Do
c = 2 * b / 3 + a / (3 * b * b)
If Math.Abs(b - c) < 0.00001 Then Exit Do
b = c
Loop
Text1.Text = a & "立方根为:" & c & vbCrLf & "利用运算符求得3的立方根为:" & a ^ (1 / 3)
a = 27
b = a
Do
c = 2 * b / 3 + a / (3 * b * b)
If Math.Abs(b - c) < 0.00001 Then Exit Do
b = c
Loop
Text2.Text = a & "立方根为:" & c & vbCrLf & "利用运算符求得3的立方根为:" & a ^ (1 / 3)
End Sub
Private Sub Command1_Click()
Dim a&, b!, c!
a = 3
b = a
Do
c = 2 * b / 3 + a / (3 * b * b)
If Math.Abs(b - c) < 0.00001 Then Exit Do
b = c
Loop
Text1.Text = a & "立方根为:" & c & vbCrLf & "利用运算符求得3的立方根为:" & a ^ (1 / 3)
a = 27
b = a
Do
c = 2 * b / 3 + a / (3 * b * b)
If Math.Abs(b - c) < 0.00001 Then Exit Do
b = c
Loop
Text2.Text = a & "立方根为:" & c & vbCrLf & "利用运算符求得3的立方根为:" & a ^ (1 / 3)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询