You are on page 1of 1

Public Class Form1

Private Sub cmdCalcular_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmdCalcular.Click
Dim Xmayor As Double, Xmenor As Double
Dim Xc As Double, fmenor As Double, fmayor As Double
Dim cont As Byte, z As Double
Xmayor = Val(txtXmenor.Text)
Xmenor = Val(txtXmayor.Text)
fmayor = f(Xmayor)
If fmayor < 0 Then
MsgBox("Debe ingresar otro valor en Xmayor mayor o menor que Xmenor" +
Chr(13) + "para que Ia funcion resulte positiva")
txtXmenor.Focus()
Exit Sub
End If
fmenor = f(Xmenor)
If fmenor > 0 Then
MsgBox("Debe ingresar otro valor en Xmenor mayor o menor que Xmayor" +
Chr(13) + "para que Ia fund& resulte negativa")
txtXmayor.Focus()
Exit Sub
End If
cont = 0
Do
cont = cont + 1
Xc = (Xmayor + Xmenor) / 2
z = f(Xc)
If z > 0 Then
Xmayor = Xc
Else
Xmenor = Xc
End If
lstIteraciones.Items.Add(Format(cont, "000") & Space(10) & Format(z,
"0.0000000000") & Space(10) & Format(Xmenor, "0.0000000000"))

Loop Until System.Math.Abs(z) < Val(txtEPS.Text)


txtXcalculado.Text = Format(Xmenor, "0.0000000000")
End Sub

Private Sub cmdSalirClick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles cmdSalir.Click
End
End Sub
End Class

Module Ecuación_No_Lineal_Bisección
Public Function f(ByVal X As Double) As Double

f = -60000 / (1 + X) ^ 0 - 15000 / (1 + X) ^ 1 + 12000 / (1 + X) ^ 2 +


20000 / (1 + X) ^ 3 + 25000 / (1 + X) ^ 4 + 30000 / (1 + X) ^ 5 + 30000 / (1 + X) ^
6 + 30000 / (1 + X) ^ 7 + 24000 / (1 + X) ^ 8 + 20000 / (1 + X) ^ 9 + 23000 / (1 +
X) ^ 10

End Function

End Module

You might also like