METODO GAUSS PARA RESOLVER ECUACIONES LINEALES
Publicado por mike (11 intervenciones) el 26/06/2019 03:22:03


**** PYTHON 2.7 ****
Saludos, queidos compañeros necesito ayuda
me gustaria saber como puedo hacer un programa capaz de solucionar ecuaciones lineales por el metodo de eliminacion de GAUSS.
¿COMO PUEDO REALIZARLO, Y SI ME PODRIAN EXPLICAR COMO FUNCIONA EL PROGRAMA DE FORMA , O SEA (COMO FUNCIONA CADA ELEMENTO EN PROGRMA)?
GRACIAS DE ANTE MANO
**EXPLICADO Y UTILIZANDO ESTA FORMA**
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def crearVector(M):
"""
Retorna un vector V de orden M con valores
iniciados en 0.0
"""
return [0.0 for j in range(M)]
def crearMatriz(M, N):
"""
Retorna una matriz de orden M x N con valores
iniciados en 0.0
"""
return [[0.0 for j in range(N)] for i in range(M)]
def mostrarMatriz(matriz):
"""
Escribe los elementos de la matriz de orden M x N.
"""
M = len(matriz)
N = len(matriz[0])
for i in range(M):
for j in range(N):
print matriz[i][j],
return
def mostrarValores(V):
"""
Escribe los elementos del vector V de orden N.
"""
N = len(V)
for i in range(N):
print V[i],
return
def entrarValores(matriz):
"""
Acepta los valores de los elementos de la
matriz de orden M x N.
"""
M = len(matriz)
N = len(matriz[0])
for i in range(M):
for j in range(N):
matriz[i][j] = float(raw_input("Matriz[" + str(i) + "][" + str(j) + "]? "))
return
def calcularVectores(matriz):
"""
Crea los vectores F y C (vector fila y vector columna)
en los que los valores de F son la suma de los vectores fila
de la matriz y los valores C son la suma de los vectores columna.
"""
M = len(matriz)
N = len(matriz[0])
F = crearVector(N)
C = crearVector(M)
DP = 0.0
DS = 0.0
for i in range(M):
DP = DP + matriz[i][i]
for j in range(N):
F[j] = F[j] + matriz[i][j]
C[i] = C[i] + matriz[i][j]
DS = DS + matriz[M - i - 1][i]
return F, C, DP, DS
def main():
M = int(raw_input("Cantidad Filas? "))
N = int(raw_input("Cantidad Columnas? "))
if (M > 0) and (N > 0):
A = crearMatriz(M, N)
entrarValores(A)
mostrarMatriz(A)
X, Y, W, Z = calcularVectores(A)
mostrarValores(X)
mostrarValores(Y)
print W
print Z
return
main()
Valora esta pregunta


0