Você está na página 1de 6

1,2 :

: 1307
2014

25:
Cos(x/5)*(1+x)^1/2-x


()

Imports System.Math
Public Class Form1
Public Function f1(ByVal x As Double)
Return Cos(x / 5) * (1 + x) ^ 1 / 2 - x
End Function
Sub resh(ByVal exp As Double, ByRef a As Double, ByRef b As Double)
Dim n As Integer
Dim c As Double
Dim t1 As Double
Dim t2 As Double
n=0
ListBox2.Items.Add(a)
ListBox3.Items.Add(b)
c = (a + b) / 2
Do While Abs(b - a) >= exp
n=n+1
t1 = f1(c)
t2 = f1(b)
If t1 * t2 < 0 Then
a=c
Else
b=c
End If
ListBox2.Items.Add(a)
ListBox3.Items.Add(b)
t1 = f1(a) : t2 = f1(b)
ListBox4.Items.Add(t1)
ListBox5.Items.Add(t2)
c = (a + b) / 2
Loop
TextBox4.Text = Str(c)
t1 = f1(c)
TextBox5.Text = Str(t1)
TextBox6.Text = Str(n)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Button1.Click


Dim a, b, exp As Double
a = CStr(TextBox1.Text)
b = CStr(TextBox2.Text)
exp = CStr(TextBox3.Text)
resh(exp, a, b)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class

f(x)

0.1
0.01

4
7

1.03125
1.00390625

-3.71*10^(-1)
-2.2*10^(-1)

0.001

10

1.00048828125

-2*10^(-1)

()


()

Você também pode gostar