This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sistemas de ecuaciones.py
70 lines (49 loc) · 2.4 KB
/
sistemas de ecuaciones.py
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
n = int(input("1.- Array de 3x3 2.- Array de 4x4 3.- Array de 5x5"))
newarray = []
resultado = []
if n==1:
n=3
elif n==2:
n=4
elif n==3:
n=5
for i in range(n):
newarray.append([0]*n)
for i in range(0,n):
for j in range(0,n):
newarray[i][j]=int(input("Ingrese el valor"))
resultado.append(int(input("ingrese el resultado")))
if n==3:
#pivote 1
PA = newarray[0][0]
newarray[1][1] = ((newarray[0][0])*(newarray[1][1])-(newarray[1][0])*(newarray[0][1]))/1;
newarray[1][2]= ((newarray[0][0])*(newarray[1][2])-(newarray[1][0])*(newarray[0][2]))/1;
resultado[1]= ((newarray[0][0])*(resultado[1])-(newarray[1][0])*(resultado[0]))/1;
newarray[2][1]= ((newarray[0][0])*(newarray[2][1])-(newarray[2][0])*(newarray[0][1]))/1
newarray[2][2]= ((newarray[0][0])*(newarray[2][2])-(newarray[2][0])*(newarray[0][2]))/1
resultado[2]= ((newarray[0][0])*(resultado[2])-(newarray[2][0])*(resultado[0]))/1
newarray[1][0] = 0
newarray[2][0] = 0
#pivote 2
newarray[0][0]= ((newarray[1][1])*(newarray[0][0])-(newarray[0][1])*(newarray[1][0]))/PA
newarray[0][2]= ((newarray[1][1])*(newarray[0][2])-(newarray[0][1])*(newarray[1][2]))/PA
resultado[0]= ((newarray[1][1])*(resultado[0])-(newarray[0][1])*(resultado[1]))/PA
newarray[2][2]= ((newarray[1][1])*(newarray[2][2])-(newarray[2][1])*(newarray[1][2]))/PA
resultado[2]= ((newarray[1][1])*(resultado[2])-(newarray[2][1])*(resultado[1]))/PA
newarray[0][1] = 0
newarray[2][1] = 0
PA = newarray[1][1]
#pivote 3
newarray[0][0]= (int((newarray[2][2])*(newarray[0][0])-(newarray[0][2])*(newarray[2][0]))/PA)
resultado[0]= ((newarray[2][2])*(resultado[0])-(newarray[0][2])*(resultado[2]))/PA
newarray[1][1]= ((newarray[2][2])*(newarray[1][1])-(newarray[1][2])*(newarray[2][1]))/PA
resultado[1]= ((newarray[2][2])*(resultado[1])-(newarray[1][2])*(resultado[2]))/PA
newarray[0][2] = 0
newarray[1][2] = 0
#Resultado
resultado[0] = resultado[0]/newarray[0][0]
resultado[1] = resultado[1]/newarray[1][1]
resultado[2] = resultado[2]/newarray[2][2]
print(resultado[0])
print(resultado[1])
print(resultado[2])