0% found this document useful (0 votes)
22 views4 pages

Actividad Sugerida

This document describes a program that takes a matrix and converts it into a symmetric positive definite matrix using the Cholesky decomposition method. The program has interfaces to input a matrix, multiply it to obtain the symmetric matrix, calculate the Cholesky decomposition, and solve the system of linear equations to find the values of x1, x2, x3, x4. Buttons allow the user to perform the various steps and view the results.

Uploaded by

MO Ale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views4 pages

Actividad Sugerida

This document describes a program that takes a matrix and converts it into a symmetric positive definite matrix using the Cholesky decomposition method. The program has interfaces to input a matrix, multiply it to obtain the symmetric matrix, calculate the Cholesky decomposition, and solve the system of linear equations to find the values of x1, x2, x3, x4. Buttons allow the user to perform the various steps and view the results.

Uploaded by

MO Ale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

LABORATORIO 3 Solución de Sistema de Ecuaciones Lineales: Método de Cholesky

Actividad Sugerida

Desarrolle una aplicación que le permita convertir una matriz cualquiera en una matriz
simétrica positiva

INTERFAZ

Public Class Form1


Dim l(4, 4) As Single
Dim x1, x2, x3, x4, c1, c2, c3, c4 As Double

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


A.Rows.Add(4)
A.Rows(1).Cells(0).Value = "fila1"
A.Rows(2).Cells(0).Value = "fila2"
A.Rows(3).Cells(0).Value = "fila3"
A.Rows(4).Cells(0).Value = "fila4"
A.Rows(1).Cells(1).Value = -2
A.Rows(1).Cells(2).Value = 1.1
A.Rows(1).Cells(3).Value = -2
A.Rows(1).Cells(4).Value = -1.8
A.Rows(1).Cells(5).Value = 1
A.Rows(2).Cells(1).Value = 3.2
A.Rows(2).Cells(2).Value = 2.1
A.Rows(2).Cells(3).Value = 3.2
A.Rows(2).Cells(4).Value = 2.2
A.Rows(2).Cells(5).Value = 1
A.Rows(3).Cells(1).Value = 3.4
A.Rows(3).Cells(2).Value = 2.3
A.Rows(3).Cells(3).Value = 4.1
A.Rows(3).Cells(4).Value = 3.2
A.Rows(3).Cells(5).Value = 6
A.Rows(4).Cells(1).Value = 2.6
A.Rows(4).Cells(2).Value = 1.1
A.Rows(4).Cells(3).Value = -3.2
A.Rows(4).Cells(4).Value = 2.4
A.Rows(4).Cells(5).Value = -7

B.Rows.Add(4)
B.Rows(1).Cells(0).Value = "fila1"
B.Rows(2).Cells(0).Value = "fila2"
B.Rows(3).Cells(0).Value = "fila3"
B.Rows(4).Cells(0).Value = "fila4"
B.Rows(1).Cells(1).Value = -2
B.Rows(1).Cells(2).Value = 3.2
B.Rows(1).Cells(3).Value = 3.4
B.Rows(1).Cells(4).Value = 2.6
B.Rows(2).Cells(1).Value = 1.1
B.Rows(2).Cells(2).Value = 2.1
B.Rows(2).Cells(3).Value = 2.3
B.Rows(2).Cells(4).Value = 1.1
B.Rows(3).Cells(1).Value = -2
B.Rows(3).Cells(2).Value = 3.2
B.Rows(3).Cells(3).Value = 4.1
B.Rows(3).Cells(4).Value = -3.2
B.Rows(4).Cells(1).Value = -1.8
B.Rows(4).Cells(2).Value = 2.2
B.Rows(4).Cells(3).Value = 3.2
B.Rows(4).Cells(4).Value = 2.4

C.Rows.Add(4)
C.Rows(1).Cells(0).Value = "fila1"
C.Rows(2).Cells(0).Value = "fila2"
C.Rows(3).Cells(0).Value = "fila3"
C.Rows(4).Cells(0).Value = "fila4"
End Sub

Private Sub btnmultiplicar_Click(sender As Object, e As EventArgs) Handles btnmultiplicar.Click


Dim i As Integer
Dim g As Integer
Dim k As Integer
Dim t As Integer
i = i + 1
For i = 1 To 4
C.Rows(i).Cells(1).Value = (B.Rows(i).Cells(1).Value * A.Rows(1).Cells(1).Value) +
(B.Rows(i).Cells(2).Value * A.Rows(2).Cells(1).Value) + (B.Rows(i).Cells(3).Value *
A.Rows(3).Cells(1).Value) + (B.Rows(i).Cells(4).Value * A.Rows(4).Cells(1).Value)
Next i
For g = 1 To 4
C.Rows(g).Cells(2).Value = (B.Rows(g).Cells(1).Value * A.Rows(1).Cells(2).Value) +
(B.Rows(g).Cells(2).Value * A.Rows(2).Cells(2).Value) + (B.Rows(g).Cells(3).Value *
A.Rows(3).Cells(2).Value) + (B.Rows(g).Cells(4).Value * A.Rows(4).Cells(2).Value)
Next g
For k = 1 To 4
C.Rows(k).Cells(3).Value = (B.Rows(k).Cells(1).Value * A.Rows(1).Cells(3).Value) +
(B.Rows(k).Cells(2).Value * A.Rows(2).Cells(3).Value) + (B.Rows(k).Cells(3).Value *
A.Rows(3).Cells(3).Value) + (B.Rows(k).Cells(4).Value * A.Rows(4).Cells(3).Value)
Next k
For t = 1 To 4
C.Rows(t).Cells(4).Value = (B.Rows(t).Cells(1).Value * A.Rows(1).Cells(4).Value) +
(B.Rows(t).Cells(2).Value * A.Rows(2).Cells(4).Value) + (B.Rows(t).Cells(3).Value *
A.Rows(3).Cells(4).Value) + (B.Rows(t).Cells(4).Value * A.Rows(4).Cells(4).Value)
Next t
End Sub

 A la hora de presionar el botón de Multiplicar en el tercer DataGriedView


aparecerá la matriz simétrica de 4x4

Private Sub btncalcular_Click(sender As Object, e As EventArgs) Handles btncalcular.Click


l(1, 1) = (C.Rows(1).Cells(1).Value) ^ 0.5
l(2, 1) = (C.Rows(2).Cells(1).Value) / l(1, 1)
l(3, 1) = (C.Rows(3).Cells(1).Value) / l(1, 1)
l(4, 1) = (C.Rows(4).Cells(1).Value) / l(1, 1)
l(2, 2) = ((C.Rows(2).Cells(2).Value) - (l(2, 1)) ^ 2) ^ 0.5
l(3, 2) = ((C.Rows(3).Cells(2).Value) - l(2, 1) * l(3, 1)) / l(2, 2)
l(4, 2) = ((C.Rows(4).Cells(2).Value) - l(2, 1) * l(4, 1)) / l(2, 2)
l(3, 3) = ((C.Rows(3).Cells(3).Value) - (l(3, 1)) ^ 2 - (l(3, 2)) ^ 2) ^ 0.5
l(4, 3) = ((C.Rows(4).Cells(3).Value) - (l(4, 1) * l(3, 1)) - l(4, 2) * l(3, 2)) / l(3,
3)
l(4, 4) = ((C.Rows(4).Cells(4).Value) - (l(4, 1)) ^ 2 - (l(4, 2)) ^ 2 - (l(4, 3)) ^ 2) ^
0.5

c1 = (A.Rows(1).Cells(5).Value) / l(1, 1)
c2 = ((A.Rows(2).Cells(5).Value) - l(2, 1) * c1) / l(2, 2)
c3 = ((A.Rows(3).Cells(5).Value) - l(3, 1) * c1 - l(3, 2) * c2) / l(3, 3)
c4 = ((A.Rows(4).Cells(5).Value) - l(4, 1) * c1 - l(4, 2) * c2) / l(4, 4)

x4 = c4 / l(4, 4)
x3 = (c3 - l(4, 3) * x4) / l(3, 3)
x2 = (c2 - l(3, 2) * x3 - l(4, 2) * x4) / l(2, 2)
x1 = (c1 - l(1, 2) * x2 - l(1, 3) * x3 - l(1, 4) * x4) / l(1, 1)

txtx1.Text = x1
txtx2.Text = x2
txtx3.Text = x3
txtx4.Text = x4
End Sub

 Con ayuda de la formula cuando se presiona en el boton de Calcular apareceran los


datos de X1, X2, X3 y X4

Private Sub btndecimales_Click(sender As Object, e As EventArgs) Handles btndecimales.Click


txtx1.Text = FormatNumber(x1, 4)
txtx2.Text = FormatNumber(x2, 4)
txtx3.Text = FormatNumber(x3, 4)
txtx4.Text = FormatNumber(x4, 4)
End Sub

End Class

 Y luego con la formula hara que los datos de X1, X2, X3 y X4 tengan 4 decimales

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy