谁能用VB解一下这个一元方程,求代码.20.26 = (8.314 * 473.15) / (v - 29.85) - (3.224 * 1000000) / (473.15 * v * (v + 29.85)) ^ 0.5还是自己把它编出来了.答案196.61475.Private Sub Command1_Click()Dim v As DoubleDim v1 As Double,v

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 09:59:14
谁能用VB解一下这个一元方程,求代码.20.26=(8.314*473.15)/(v-29.85)-(3.224*1000000)/(473.15*v*(v+29.85))^0.5还是自己把它编出来了

谁能用VB解一下这个一元方程,求代码.20.26 = (8.314 * 473.15) / (v - 29.85) - (3.224 * 1000000) / (473.15 * v * (v + 29.85)) ^ 0.5还是自己把它编出来了.答案196.61475.Private Sub Command1_Click()Dim v As DoubleDim v1 As Double,v
谁能用VB解一下这个一元方程,求代码.
20.26 = (8.314 * 473.15) / (v - 29.85) - (3.224 * 1000000) / (473.15 * v * (v + 29.85)) ^ 0.5
还是自己把它编出来了.答案196.61475.
Private Sub Command1_Click()
Dim v As Double
Dim v1 As Double,v2 As Double
Dim e As Double,n As Integer
v = 1
n = 0
Do
v1 = v
v = (8.314 * 473.15) / (20.26 + (3.224 * 1000000) / ((473.15 ^ 0.5) * v * (v + 29.85))) + 29.85
v2 = v
n = n + 1
e = Abs(v2 - v1)
Loop Until e < 1E-20
Print "v="; v
End Sub

谁能用VB解一下这个一元方程,求代码.20.26 = (8.314 * 473.15) / (v - 29.85) - (3.224 * 1000000) / (473.15 * v * (v + 29.85)) ^ 0.5还是自己把它编出来了.答案196.61475.Private Sub Command1_Click()Dim v As DoubleDim v1 As Double,v
'答案是29.85,注意代码里可以设置结果的精确度
Private Function calc(bitnum As Integer) As Double
Dim v As Double, eps As Double
Dim cnt As Integer: cnt = 0
eps = 1
v = eps
Do While True
r = (8.314 * 473.15) / (v - 29.85) - (3.224 * 1000000) / (473.15 * v * (v + 29.85)) ^ 0.5
If r > 20.26 Then
cnt = cnt + 1
If cnt > bitnum Then
Exit Do
End If
v = v - eps
eps = eps / 10
End If
v = v + eps
Loop
calc = v
End Function
Private Sub Command1_Click()
v = calc(6) '结果精确到6位小数
MsgBox v
End Sub