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.html
108 lines (64 loc) · 3.13 KB
/
Sistemas de ecuaciones.html
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<html>
<body>
<script type="text/javascript">
var n = parseInt(prompt("1.- Array de 3x3 2.- Array de 4x4 3.- Array de 5x5"))
var newarray = new Array();
var resultado = new Array();
if(n==1){
n=3
} else if(n==2){
n=4
}else if (n==3){
n=5
}
for(var i=0;i<n;i++){
newarray[i]=new Array();
}
for(var i=0; i<n; i++) {
for(var j=0; j<n; j++) {
newarray[i][j] = prompt("Ingrese el valor ["+i+"] ["+j+"]")
newarray[i][j] = parseInt(newarray[i][j])
document.write(newarray[i][j]+" ")
}
resultado[i] = parseInt(prompt("Ingrese el resultado de la ecuacion #"+i))
document.write(" = ",resultado[i])
document.write("<br>")
}
if(n==3){
//pivote 1
var 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]= ((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]
document.write("X = "+resultado[0])
document.write(" Y = "+resultado[1])
document.write(" Z = "+resultado[2])
}
</script>
</body>
</html>