You are on page 1of 19

FACULTAD DE INGENIERIA, UNAM

ANLISIS NUMRICO Semestre 2013-2

PROYECTO 2

Integrantes del Equipo: Del Ro Cruz Vania Padilla Resendiz Nabila Isabel Rayo Velzquez Csar Daro Ruz Mrquez Juan Pedro N.L. 8 N.L. 31

CDIGO CORRESPONDIENTE A LOS PROCEDIMIENTOS DEL METODO DE REGLA FALSA


Dim x11(10000) As String Dim x22(10000) As String Dim N1(10000) As String Dim XR(10000) As String Dim fx1(10000) As String Dim fxm(10000) As String Dim i Function F(ByVal x As Double) As Double Dim Formula As String Dim Funct As New clsMathParser Formula = Text1.Text Funct.StoreExpression (Formula) F = Funct.Eval1(x) End Function Private Sub abs_Click() Text1.Text = "abs(x)" Text1.SetFocus End Sub Private Sub atn_Click() Text1.Text = "atn(x)" Text1.SetFocus End Sub Private Sub Command1_Click() If Text2.Text <> Text3.Text Then If Text2.Text <> "" Then If Text3.Text <> "" Then n = Val(Text4.Text) x11(0) = Val(Text2.Text) x22(0) = Val(Text3.Text) For i = 0 To Val(n) XR(i) = (Val(x11(i)) + Val(x22(i))) / 2 fx1(i) = F(Val(x11(i))) fxm(i) = F(XR(i)) Else x11(i + 1) = Val(XR(i)) x22(i + 1) = Val(x22(i)) End If Label1.Caption = XR(n) Next i Else MsgBox "Debes introducir el valor final", 0, "Aviso" End If Else MsgBox "Debes introducir el valor inicial", 0, "Aviso" End If End If End Sub Private Sub Command2_Click() Dim i, j, positivo, incremento incremento = Val(Text5.Text) If Inf.Text <> "" Then If Sup.Text <> "" Then If Text1.Text <> "" Then If Text5.Text <> "" Then For i = 0 To Abs((1 / incremento) * (Val(Sup.Text) - Val(Inf.Text))) List1.List(i) = Round(Val(Inf.Text) + i * incremento, 3) List2.List(i) = Round(F(Val(Inf.Text) + i * incremento), 3) Next i End If End If End If End If End Sub Private Sub Command3_Click() FormRegla.Visible = False FormPrincipal.Show End Sub Private Sub Command4_Click() frmAbout.Show vbModal End Sub

If Val(Val(fx1(i)) * Val(fxm(i))) < 0 Then x22(i + 1) = Val(XR(i)) x11(i + 1) = Val(x11(i))

Private Sub Command6_Click() Text1.Text = "ln(x)" Text1.SetFocus End Sub Private Sub Command7_Click() Text1.Text = "log(x)" Text1.SetFocus End Sub Private Sub Command8_Click() Text1.Text = "abs(x)" Text1.SetFocus End Sub Private Sub Command9_Click() Text1.Text = "atn(x)" Text1.SetFocus End Sub Private Sub cos_Click() Text1.Text = "cos(x)" Text1.SetFocus End Sub Private Sub Exp_Click() Text1.Text = "exp(x)" Text1.SetFocus End Sub Private Sub Form_Load() Text2.Enabled = False Text3.Enabled = False Text4.Enabled = False Inf.Enabled = False Sup.Enabled = False Text5.Enabled = False Command1.Enabled = False End Sub Private Sub Inf_Change() List1.Clear List2.Clear End Sub Private Sub Inf_KeyPress(KeyAscii As Integer)

Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub ln_Click() Text1.Text = "ln(x)" Text1.SetFocus End Sub Private Sub log_Click() Text1.Text = "log(x)" Text1.SetFocus End Sub Private Sub Nueva_Click() Text1.Text = "" Inf.Text = "" Sup.Text = "" Text5.Text = "" List1.Clear List2.Clear Text2.Text = "" Text3.Text = "" Label1.Caption = "" Text4.Text = "" End Sub Private Sub Prueba5_Click() End Sub Private Sub Sal_Click() FormBiseccion.Visible = False FormPrincipal.Show

End Sub Private Sub Sen_Click() Text1.Text = "sin(x)" Text1.SetFocus End Sub Private Sub Sup_Change() List1.Clear List2.Clear End Sub

Inf.SetFocus

Private Sub Sup_KeyPress(KeyAscii As Integer) Sup.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub Tan_Click() Text1.Text = "tan(x)" Text1.SetFocus End Sub Private Sub Text1_Change()

Case 8, 33, 124, 105, 108 To 116, 97 To 101, 120, 94, 40 To 43, 44 To 46, 48 To 57, 78 Case Else KeyAscii = 0 End Select End Sub Private Sub Text2_Change() Label1.Caption = "" If Text2.Text <> "" Then If Text3.Text <> "" Then If Text4.Text <> "" Then Command1.Enabled = True Else Command1.Enabled = False End If Else Command1.Enabled = False End If Else Command1.Enabled = False End If End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) Text2.SetFocus

If Text1.Text <> "" Then Inf.Enabled = True Sup.Enabled = True Text5.Enabled = True Text2.Enabled = True Text3.Enabled = True Text4.Enabled = True Else Inf.Enabled = False Sup.Enabled = False Text5.Enabled = False End If Inf.Text = "" Sup.Text = "" Text5.Text = "" List1.Clear List2.Clear Text2.Text = "" Text3.Text = "" Label1.Caption = "" Text4.Text = "" End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 13 KeyAscii = 0

Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub

Private Sub Text3_Change()

Label1.Caption = "" If Text2.Text <> "" Then If Text3.Text <> "" Then If Text4.Text <> "" Then Command1.Enabled = True Else Command1.Enabled = False End If Else Command1.Enabled = False

End If Else Command1.Enabled = False End If End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) Text3.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub Text4_Change() Label1.Caption = "" If Text2.Text <> "" Then If Text3.Text <> "" Then If Text4.Text <> "" Then Command1.Enabled = True Else Command1.Enabled = False End If Else Command1.Enabled = False End If Else Command1.Enabled = False End If End Sub Private Sub Text4_KeyPress(KeyAscii As Integer) Text4.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub Text5_Change() List1.Clear List2.Clear

End Sub Private Sub Text5_KeyPress(KeyAscii As Integer) Text5.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub

CDIGO CORRESPONDIENTE A LOS PROCEDIMIENTOS DEL METODO DE BISECCION


Dim x11(10000) As String Dim x22(10000) As String Dim N1(10000) As String Dim XR(10000) As String Dim fx1(10000) As String Dim fxm(10000) As String Dim i Function F(ByVal x As Double) As Double Dim Formula As String Dim Funct As New clsMathParser Formula = Text1.Text Funct.StoreExpression (Formula) F = Funct.Eval1(x) End Function Private Sub abs_Click() Text1.Text = "abs(x)" Text1.SetFocus End Sub Private Sub atn_Click() Text1.Text = "atn(x)" Text1.SetFocus End Sub Private Sub Command1_Click() If Text2.Text <> Text3.Text Then If Text2.Text <> "" Then If Text3.Text <> "" Then n = Val(Text4.Text) x11(0) = Val(Text2.Text) x22(0) = Val(Text3.Text) For i = 0 To Val(n) End Sub XR(i) = (Val(x11(i)) + Val(x22(i))) / 2 fx1(i) = F(Val(x11(i))) fxm(i) = F(XR(i)) Private Sub Command3_Click() FormRegla.Visible = False FormPrincipal.Show End Sub If Val(Val(fx1(i)) * Val(fxm(i))) < 0 Then x22(i + 1) = Val(XR(i)) x11(i + 1) = Val(x11(i)) Else Private Sub Command4_Click() frmAbout.Show vbModal End Sub Private Sub Command6_Click() x11(i + 1) = Val(XR(i)) x22(i + 1) = Val(x22(i)) End If Label1.Caption = XR(n) Next i Else MsgBox "Debes introducir el valor final", 0, "Aviso" End If Else MsgBox "Debes introducir el valor inicial", 0, "Aviso" End If End If End Sub Private Sub Command2_Click() Dim i, j, positivo, incremento incremento = Val(Text5.Text) If Inf.Text <> "" Then If Sup.Text <> "" Then If Text1.Text <> "" Then If Text5.Text <> "" Then For i = 0 To Abs((1 / incremento) * (Val(Sup.Text) - Val(Inf.Text))) List1.List(i) = Round(Val(Inf.Text) + i * incremento, 3) List2.List(i) = Round(F(Val(Inf.Text) + i * incremento), 3) Next i End If End If End If End If

Text1.Text = "ln(x)" Text1.SetFocus End Sub Private Sub Command7_Click() Text1.Text = "log(x)" Text1.SetFocus End Sub Private Sub Command8_Click() Text1.Text = "abs(x)" Text1.SetFocus End Sub Private Sub Command9_Click() Text1.Text = "atn(x)" Text1.SetFocus End Sub Private Sub cos_Click() Text1.Text = "cos(x)" Text1.SetFocus End Sub Private Sub Exp_Click() Text1.Text = "exp(x)" Text1.SetFocus End Sub Private Sub Form_Load() Text2.Enabled = False Text3.Enabled = False Text4.Enabled = False Inf.Enabled = False Sup.Enabled = False Text5.Enabled = False Command1.Enabled = False End Sub Private Sub Inf_Change() List1.Clear List2.Clear End Sub Private Sub Inf_KeyPress(KeyAscii As Integer)

Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub ln_Click() Text1.Text = "ln(x)" Text1.SetFocus End Sub Private Sub log_Click() Text1.Text = "log(x)" Text1.SetFocus End Sub Private Sub Nueva_Click() Text1.Text = "" Inf.Text = "" Sup.Text = "" Text5.Text = "" List1.Clear List2.Clear Text2.Text = "" Text3.Text = "" Label1.Caption = "" Text4.Text = "" End Sub Private Sub Prueba5_Click() End Sub Private Sub Sal_Click() FormBiseccion.Visible = False FormPrincipal.Show

End Sub Private Sub Sen_Click() Text1.Text = "sin(x)" Text1.SetFocus End Sub Private Sub Sup_Change() List1.Clear List2.Clear End Sub Private Sub Sup_KeyPress(KeyAscii As Integer)

Inf.SetFocus Select Case KeyAscii Case 8, 46, 45

Sup.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub Tan_Click() Text1.Text = "tan(x)" Text1.SetFocus End Sub Private Sub Text1_Change()

KeyAscii = 0 End Select End Sub Private Sub Text2_Change() Label1.Caption = "" If Text2.Text <> "" Then If Text3.Text <> "" Then If Text4.Text <> "" Then Command1.Enabled = True Else Command1.Enabled = False End If Else Command1.Enabled = False End If Else Command1.Enabled = False End If End Sub

If Text1.Text <> "" Then Inf.Enabled = True Sup.Enabled = True Text5.Enabled = True Text2.Enabled = True Text3.Enabled = True Text4.Enabled = True Else Inf.Enabled = False Sup.Enabled = False Text5.Enabled = False End If Inf.Text = "" Sup.Text = "" Text5.Text = "" List1.Clear List2.Clear Text2.Text = "" Text3.Text = "" Label1.Caption = "" Text4.Text = "" End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 13 KeyAscii = 0 Case 8, 33, 124, 105, 108 To 116, 97 To 101, 120, 94, 40 To 43, 44 To 46, 48 To 57, 78 Case Else

Private Sub Text2_KeyPress(KeyAscii As Integer) Text2.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub

Private Sub Text3_Change()

Label1.Caption = "" If Text2.Text <> "" Then If Text3.Text <> "" Then If Text4.Text <> "" Then Command1.Enabled = True Else Command1.Enabled = False End If Else Command1.Enabled = False End If Else Command1.Enabled = False

End If End Sub Private Sub Text3_KeyPress(KeyAscii As Integer) Text3.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub Text4_Change() Label1.Caption = "" If Text2.Text <> "" Then If Text3.Text <> "" Then If Text4.Text <> "" Then Command1.Enabled = True Else Command1.Enabled = False End If Else Command1.Enabled = False End If Else Command1.Enabled = False End If End Sub Private Sub Text4_KeyPress(KeyAscii As Integer) Text4.SetFocus Select Case KeyAscii Case 8, 46, 45

Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub Text5_Change() List1.Clear List2.Clear End Sub Private Sub Text5_KeyPress(KeyAscii As Integer) Text5.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub

CDIGO CORRESPONDIENTE A LOS PROCEDIMIENTOS DEL METODO DE FACTORES CUADRATICOS


Option Explicit Dim B1(1000000) As String Dim b2(1000000) As String Dim c(1000000) As String Dim d(1000000) As String Dim r(1000000) As String Dim s(1000000) As String Dim p(1000000) As String Dim Q(1000000) As String Dim deltap(1000000) As String Dim deltaq(1000000) As String Dim pnu, n Dim N1, N2 As String Dim y(1000000) As String Dim Y1(1000000) As String Dim i Private Sub a0_Change() If a1.Text <> "" Then If a2.Text <> "" Then If a3.Text <> "" Then If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True Command2.Enabled = True Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If

End Sub Private Sub a0_KeyPress(KeyAscii As Integer) a0.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub a1_Change()

If a1.Text <> "" Then If a2.Text <> "" Then If a3.Text <> "" Then If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True Command2.Enabled = True Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else

Iteraciones.Enabled = False Command2.Enabled = False End If

Private Sub a2_KeyPress(KeyAscii As Integer) a2.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub a3_Change() If a1.Text <> "" Then If a2.Text <> "" Then If a3.Text <> "" Then If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True Command2.Enabled = True Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If

End Sub Private Sub a1_KeyPress(KeyAscii As Integer) a1.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub a2_Change() If a1.Text <> "" Then If a2.Text <> "" Then If a3.Text <> "" Then If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True Command2.Enabled = True Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If

End Sub Private Sub a3_KeyPress(KeyAscii As Integer) a3.SetFocus Select Case KeyAscii Case 8, 46, 45

End Sub

Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub a4_Change() If a1.Text <> "" Then If a2.Text <> "" Then If a3.Text <> "" Then If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True Command2.Enabled = True Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If

If Iteraciones.Text <> "" Then If a1.Text <> "" Then If a2.Text <> "" And a2.Text <> "0" Then

If a3.Text <> "" Then If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True End If End If End If End If Else MsgBox "Aplica la formula", "0", "Aviso"

End If Else MsgBox "Faltan datos", "0", "Aviso" Exit Sub End If

If Iteraciones.Text < 1000000 Then If Iteraciones.Text <> "" Then

p(0) = Val(p1.Text) Q(0) = Val(q1.Text) n = Val(Iteraciones.Text) For i = 0 To Val(n) B1(i) = Val(a1.Text) - (Val(p(i)) * Val(a0.Text)) b2(i) = Val(a2.Text) - ((Val(p(i))) * (Val(B1(i)))) ((Val(Q(i))) * Val(a0.Text)) r(i) = (a3.Text) - ((p(i)) * (b2(i))) - ((Q(i)) * (B1(i))) s(i) = (a4.Text) - ((Q(i)) * (b2(i)))

End Sub Private Sub a4_KeyPress(KeyAscii As Integer) a4.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub Calc_Click()

p(i + 1) = ((a3.Text) - (Q(i)) * (B1(i))) / ((b2(i))) Q(i + 1) = (a4.Text) / (b2(i)) deltap(i) = r(i) / b2(i) deltaq(i) = s(i) / b2(i)

y(i) = Val(((a3.Text) - (Q(i)) * (B1(i))) / ((b2(i)))) + Val((r(i) / b2(i))) Y1(i) = Val((a4.Text) / (b2(i))) + Val(s(i) / b2(i)) Next i Valp.Text = Round(p(Val(Iteraciones.Text)), 2) Valq.Text = Round(Q(Val(Iteraciones.Text)), 2) Valb0.Text = Round(Val(a0.Text), 2) Valb1.Text = Round(B1(Val(Iteraciones.Text)), 2) Valb2.Text = Round(b2(Val(Iteraciones.Text)), 2) ValR.Text = Round(r(Val(Iteraciones.Text)), 2) ValS.Text = Round(s(Val(Iteraciones.Text)), 2) Else Valp.Text = "" Valq.Text = "" Valb0.Text = "" Valb1.Text = "" Valb2.Text = "" ValR.Text = "" ValS.Text = "" End If Else Valp.Text = "" Valq.Text = "" Valb0.Text = "" Valb1.Text = "" Valb2.Text = "" ValR.Text = "" ValS.Text = "" MsgBox "Limite de iteraciones maximo exedido", "1", "Aviso" End If Else Valp.Text = "" Valq.Text = "" Valb0.Text = "" Valb1.Text = "" Valb2.Text = "" ValR.Text = "" ValS.Text = "" End If End Sub Private Sub Command2_Click() If Iteraciones.Text <> "" Then If a1.Text <> "" Then If a2.Text <> "" Then If a3.Text <> "" Then

If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True If ((Valp.Text * Valp.Text) - 4 * Valq.Text) > 0 Then Raiz1.Caption = Round((-Valp.Text + Sqr((Valp.Text * Valp.Text) - 4 * Valq.Text)) / 2, 3) Raiz2.Caption = Round((-Valp.Text Sqr((Valp.Text * Valp.Text) - 4 * Valq.Text)) / 2, 3) Else Raiz1.Caption = "" Raiz2.Caption = "" MsgBox "Algunar raices son complejas", "1", "Aviso" End If If Valb0.Text <> 0 Then If ((Valb1.Text * Valb1.Text) - 4 * (Valb0.Text * Valb2.Text)) > 0 Then Raiz3.Caption = Round((-Valb1.Text + Sqr((Valb1.Text * Valb1.Text) - 4 * Valb0.Text * Valb2.Text)) / 2, 3) Raiz4.Caption = Round((-Valb1.Text Sqr((Valb1.Text * Valb1.Text) - 4 * Valb0.Text * Valb2.Text)) / 2, 3) Else Raiz3.Caption = "" Raiz4.Caption = "" MsgBox "Algunar raices son complejas", "1", "Aviso" End If Else If Val(Valb1.Text) = "0" Then Raiz3.Caption = "" Else Raiz3.Caption = -Val(Valb2.Text) / Val(Valb1.Text) End If Raiz4.Caption = "" End If End If End If End If End If End If Else Iteraciones.Enabled = False MsgBox "Faltan datos", "1", "Aviso"

End If Else MsgBox "Introduce el nmero de iteraciones", "1", "Aviso" End If End Sub Private Sub Form_Load() Command2.Enabled = False Iteraciones.Enabled = False Valp.Enabled = False Valq.Enabled = False Valb0.Enabled = False Valb1.Enabled = False Valb2.Enabled = False ValR.Enabled = False ValS.Enabled = False End Sub Private Sub Iteraciones_Change() If Iteraciones.Text <> "" Then If a1.Text <> "" Then If a2.Text <> "" And a2.Text <> "0" Then If a3.Text <> "" Then If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True End If End If End If End If Else MsgBox "Aplica la formula", "0", "Aviso" End If Else MsgBox "Faltan datos", "0", "Aviso" Exit Sub End If If Iteraciones.Text < 1000000 Then If Iteraciones.Text <> "" Then p(0) = Val(p1.Text) Q(0) = Val(q1.Text) n = Val(Iteraciones.Text)

B1(i) = Val(a1.Text) - (Val(p(i)) * Val(a0.Text)) b2(i) = Val(a2.Text) - ((Val(p(i))) * (Val(B1(i)))) ((Val(Q(i))) * Val(a0.Text)) r(i) = (a3.Text) - ((p(i)) * (b2(i))) - ((Q(i)) * (B1(i))) s(i) = (a4.Text) - ((Q(i)) * (b2(i)))

p(i + 1) = ((a3.Text) - (Q(i)) * (B1(i))) / ((b2(i))) Q(i + 1) = (a4.Text) / (b2(i)) deltap(i) = r(i) / b2(i) deltaq(i) = s(i) / b2(i) y(i) = Val(((a3.Text) - (Q(i)) * (B1(i))) / ((b2(i)))) + Val((r(i) / b2(i))) Y1(i) = Val((a4.Text) / (b2(i))) + Val(s(i) / b2(i)) Next i Valp.Text = Round(p(Val(Iteraciones.Text)), 2) Valq.Text = Round(Q(Val(Iteraciones.Text)), 2) Valb0.Text = Round(Val(a0.Text), 2) Valb1.Text = Round(B1(Val(Iteraciones.Text)), 2) Valb2.Text = Round(b2(Val(Iteraciones.Text)), 2) ValR.Text = Round(r(Val(Iteraciones.Text)), 2) ValS.Text = Round(s(Val(Iteraciones.Text)), 2) Else Valp.Text = "" Valq.Text = "" Valb0.Text = "" Valb1.Text = "" Valb2.Text = "" ValR.Text = "" ValS.Text = "" End If Else Valp.Text = "" Valq.Text = "" Valb0.Text = "" Valb1.Text = "" Valb2.Text = "" ValR.Text = "" ValS.Text = "" MsgBox "Limite de iteraciones maximo exedido", "1", "Aviso" End If Else

For i = 0 To Val(n) Valp.Text = ""

Valq.Text = "" Valb0.Text = "" Valb1.Text = "" Valb2.Text = "" ValR.Text = "" ValS.Text = "" End If End Sub Private Sub p1_Change() If a1.Text <> "" Then If a2.Text <> "" Then If a3.Text <> "" Then If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True Command2.Enabled = True Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If End Sub Private Sub p1_KeyPress(KeyAscii As Integer) p1.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0

End Select End Sub Private Sub q1_Change() If a1.Text <> "" Then If a2.Text <> "" Then If a3.Text <> "" Then If a4.Text <> "" Then If p1.Text <> "" Then If q1.Text <> "" Then Iteraciones.Enabled = True Command2.Enabled = True Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If Else Iteraciones.Enabled = False Command2.Enabled = False End If End Sub Private Sub q1_KeyPress(KeyAscii As Integer) q1.SetFocus Select Case KeyAscii Case 8, 46, 45 Case Is < 48, Is > 57 KeyAscii = 0 End Select End Sub Private Sub Salir_Click() FormLin.Visible = False FormPrincipal.Show End Sub

CDIGO CORRESPONDIENTE A LOS PROCEDIMIENTOS DEL METODO DE NEWTONRAPHSON


End If Function F(ByVal x As Double) As Double Dim Formula As String Dim Funct As New clsMathParser Formula = TextEc.Text Funct.StoreExpression (Formula) F = Funct.Eval1(x) End Function Private Sub Calcular_Click() If TextEc.Text = "0" Then MsgBox "Debes introducir una funcion de X diferente de 0", 0, "Aviso" Else If TextEc.Text <> "" And TextX.Text <> "" And TextN.Text <> "" Then xi = TextX.Text DeltaX = 0.000001 n = TextN.Text For contador = 1 To n inc = xi + DeltaX DF = (F(inc) - F(xi)) / DeltaX Xi1 = xi - (F(xi) / DF) xi = Xi1 End If End Sub Private Sub Men_Click() FormNewton.Visible = False End Sub Private Sub TextEc_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 13 KeyAscii = 0 Case 8, 33, 124, 105, 108 To 116, 97 To 101, 120, 94, 40 To 43, 44 To 46, 48 To 57, 78 Case Else KeyAscii = 0 End Select End Sub Private Sub TextN_KeyPress(KeyAscii As Integer) If (KeyAscii < 45 Or KeyAscii > 46) Then If (KeyAscii < 48 Or KeyAscii > 57) Then If (KeyAscii <> 8) Then KeyAscii = 0 End If End If End Sub Private Sub TextX_KeyPress(KeyAscii As Integer) If (KeyAscii < 45 Or KeyAscii > 46) Then If (KeyAscii < 48 Or KeyAscii > 57) Then If (KeyAscii <> 8) Then KeyAscii = 0 End If End If End Sub

LabelRaiz.Caption = Xi1 Next contador Label7.Caption = F(Xi1)

FUNCIONAMIENTO DEL METODO DE REGLA FALSA

FUNCIONAMIENTO DEL METODO DE BISECCION

FUNCIONAMIENTO DEL METODO DE FACTORES CUADRATICOS

FUNCIONAMIENTO DEL MTODO DE NEWTON-RAPHSON

METODOLOGA.- Primero iniciamos el programa con la opcin EXE Estndar, luego pusimos los objetos en el formulario necesarios para el funcionamiento del mtodo y comenzamos a programar a partir de la declaracin de varios arreglos que iban cambiando su valor conforme al mtodo y el nmero de iteraciones, para el mtodo de regla falsa empleamos la misma programacin solo que cambiamos la frmula para dividir el intervalo.

Mientras que para el mtodo de Factores cuadrticos se definieron muchos arreglos que igual como es un mtodo iterativo iban cambiando su valor, por ejemplo en este mtodo se lo que iba cambiando era el valor de p que al aumentar el contador se le sumaba un incremento delta p y as sucesivamente, esto hacia que haca que el programa encontrara la raz. En el Mtodo de Newton-Raphson para calcular la derivada utilizamos la definicin de la que es:
.

Para que h tendiera a 0 este fue lo suficientemente pequeo para que el valor fuera preciso y exacto. El programa est como DeltaX = 0.000001 . Despus aplicaba el Mtodo enseado en clase tantas veces como el usuario haya puesto en su nmero de iteraciones. En esta aplicacin agregamos el plus de que el usuario ya no necesita calcular la derivada para aplicar el programa.

RESULTADOS.- El programa funciono correctamente, incluso le agregamos dos tablas para que tabulara la funcin en un intervalo que el usuario poda poner. Tambin pusimos en el programa de factores cuadrticos adems de que determinara estos factores y los mostrara una opcin que calcula las races aplicando la formula cuadrtica.

CONCLUSIONES.- Pudimos darnos cuenta que el mtodo de regla falsa algunas veces converge al valor de la raz ms rpido que el mtodo de biseccin sin embargo no siempre es as. Tambin que son muy tiles estos programas pero que tienen sus limitaciones, por ejemplo el de factores cuadrticos es muy bueno pero solo funcional para polinomios, y para los de regla falsa y biseccin debes de conocer un intervalo que encierre a la raz si no obtienes un valor errneo. Para el Mtodo de Newton-Raphson necesitas un valor de inicio estratgico para que la derivada converja a la raz, sino es as este dar valores errneos. Pero ms all de estas limitaciones los programas hacen los clculos en fracciones de segundo algo que sera muy difcil y tardado de hacer a mano. Al realizar estos programas reafirmamos los conocimientos que tenemos de la asignatura y desarrollamos nuestras habilidades para programar y resolver problemas ligadas a Visual Basic. Le agradecemos la constancia y el tiempo que nos dedic para ensearnos Anlisis Numrico y del Software Visual Basic.

You might also like