Ejercicios sobre resolución de sistemas 3x3 por la regla de Cramer

Una forma de resolver sistemas compatibles consiste en usar determinantes y la regla de Cramer. En esta ocasión nuestro archivo LyX/pythontex permite generar cualquier número de ejercicios de este tipo. Los datos para resolver los problemas se pueden introducir de forma manual o de forma aleatoria y tenemos varios ejemplos en el código de fichero que nos pueden servir de ayuda para tener ideas de qué relación de ejercicios deseamos generar.

De nuevo casi todo el código esté en formato python/LaTeX y el uso de LyX es mínimo. Pero por mantener el mismo sistema de los ficheros de las entradas anteriores lo subo en formato LyX. El programa permite ajustar la salida a SCD o SCI (dependientes de un parámetro), en este último caso se discrimina en el código qué ecuación se debe eliminar así como la incógnita que se debe usar como parámetro.

Lo único que tendremos que adecuar en el fichero es:

# Resolvemos sistemas compatibles 3x3 de la forma A*X=B por la Regla de Cramer paso a paso
import random

# Podemos trabajar con dos opciones para las matrices A y B:
# m --> Datos manuales
# a --> Datos aleatorios
# Si no ponemos que opción es "m" siempre se hace con datos aleatorios.
opción = ''

# OPCIONES PERMITIDAS EN EL PROGRAMA PARA LOS TIPOS ALEATORIOS
# tipo -> cadena con los tipos permitidos siguientes:
# scd1 -> sistema compatible y determinado con soluciones enteras (el determinante se obliga a que sea +-1)
# scd2 -> sistema compatible y determinado con soluciones de cualquier tipo
# sci -> sistema compatible e indeterminado dependiente de un parámetro

# Valores entre los que obtener los coeficientes de los ejercicios que se obtienen de forma aleatoria
minimo = -5
maximo = 5

# Forma de definir los ejercicios que queremos obtener
# listaejercicios=[ tipo1, tipo2, ... ]

# Por ejemplo, con la lista siguiente se obtienen 5 ejercicios de órdenes y tipos especificados
# listaejercicios = ["scd1","scd2","scd2","sci","sci"]

# Otras formas de obtener listas de ejercicios
tipos = ['scd1', 'scd2', 'sci']

# Si queremos una lista de 4 ejercicios de cada tipo (12 ejercicios) podemos optar por
# listaejercicios = 4*tipos

# Si lo que queremos es 10 ejercicios aleatorios
# listaejercicios = [j for j in random.choices(tipos, k=10)]

# O si lo que queremos es 10 ejercicios aleatorios pero más del tipo SCD
# Estos pesos suponen que la probabilidad de seleccionar el valor "scd2" es el triple
# a la probabilidad de seleccionar cualquier otro
# pesos = [1, 3, 1]
# listaejercicios = [j for j in random.choices(tipos, pesos, k=10)]

# 15 ejercicios del tipo especificado
listaejercicios = 4*["scd1"]+6*["scd2"]+5*["sci"]

# OPCIONES PERMITIDAS EN EL PROGRAMA PARA INTRODUCIR LOS DATOS DE FORMA MANUAL
# Podemos optar por poner la matrices A y B de forma manual si optamos por opción='m'
# en ese caso debemos introducir los datos de la forma
# Ei = (A, B)
# Si los datos del ejercicio que introducimos no dan como resultado un SC no se tienen en cuenta.
# Además, para SCI solo se tienen en cuenta los que dependen de un parámetro (rango(A) = rango (A*) = 2)
# por ejemplo:
E1 = (Matrix([[1,1,0],[1,0,1],[0,1,1]]),Matrix([2,3,4]))
E2 = (Matrix([[1,1,1],[1,-2,3],[1,0,1]]),Matrix([1,2,5]))
E3 = (Matrix([[1,1,-1],[3,-2,1],[1,3,-2]]),Matrix([6,-5,14]))
E4 = (Matrix([[1,1,1],[2,4,-2],[1,2,-1]]),Matrix([0,4,2]))
E5 = (Matrix([[1,2,1],[1,2,1],[1,2,-1]]),Matrix([0,0,2]))
# Este ejercicio que sigue no se tendría en cuenta
E6 = (Matrix([[1,2,1],[1,2,1],[1,2,-1]]),Matrix([0,2,2]))
E7 = (Matrix([[0,0,0],[0,1,1],[0,1,-1]]),Matrix([0,3,-1]))
E8 = (Matrix([[1,0,1],[0,0,0],[1,0,-1]]),Matrix([3,0,-1]))
E9 = (Matrix([[1,1,1],[2,2,2],[1,0,-1]]),Matrix([3,6,-1]))
E10 = (Matrix([[1,-1,0],[1,-1,1],[-1,1,1]]),Matrix([1,9,7]))

# Número máximo de ejercicios.
# Si ponemos más de 15 tenemos que aumentar este valor para que se construya
# bien la lista de ejercicios. Si tenemos definidos 10 ejercicios y aquí ponemos
# 3, solo se resolveran los 3 primeros: E1, E2 y E3
maxejer = 10

Tal cuál está por defecto, obtenemos 15 ejercicios del tipo especificado en la variable listaejercicios de los cuales 4 tienen soluciones enteras, 6 puede que no y 5 son SCI dependientes de un parámetro.

Con esos valores, un posible resultado de la compilación se puede descargar en el pdf final disponible al final del artículo. A continuación solo muestro el resultado del primero de cada tipo en formato html (ejercicios 1, 5 y 11):

Regla de Cramer para sistemas 3x3

Si tenemos un sistema {a1,1x+a1,2y+a1,3z=b1a2,1x+a2,2y+a2,3z=b2a3,1x+a3,2y+a3,3z=b3\left\{ \begin{aligned}a_{1,1}x+a_{1,2}y+a_{1,3}z & = & b_{1}\\ a_{2,1}x+a_{2,2}y+a_{2,3}z & = & b_{2}\\ a_{3,1}x+a_{3,2}y+a_{3,3}z & = & b_{3} \end{aligned} \right.  que en forma matricial es de la forma AX=BA\cdot X=B , es decir (a1,1a1,2a1,3a2,1a2,2a2,3a3,1a3,2a3,3)(xyz)=(b1b2b3)\begin{pmatrix}a_{1,1} & a_{1,2} & a_{1,3}\\ a_{2,1} & a_{2,2} & a_{2,3}\\ a_{3,1} & a_{3,2} & a_{3,3} \end{pmatrix}\cdot\begin{pmatrix}x\\ y\\ z \end{pmatrix}=\begin{pmatrix}b_{1}\\ b_{2}\\ b_{3} \end{pmatrix} en el que A0,|A|\mathrel{\char`≠}0,entonces

x=b1a1,2a1,3b2a2,2a2,3b3a3,2a3,3Ax=\dfrac{\begin{vmatrix}b_{1} & a_{1,2} & a_{1,3}\\ b_{2} & a_{2,2} & a_{2,3}\\ b_{3} & a_{3,2} & a_{3,3} \end{vmatrix}}{|A|} y=a1,1b1a1,3a2,1b2a2,3a3,1b3a3,3Ay=\dfrac{\begin{vmatrix}a_{1,1} & b_{1} & a_{1,3}\\ a_{2,1} & b_{2} & a_{2,3}\\ a_{3,1} & b_{3} & a_{3,3} \end{vmatrix}}{|A|} z=a1,1a1,2b1a2,1a2,2b2a3,1a3,2b3Az=\dfrac{\begin{vmatrix}a_{1,1} & a_{1,2} & b_{1}\\ a_{2,1} & a_{2,2} & b_{2}\\ a_{3,1} & a_{3,2} & b_{3} \end{vmatrix}}{|A|}

En el caso de que A=0|A|=0 y rango(A)=rango(A)rango(A)=rango(A^{*}) (SCI) podemos aplicar Cramer introduciendo parámetros a partir de un menor de AA con determinante no nulo.

  1. Resuelve por la regla de Cramer el sistema:

    {4y+5z=53x+4y=12xy+2z=2\left\{ \begin{aligned}4y+5z & = & 5\\ 3x+4y & = & 1\\ -2x-y+2z & = & -2 \end{aligned} \right.

    Solución:

    El sistema, en forma matricial AX=BA\cdot X=B, se puede escribir como:

    (045340212)(xyz)=(512)\left(\begin{matrix}0 & 4 & 5\\ 3 & 4 & 0\\ -2 & -1 & 2 \end{matrix}\right)\cdot\left(\begin{matrix}x\\ y\\ z \end{matrix}\right)=\left(\begin{matrix}5\\ 1\\ -2 \end{matrix}\right)

    Además, su matriz ampliada es

    image

    Calculemos el determinante de AA:

    A=045340212=\left|A\right|=\begin{vmatrix}0 & 4 & 5\\ 3 & 4 & 0\\ -2 & -1 & 2 \end{vmatrix}= 045340212045340\begin{array}{c} \begin{vmatrix}0 & 4 & 5\\ 3 & 4 & 0\\ -2 & -1 & 2 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} 0 & 4 & 5\\ 3 & 4 & 0 \end{array}} \end{array}

    =[042+3(1)5+(2)40][54(2)+0(1)0+243]=\left[0\cdot4\cdot2+3\left(-1\right)5+\left(-2\right)4\cdot0\right]-\left[5\cdot4\left(-2\right)+0\left(-1\right)0+2\cdot4\cdot3\right]=(15)(16)=1=\left(-15\right)-\left(-16\right)=1

    Como A0Rango(A)=Rango(A)=3\left|A\right|\mathrel{\char`≠}0\Rightarrow Rango(A)=Rango(A^{*})=3 tenemos un SCD (tiene una sola solución)

    Ax=545140212=\left|A_{x}\right|=\begin{vmatrix}5 & 4 & 5\\ 1 & 4 & 0\\ -2 & -1 & 2 \end{vmatrix}= 545140212545140\begin{array}{c} \begin{vmatrix}5 & 4 & 5\\ 1 & 4 & 0\\ -2 & -1 & 2 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} 5 & 4 & 5\\ 1 & 4 & 0 \end{array}} \end{array}

    =[542+1(1)5+(2)40][54(2)+0(1)5+241]=\left[5\cdot4\cdot2+1\left(-1\right)5+\left(-2\right)4\cdot0\right]-\left[5\cdot4\left(-2\right)+0\left(-1\right)5+2\cdot4\cdot1\right]=(35)(32)=67=\left(35\right)-\left(-32\right)=67

    x=5451402121=671=67\Rightarrow x=\dfrac{\begin{vmatrix}5 & 4 & 5\\ 1 & 4 & 0\\ -2 & -1 & 2 \end{vmatrix}}{1}=\dfrac{67}{1}=67

    Ay=055310222=\left|A_{y}\right|=\begin{vmatrix}0 & 5 & 5\\ 3 & 1 & 0\\ -2 & -2 & 2 \end{vmatrix}= 055310222055310\begin{array}{c} \begin{vmatrix}0 & 5 & 5\\ 3 & 1 & 0\\ -2 & -2 & 2 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} 0 & 5 & 5\\ 3 & 1 & 0 \end{array}} \end{array}

    =[012+3(2)5+(2)50][51(2)+0(2)0+253]=\left[0\cdot1\cdot2+3\left(-2\right)5+\left(-2\right)5\cdot0\right]-\left[5\cdot1\left(-2\right)+0\left(-2\right)0+2\cdot5\cdot3\right]=(30)(20)=50=\left(-30\right)-\left(20\right)=-50

    y=0553102221=501=50\Rightarrow y=\dfrac{\begin{vmatrix}0 & 5 & 5\\ 3 & 1 & 0\\ -2 & -2 & 2 \end{vmatrix}}{1}=\dfrac{-50}{1}=-50

    Az=045341212=\left|A_{z}\right|=\begin{vmatrix}0 & 4 & 5\\ 3 & 4 & 1\\ -2 & -1 & -2 \end{vmatrix}= 045341212045341\begin{array}{c} \begin{vmatrix}0 & 4 & 5\\ 3 & 4 & 1\\ -2 & -1 & -2 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} 0 & 4 & 5\\ 3 & 4 & 1 \end{array}} \end{array}

    =[04(2)+3(1)5+(2)41][54(2)+1(1)0+(2)43]=\left[0\cdot4\left(-2\right)+3\left(-1\right)5+\left(-2\right)4\cdot1\right]-\left[5\cdot4\left(-2\right)+1\left(-1\right)0+\left(-2\right)4\cdot3\right]=(23)(64)=41=\left(-23\right)-\left(-64\right)=41

    z=0453412121=411=41\Rightarrow z=\dfrac{\begin{vmatrix}0 & 4 & 5\\ 3 & 4 & 1\\ -2 & -1 & -2 \end{vmatrix}}{1}=\dfrac{41}{1}=41

    Por tanto {x=67y=50z=41\left\{ \begin{aligned}x & = & 67\\ y & = & -50\\ z & = & 41 \end{aligned} \right.

  2. Resuelve por la regla de Cramer el sistema:

    {2x+3y4z=23x+4y+5z=15x+4y+4z=5\left\{ \begin{aligned}2x+3y-4z & = & -2\\ -3x+4y+5z & = & 1\\ -5x+4y+4z & = & -5 \end{aligned} \right.

    Solución:

    El sistema, en forma matricial AX=BA\cdot X=B, se puede escribir como:

    (234345544)(xyz)=(215)\left(\begin{matrix}2 & 3 & -4\\ -3 & 4 & 5\\ -5 & 4 & 4 \end{matrix}\right)\cdot\left(\begin{matrix}x\\ y\\ z \end{matrix}\right)=\left(\begin{matrix}-2\\ 1\\ -5 \end{matrix}\right)

    Además, su matriz ampliada es

    image1

    Calculemos el determinante de AA:

    A=234345544=\left|A\right|=\begin{vmatrix}2 & 3 & -4\\ -3 & 4 & 5\\ -5 & 4 & 4 \end{vmatrix}= 234345544234345\begin{array}{c} \begin{vmatrix}2 & 3 & -4\\ -3 & 4 & 5\\ -5 & 4 & 4 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} 2 & 3 & -4\\ -3 & 4 & 5 \end{array}} \end{array}

    =[244+(3)4(4)+(5)35][(4)4(5)+542+43(3)]=\left[2\cdot4\cdot4+\left(-3\right)4\left(-4\right)+\left(-5\right)3\cdot5\right]-\left[\left(-4\right)4\left(-5\right)+5\cdot4\cdot2+4\cdot3\left(-3\right)\right]=(5)(84)=79=\left(5\right)-\left(84\right)=-79

    Como A0Rango(A)=Rango(A)=3\left|A\right|\mathrel{\char`≠}0\Rightarrow Rango(A)=Rango(A^{*})=3 tenemos un SCD (tiene una sola solución)

    Ax=234145544=\left|A_{x}\right|=\begin{vmatrix}-2 & 3 & -4\\ 1 & 4 & 5\\ -5 & 4 & 4 \end{vmatrix}= 234145544234145\begin{array}{c} \begin{vmatrix}-2 & 3 & -4\\ 1 & 4 & 5\\ -5 & 4 & 4 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} -2 & 3 & -4\\ 1 & 4 & 5 \end{array}} \end{array}

    =[(2)44+14(4)+(5)35][(4)4(5)+54(2)+431]=\left[\left(-2\right)4\cdot4+1\cdot4\left(-4\right)+\left(-5\right)3\cdot5\right]-\left[\left(-4\right)4\left(-5\right)+5\cdot4\left(-2\right)+4\cdot3\cdot1\right]=(123)(52)=175=\left(-123\right)-\left(52\right)=-175

    x=23414554479=17579=17579\Rightarrow x=\dfrac{\begin{vmatrix}-2 & 3 & -4\\ 1 & 4 & 5\\ -5 & 4 & 4 \end{vmatrix}}{-79}=\dfrac{-175}{-79}=\frac{175}{79}

    Ay=224315554=\left|A_{y}\right|=\begin{vmatrix}2 & -2 & -4\\ -3 & 1 & 5\\ -5 & -5 & 4 \end{vmatrix}= 224315554224315\begin{array}{c} \begin{vmatrix}2 & -2 & -4\\ -3 & 1 & 5\\ -5 & -5 & 4 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} 2 & -2 & -4\\ -3 & 1 & 5 \end{array}} \end{array}

    =[214+(3)(5)(4)+(5)(2)5][(4)1(5)+5(5)2+4(2)(3)]=\left[2\cdot1\cdot4+\left(-3\right)\left(-5\right)\left(-4\right)+\left(-5\right)\left(-2\right)5\right]-\left[\left(-4\right)1\left(-5\right)+5\left(-5\right)2+4\left(-2\right)\left(-3\right)\right]=(2)(6)=4=\left(-2\right)-\left(-6\right)=4

    y=22431555479=479=479\Rightarrow y=\dfrac{\begin{vmatrix}2 & -2 & -4\\ -3 & 1 & 5\\ -5 & -5 & 4 \end{vmatrix}}{-79}=\dfrac{4}{-79}=-\frac{4}{79}

    Az=232341545=\left|A_{z}\right|=\begin{vmatrix}2 & 3 & -2\\ -3 & 4 & 1\\ -5 & 4 & -5 \end{vmatrix}= 232341545232341\begin{array}{c} \begin{vmatrix}2 & 3 & -2\\ -3 & 4 & 1\\ -5 & 4 & -5 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} 2 & 3 & -2\\ -3 & 4 & 1 \end{array}} \end{array}

    =[24(5)+(3)4(2)+(5)31][(2)4(5)+142+(5)3(3)]=\left[2\cdot4\left(-5\right)+\left(-3\right)4\left(-2\right)+\left(-5\right)3\cdot1\right]-\left[\left(-2\right)4\left(-5\right)+1\cdot4\cdot2+\left(-5\right)3\left(-3\right)\right]=(31)(93)=124=\left(-31\right)-\left(93\right)=-124

    z=23234154579=12479=12479\Rightarrow z=\dfrac{\begin{vmatrix}2 & 3 & -2\\ -3 & 4 & 1\\ -5 & 4 & -5 \end{vmatrix}}{-79}=\dfrac{-124}{-79}=\frac{124}{79}

    Por tanto {x=17579y=479z=12479\left\{ \begin{aligned}x & = & \frac{175}{79}\\ y & = & -\frac{4}{79}\\ z & = & \frac{124}{79} \end{aligned} \right.

  3. Resuelve por la regla de Cramer el sistema:

    {2x2z=3x+2yz=44x4y=5\left\{ \begin{aligned}-2x-2z & = & 3\\ x+2y-z & = & 4\\ -4x-4y & = & -5 \end{aligned} \right.

    Solución:

    El sistema, en forma matricial AX=BA\cdot X=B, se puede escribir como:

    (202121440)(xyz)=(345)\left(\begin{matrix}-2 & 0 & -2\\ 1 & 2 & -1\\ -4 & -4 & 0 \end{matrix}\right)\cdot\left(\begin{matrix}x\\ y\\ z \end{matrix}\right)=\left(\begin{matrix}3\\ 4\\ -5 \end{matrix}\right)

    Además, su matriz ampliada es

    image2

    Calculemos el determinante de AA:

    A=202121440=\left|A\right|=\begin{vmatrix}-2 & 0 & -2\\ 1 & 2 & -1\\ -4 & -4 & 0 \end{vmatrix}= 202121440202121\begin{array}{c} \begin{vmatrix}-2 & 0 & -2\\ 1 & 2 & -1\\ -4 & -4 & 0 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} -2 & 0 & -2\\ 1 & 2 & -1 \end{array}} \end{array}

    =[(2)20+1(4)(2)+(4)0(1)][(2)2(4)+(1)(4)(2)+001]=\left[\left(-2\right)2\cdot0+1\left(-4\right)\left(-2\right)+\left(-4\right)0\left(-1\right)\right]-\left[\left(-2\right)2\left(-4\right)+\left(-1\right)\left(-4\right)\left(-2\right)+0\cdot0\cdot1\right]=(8)(8)=0=\left(8\right)-\left(8\right)=0

    Como

    A3,3=2012=\left|A_{3,3}\right|=\begin{vmatrix}-2 & 0\\ 1 & 2 \end{vmatrix}=

    =[(2)2][01]=\left[\left(-2\right)2\right]-\left[0\cdot1\right]=(4)(0)=4=\left(-4\right)-\left(0\right)=-4

    y como

    A3=203124445=\left|A_{3}^{*}\right|=\begin{vmatrix}-2 & 0 & 3\\ 1 & 2 & 4\\ -4 & -4 & -5 \end{vmatrix}= 203124445203124\begin{array}{c} \begin{vmatrix}-2 & 0 & 3\\ 1 & 2 & 4\\ -4 & -4 & -5 \end{vmatrix}\\ \textcolor{cyan}{\begin{array}{ccc} -2 & 0 & 3\\ 1 & 2 & 4 \end{array}} \end{array}

    =[(2)2(5)+1(4)3+(4)04][32(4)+4(4)(2)+(5)01]=\left[\left(-2\right)2\left(-5\right)+1\left(-4\right)3+\left(-4\right)0\cdot4\right]-\left[3\cdot2\left(-4\right)+4\left(-4\right)\left(-2\right)+\left(-5\right)0\cdot1\right]=(8)(8)=0=\left(8\right)-\left(8\right)=0

    Se obtiene que Rango(A)=Rango(A)=2Rango(A)=Rango(A^{*})=2 y se trata de un SCI (infinitas soluciones).

    A partir de lo anterior podemos reescribir el sistema como sigue:

    • Eliminamos la fila 3
    • Introducimos el parámetro z=λz=\lambda

    y quedaría que: {2x=2λ+3x+2y=λ+4\left\{ \begin{aligned}-2x & = & 2\lambda+3\\ x+2y & = & \lambda+4 \end{aligned} \right. con A=2012=4|A|=\begin{vmatrix}-2 & 0\\ 1 & 2 \end{vmatrix}=-4

    Ax=2λ+30λ+42=\left|A_{x}\right|=\begin{vmatrix}2\lambda+3 & 0\\ \lambda+4 & 2 \end{vmatrix}=

    =[(2λ+3)2][0(λ+4)]=\left[\left(2\lambda+3\right)2\right]-\left[0\left(\lambda+4\right)\right]=(4λ+6)(0)=4λ+6=\left(4\lambda+6\right)-\left(0\right)=4\lambda+6

    x=2λ+30λ+424=4λ+64=λ32\Rightarrow x=\dfrac{\begin{vmatrix}2\lambda+3 & 0\\ \lambda+4 & 2 \end{vmatrix}}{-4}=\dfrac{4\lambda+6}{-4}=-\lambda-\frac{3}{2}

    Ay=22λ+31λ+4=\left|A_{y}\right|=\begin{vmatrix}-2 & 2\lambda+3\\ 1 & \lambda+4 \end{vmatrix}=

    =[(2)(λ+4)][(2λ+3)1]=\left[\left(-2\right)\left(\lambda+4\right)\right]-\left[\left(2\lambda+3\right)1\right]=(2λ8)(2λ+3)=4λ11=\left(-2\lambda-8\right)-\left(2\lambda+3\right)=-4\lambda-11

    y=22λ+31λ+44=4λ114=λ+114\Rightarrow y=\dfrac{\begin{vmatrix}-2 & 2\lambda+3\\ 1 & \lambda+4 \end{vmatrix}}{-4}=\dfrac{-4\lambda-11}{-4}=\lambda+\frac{11}{4}

    Por tanto {x=λ32y=λ+114z=λ\left\{ \begin{aligned}x & = & -\lambda-\frac{3}{2}\\ y & = & \lambda+\frac{11}{4}\\ z & = & \lambda \end{aligned} \right.

Enlaces al fichero fuente y al pdf final de una posible compilación.