Ejercicios realizados

parent e25a9c74
......@@ -910,7 +910,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
......@@ -954,7 +954,6 @@
" eliminaColumna(A, Inver, pivote) #Elimina la columna por debajo del pivote\n",
" \n",
" #Eliminación de Gauss-Jordan hacia arriba\n",
" if verbosity: print('Ahora elimino hacia arriba: ')\n",
" for pivote in reversed(range(n)):\n",
" eliminaColumna(A, Inver, pivote, reverse=True) #Elimina la columna por arriba del pivote\n",
" return Inver\n",
......@@ -963,8 +962,7 @@
"\n",
"def eliminaColumna(A, Inver, p, reverse=False):\n",
" direction = range(p+1,len(A))\n",
" if reverse == True:\n",
" direction = reversed(range(p))\n",
" if reverse: direction = reversed(range(p))\n",
" A[p], Inver[p] = A[p] / A[p,p], Inver[p] / A[p,p]\n",
" for k in direction:\n",
" A[k], Inver[k] = A[p] * A[k,p] - A[k], Inver[p] * A[k,p] - Inver[k]\n",
......@@ -988,7 +986,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 7,
"metadata": {},
"outputs": [
{
......@@ -1009,6 +1007,7 @@
" [ 0. 2. -3. 4. 5.]\n",
" [ 0. 0. 0. 1. 8.]] \n",
"\n",
"[1, 2, 3, 4]\n",
"Elimino Columna 1 :\n",
" [[ 1. 0. -0.5 0.5 0.5]\n",
" [ 0. 0. -2. 1. -2. ]\n",
......@@ -1023,6 +1022,7 @@
" [ 0. 0. -2. 1. -2. ]\n",
" [ 0. 0. -0. -1. -8. ]] \n",
"\n",
"[2, 3, 4]\n",
"Elimino Columna 2 :\n",
" [[ 1. 0. -0.5 0.5 0.5]\n",
" [-0. 1. -1.5 2. 2.5]\n",
......@@ -1030,6 +1030,7 @@
" [-0. 0. 2. -1. 2. ]\n",
" [-0. 0. 0. 1. 8. ]] \n",
"\n",
"[3, 4]\n",
"Elimino Columna 3 :\n",
" [[ 1. 0. -0.5 0.5 0.5 ]\n",
" [-0. 1. -1.5 2. 2.5 ]\n",
......@@ -1044,6 +1045,7 @@
" [ 0. 0. 0. -1. -8. ]\n",
" [ 0. 0. 0. 0.5 -6. ]] \n",
"\n",
"[4]\n",
"Elimino Columna 4 :\n",
" [[ 1. 0. -0.5 0.5 0.5 ]\n",
" [-0. 1. -1.5 2. 2.5 ]\n",
......@@ -1051,6 +1053,7 @@
" [-0. -0. -0. 1. 8. ]\n",
" [-0. -0. -0. 0. 10. ]] \n",
"\n",
"[]\n",
"Elimino Columna 5 :\n",
" [[ 1. 0. -0.5 0.5 0.5 ]\n",
" [-0. 1. -1.5 2. 2.5 ]\n",
......@@ -1058,47 +1061,51 @@
" [-0. -0. -0. 1. 8. ]\n",
" [-0. -0. -0. 0. 1. ]] \n",
"\n",
"Ahora elimino hacia arriba: \n",
"[3, 2, 1, 0]\n",
"Elimino Columna 5 :\n",
" [[-1. -0. 0.5 -0.5 0. ]\n",
" [ 0. -1. 1.5 -2. 0. ]\n",
" [ 0. 0. -1. 0.25 0. ]\n",
" [ 0. 0. 0. -1. 0. ]\n",
" [[ 1. 0. -0.5 0.5 0.5 ]\n",
" [-0. 1. -1.5 2. 2.5 ]\n",
" [ 0. 0. 1. -0.25 -2. ]\n",
" [-0. -0. -0. 1. 8. ]\n",
" [-0. -0. -0. 0. 1. ]] \n",
"\n",
"[2, 1, 0]\n",
"Elimino Columna 4 :\n",
" [[ 1. 0. -0.5 0. 0. ]\n",
" [ 0. 1. -1.5 0. 0. ]\n",
" [-0. -0. 1. 0. -0. ]\n",
" [-0. -0. -0. 1. -0. ]\n",
" [[ 1. 0. -0.5 0.5 0.5 ]\n",
" [-0. 1. -1.5 2. 2.5 ]\n",
" [ 0. 0. 1. -0.25 -2. ]\n",
" [-0. -0. -0. 1. 8. ]\n",
" [-0. -0. -0. 0. 1. ]] \n",
"\n",
"[1, 0]\n",
"Elimino Columna 3 :\n",
" [[-1. 0. 0. -0. 0.]\n",
" [ 0. -1. 0. -0. 0.]\n",
" [-0. -0. 1. 0. -0.]\n",
" [-0. -0. -0. 1. -0.]\n",
" [-0. -0. -0. 0. 1.]] \n",
" [[ 1. 0. -0.5 0.5 0.5 ]\n",
" [-0. 1. -1.5 2. 2.5 ]\n",
" [ 0. 0. 1. -0.25 -2. ]\n",
" [-0. -0. -0. 1. 8. ]\n",
" [-0. -0. -0. 0. 1. ]] \n",
"\n",
"[0]\n",
"Elimino Columna 2 :\n",
" [[ 1. 0. -0. 0. -0.]\n",
" [-0. 1. -0. 0. -0.]\n",
" [-0. -0. 1. 0. -0.]\n",
" [-0. -0. -0. 1. -0.]\n",
" [-0. -0. -0. 0. 1.]] \n",
" [[ 1. 0. -0.5 0.5 0.5 ]\n",
" [-0. 1. -1.5 2. 2.5 ]\n",
" [ 0. 0. 1. -0.25 -2. ]\n",
" [-0. -0. -0. 1. 8. ]\n",
" [-0. -0. -0. 0. 1. ]] \n",
"\n",
"[]\n",
"Elimino Columna 1 :\n",
" [[ 1. 0. -0. 0. -0.]\n",
" [-0. 1. -0. 0. -0.]\n",
" [-0. -0. 1. 0. -0.]\n",
" [-0. -0. -0. 1. -0.]\n",
" [-0. -0. -0. 0. 1.]] \n",
" [[ 1. 0. -0.5 0.5 0.5 ]\n",
" [-0. 1. -1.5 2. 2.5 ]\n",
" [ 0. 0. 1. -0.25 -2. ]\n",
" [-0. -0. -0. 1. 8. ]\n",
" [-0. -0. -0. 0. 1. ]] \n",
"\n",
"Mi Inversa=\n",
" [[ 0.05 0.35 -0.1 0.55 -0.2 ]\n",
" [ 0.8 1.35 -0.6 0.3 -0.95]\n",
" [-0.25 0. 0.5 -0.25 0.25]\n",
" [-0.4 -0.8 0.8 -0.4 0.6 ]\n",
" [[ 0. 0. 0. 0.5 0. ]\n",
" [ 0.5 -0. -0. -0. -0. ]\n",
" [-0.25 0. 0.5 -0.25 0. ]\n",
" [ 0. -0. -0. -0. 1. ]\n",
" [ 0.05 0.1 -0.1 0.05 0.05]]\n",
"\n",
"np.linalg.inv=\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment