Saltar al contenido principal
LibreTexts Español

18.3: Usando la regla de Cramer para resolver Ax=b

  • Page ID
    114949
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Dejar\(Ax=b\) ser un sistema de ecuaciones\(n\) lineales en\(n\) variables tales que\(|A| \neq 0\). El sistema cuenta con una solución única dada por:

    \[x_1 = \frac{|A_1|}{|A|}, x_2 = \frac{|A_2|}{|A|}, \ldots, x_n = \frac{|A_n|}{|A|} \nonumber \]

    donde\(A_i\) se obtiene la matriz reemplazando columna\(i\)\(A\) de por\(b\). La siguiente función genera\(A_i\) reemplazando la columna\(i\) th\(A\) de por\(b\):

    def makeAi(A,i,b):
        '''Replace the ith column in A with b'''
        if type(A) == np.matrix:
            A = A.tolist()
        if type(b) == np.matrix:
            b = b.tolist()
        Ai = copy.deepcopy(A)
        for j in range(len(Ai)):
            Ai[j][i] = b[j][0]
        return Ai
    Hacer esto

    Crea una nueva función llamada CramersRule, que toma\(A\)\(b\) y devuelve\(x\) usando la regla de Cramer.

    Nota: Use numpy y NOT mydet para encontrar los determinantes requeridos. mydet es demasiado lento.

    # Stub code. Replace the np.linalg.solve code with your answer
    
    def cramersRule(A,b):
        detA = np.linalg.det(A)
        x = []    
        #####Start of your code here#####  
     
    
        #####End of your code here#####  
        
        return x
    Pregunta

    Pruebe su función CramersRule en el siguiente sistema de ecuaciones lineales:

    \[ x_1 + 2x_2 = 3 \nonumber \]

    \[3x_1 + x_2 = -1 \nonumber \]

    #Put your answer to the above question here
    Pregunta

    Verifique la respuesta anterior usando la función np.linalg.solve:

    #Put your answer to the above question here
    Pregunta

    Pruebe su función cramersRule en el siguiente sistema de ecuaciones lineales y verifique la respuesta usando la función np.linalg.solve:

    \[ x_1 + 2x_2 +x_3 = 9 \nonumber \]

    \[ x_1 + 3x_2 - x_3 = 4 \nonumber \]

    \[ x_1 + 4x_2 - x_3 = 7 \nonumber \]

    #Put your answer to the above question here
    Pregunta

    La regla de Cramer es un\(O(n!)\) algoritmo y la eliminación Gauss-Jordan (o Gaussiana) es\(O(n^3)\). ¿Qué ventajas tiene la regla de Cramer sobre la eliminación?


    This page titled 18.3: Usando la regla de Cramer para resolver Ax=b is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.