Sie sind auf Seite 1von 2

Mate

2 2 2
FindRoot 1.6 x 3.6 x y 7.8 x 2.6 y 5.2 0, 0.9 y 3.1 x 6.2 y 6.2 x 0 , x, 0.5 ,
y, 0.5

VB
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles
Button1.Click
Dim x As Double, xx As Double
Dim y As Double, yy As Double
Dim cont As Byte
Dim f1 As Double, df1x As Double, df1y As Double
Dim f2 As Double, df2x As Double, df2y As Double
Dim errorr As Double
errorr = Val(Terror.Text)
cont = 0
x = Val(tXo.Text)
y = Val(tYo.Text)
ListBox1.Items.Clear()
ListBox1.Items.Add(Format(cont, "00") & Space(10) & Format(x,
"#0.0000000") & Space(10) & Format(y, "#0.0000000"))
Do
xx = x
yy = y
f1 = 1.6 * x ^ 2 + 3.6 * x * y - 7.8 * x - 2.6 * y + 5.2
f2 = 0.9 * y ^ 2 + 3.1 * x ^ 2 + 6.2 * y - 6.2 * x
df1x = 3.2 * x + 3.6 * y - 7.8
df1y = 3.6 * x - 6.2
df2x = 6.2 * x - 6.2
df2y = 1.8 * y + 6.2
A(1, 1) = df1x
A(1, 2) = df1y
A(1, 3) = -f1
A(2, 1) = df2x
A(2, 2) = df2y
A(2, 3) = -f2
singular = 0
Call Gaussjordan()
If singular = 1 Then
MsgBox("el sistema no tiene sol")
End If
x = A(1, 3) + x
y = A(2, 3) + y
Eps = System.Math.Sqrt((x - xx) ^ 2 + (y - yy) ^ 2)
cont = cont + 1
ListBox1.Items.Add(Format(cont, "00") & Space(10) & Format(x,
"#0.0000000") & Space(10) & Format(y, "#0.0000000") & Space(10) & Format(Eps,
"#0.0000000"))
Loop Until Eps < errorr
txi.Text = x
tyi.Text = y
End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs)


Handles Button2.Click
End
End Sub

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs)


Handles MyBase.Load
N = 2
End Sub
End Class

MODULE
Public respuesta As Byte, singular As Byte, det As Double, Eps As Double
Public A(10, 10) As Double, N As Byte, i As Byte, j As Byte
Sub pivoteo(ByVal i)
Dim j As Byte, P As Byte, max As Single
singular = 0
max = System.Math.Abs(A(i, i))
P = i
If i < N Then
For j = i + 1 To N
If System.Math.Abs(A(j, i)) Then
P=j
End If
Next j
End If
If max <= 0.0000000001 Then
singular = 1
ElseIf P <> i Then
For j = 1 To N + 1
max = A(i, j)
A(i, j) = A(P, j)
A(P, j) = max
Next j
End If
End Sub
Sub Gaussjordan()
Dim i As Byte, j As Byte, k As Byte
det = 1
For i = 1 To N
Call pivoteo(i)
det = det * A(i, j)
If singular = 0 Then
For j = i + 1 To N + 1
A(i, j) = A(i, j) / A(i, i)
Next j
A(i, j) = 1
For k = 1 To N
If (k = i) Or (System.Math.Abs(A(k, i)) < 0.0000000001) Then
Else
For j = i + 1 To N + 1
A(k, j) = A(k, j) - A(k, i) * A(i, j)
Next j

End If
Next k

End If
Next i
End Sub
End Module

Das könnte Ihnen auch gefallen