13、Private Sub Form_Click()
Dim x, x0 As Double
Dim n As Integer
x = 0: n = 0
Do
x1 = (5 + 2 * x) ^ (1 / 3)
n = (n + 1)
x2 = x: x = x1
Loop Until Abs(x2 - x) < 0.001
Print x
End Sub
15、Private Sub Command1_Click()
Dim x, y, a, b
y0 = 12.119
a = -1: b = 8
x = (a + b) / 2
y = x ^ 4 - 7.223 * x ^ 3 + 13.447 * x ^ 2 - 0.672 * x - 10.223
If y * y0 > 0 Then
a = x
Else
b = x
end if
Do Until Abs(a - b) < 10 ^ (-6)
Loop
Text1.Text = x
Print x
End Sub
16题参考Private Sub Form_Click()
Dim x As Double: Dim y As Double: Dim n As Integer: Dim h As Integer
For h = 1 To 1000
x = 1 / 1000
y = y + x * (0 + x * h)
Next h
Print y
End Sub
Private Sub Form_Click()
Dim x As Double, y As Double, s As Double
For x = 0 To 1 Step 0.00001
y = x
s = s + y * 0.00001
Next
Print s
End Sub
正式
答案
矩形法0.359174735226714
Private Sub Form_Click()
Dim x, y, h, a, b As Double
x = 1 / 10000
y = 0
For h = 1 To 10000
b = h * x
a = b * 2.71828 ^ b / (1 + b) ^ 2
y = y + x * a
Next
Print y
End Sub
梯形法0.35914073
Private Sub Form_Click()
Dim h, y, a, b, c
h = 1 / 1000
y = 2.71828 / 8
For b = 1 To 1000 - 1
a = b * h
c = a * 2.71828 ^ a / (1 + a) ^ 2
y = y + c
Next
y = h * y
Print y
End Sub
抛物线法0.3589142
Private Sub Form_Click()
Dim h, y, a, b, c, d, f, g, i
h = 1 / (1000 * 2)
a = (2 * h) * (1000 - 1) + 0
c = a * 2.71828 ^ a / (1 + a) ^ 2
y = 2.71828 / 4 + 4 * c
For b = 1 To 1000 - 1
d = 0 + 2 * b * h
f = d * 2.71828 ^ d / (1 + d) ^ 2
g = 0 + 2 * (b - 1) * h
i = g * 2.71828 ^ g / (1 + g) ^ 2
y = y + 2 * f + 4 * i
Next
y = y * h / 3
Print y
End Sub
17、答案 矩形法5.056198
Private Sub Form_Click()
Dim x, y, h, a, b As Double
x = 3.1415926535 / 10000
y = 0
For h = 1 To 10000
b = h * x
a = Log(5 - 4 * cosb)
y = y + x * a
Next
Print y
End Sub
抛物线法 5.056506086
Private Sub Form_Click()
Dim h, y, a, b, c As Double
h = 3.1415926535 / (1000 * 2)
a = 2 * h * (1000 - 1) + 0
c = Log(5 - 4 * cosa)
y = Log(5 - 4 * cos0) + Log(5 + -4 * Cos(3.1415926535)) + 4 * c
For b = 1 To 1000 - 1
d = 0 + 2 * b * h
f = Log(5 - 4 * cosd)
g = 0 + 2 * (b - 1) * h
i = Log(5 - 4 * cosg)
y = y + 2 * f + 4 * i
Next
y = y * h / 3
Print y
End Sub
第二小题抛物线法 3.02299894
Private Sub Form_Click()
Dim h, y, a, b, c As Double
h = 3.1415926535 / (1000 * 2 * 2)
a = 2 * h * (1000 - 1) + 0
c = sina / (1 - 0.25 * sina * sina) ^ 0.5
y = sin0 / (1 - 0.25 * sin0 * sin0) ^ 0.5 + Sin(3.14159265 / 2) / (1 - 0.25 * Sin(3.14159265 / 2) * Sin(3.14159265 / 2)) ^ 0.5 + 4 * c
For b = 1 To 1000 - 1
d = 0 + 2 * b * h
f = sind / (1 - 0.25 * sind * sind) ^ 0.5
g = 0 + 2 * (b - 1) * h
i = sing / (1 - 0.25 * sing * sing) ^ 0.5
y = y + 2 * f + 4 * i
Next
y = y * h / 3
Print y
End Sub
矩形法
Private
Sub Form_Click()
Dim x, y, h, a, b As Double
x = 3.14159 / 200
y = 0
For h = 1 To 100
b = h * x
a = sinb / (1 - 0.25 * sinb * sinb) ^ 0.5