Métodos iterativos

Introducción

Dado un sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\), un método iterativo para resolver dicho sistema consiste en hallar una sucesión de soluciones aproximadas \((\mathbf{x}^{(k)})_{k=0}^\infty\) tal que \(\displaystyle\lim_{k\to\infty}\mathbf{x}^{(k)}=\mathbf{x}\) donde \(\mathbf{x}\) es la solución del sistema.

Cuando escribimos que \(\displaystyle\lim_{k\to\infty}\mathbf{x}^{(k)}=\mathbf{x}\), queremos decir que dada una norma matricial \(\|\cdot\|\), \(\displaystyle\lim_{k\to\infty}\|\mathbf{x}^{(k)}-\mathbf{x}\|=0\).

Introducción

Los algoritmos numéricos basado en métodos iterativos tienen las propiedades siguientes:

  • obtienen una solución aproximada, al contrario de lo que pasaba con los métodos directos que hallaban una solución exacta del sistema lineal. Es decir, suponiendo que no hay errores en los datos ni en las operaciones aritméticas, la solución obtenida por un método iterativo es aproximada.

  • el número de pasos que hay que realizar para hallar la solución de un sistema lineal no está predeterminado de entrada.

Introducción

Tenemos entonces que establecer un criterio de parada de cara a obtener una solución aproximada del sistema lineal dado un umbral de error \(\epsilon\).

Concretamente, sea \((\mathbf{x}^{(k)})_{k=0}^\infty\) la sucesión de soluciones aproximadas cuyo límite es la solución exacta \(\mathbf{x}\) del sistema lineal, \(\|\cdot\|\) una norma vectorial y \(\epsilon\) un umbral de error.

Existen dos criterios de parada:

  • hallar el entero \(k\) tal que \(\|\mathbf{x}^{(k)}-\mathbf{x}^{(k-1)}\|<\epsilon\), (criterio del error absoluto)
  • hallar el entero \(k\) tal que \(\frac{\|\mathbf{x}^{(k)}-\mathbf{x}^{(k-1)}\|}{\|\mathbf{x}^{(k)}\|}<\epsilon\), (criterio del error relativo)

y adoptamos \(\mathbf{x}^{(k)}\) como solución aproximada del sistema lineal.

Construcción de la sucesión \(\mathbf{x}^{(k)}\)

Los métodos iterativos que vamos a ver construyen la sucesión de aproximaciones a la solución de forma iterativa usando una expresión de la forma siguiente: \[ \mathbf{x}^{(k)}=\mathbf{T}\mathbf{x}^{(k-1)}+\mathbf{c}, \] donde \(\mathbf{T}\) es la llamada matriz de iteración y \(\mathbf{c}\) el vector independiente del método iterativo en cuestión.

El método iterativo necesita una aproximación inicial \(\mathbf{x}^{(0)}\) que podemos suponer que vale \(\mathbf{0}\) o cualquier valor que queramos.

Veremos posteriomente que la convergencia del método iterativo depende sólo de la matriz de iteración \(\mathbf{T}\).

Construcción de la sucesión \(\mathbf{x}^{(k)}\)

¿Cómo se construye la expresión anterior que nos define la sucesión de aproximaciones \(\mathbf{x}^{(k)}\)?

La idea clave es transformar el sistema a resolver \(\mathbf{A}\mathbf{x}=\mathbf{b}\) en un sistema equivalente de la forma \(\mathbf{x}=\mathbf{T}\mathbf{x}+\mathbf{c}\) ya que si la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) converge a la solución del sistema \(\mathbf{x}\), dicha solución debe verificar \(\mathbf{x}=\mathbf{T}\mathbf{x}+\mathbf{c}\).

Métodos de Jacobi y Gauss Seidel

Método de Jacobi

Supongamos que los coeficientes \(a_{ii}\) de la matriz \(\mathbf{A}=(a_{ij})_{i,j=1,\ldots,n}\) del sistema a resolver \(\mathbf{A}\mathbf{x}=\mathbf{b}\) son todos diferentes de cero.

Fijaos que siempre existe una permutación de filas para que dicha condición se cumpla ya que, en caso contrario, la matriz del sistema sería singular y el sistema no tendría solución única.

Entonces para transformar el sistema \(\mathbf{A}\mathbf{x}=\mathbf{b}\) en un sistema equivalente de la forma \(\mathbf{x}=\mathbf{T}\mathbf{x}+\mathbf{c}\), podemos aislar las incógnitas \(x_i\) de la ecuación \(i\)-ésima de la forma siguiente: \[ \begin{align*} E_i:& a_{i1}x_1+a_{i2}x_2+\cdots +a_{ii}x_i+\cdots +a_{in}x_n=b_i,\ \Rightarrow\\ & x_i=\frac{1}{a_{ii}}(b_i-(a_{i1}x_1+\cdots+a_{i,i-1}x_{i-1}+a_{i,i+1}x_{i+1}+\cdots+a_{in}x_n)) \end{align*} \]

Método de Jacobi

Entonces, la matriz de iteración \(\mathbf{T}_J\) y el vector independiente \(\mathbf{c}_J\) serán los siguientes:

\[ \mathbf{T}_J=\begin{bmatrix}0&-\frac{a_{12}}{a_{11}}&\ldots&-\frac{a_{1n}}{a_{11}} \\-\frac{a_{21}}{a_{22}}&0&\ldots&-\frac{a_{2n}}{a_{22}} \\\vdots&\vdots&\ddots&\vdots \\-\frac{a_{n1}}{a_{nn}}&-\frac{a_{n2}}{a_{nn}}&\ldots&0 \\\end{bmatrix},\quad \mathbf{c}_J=\begin{bmatrix}\frac{b_{1}}{a_{11}} \\\frac{b_2}{a_{22}} \\\vdots \\\frac{b_n}{a_{nn}} \\\end{bmatrix}. \]

La sucesión \(\mathbf{x}^{(k)}\) se generará de la forma siguiente: \[ \begin{bmatrix}x_{1}^{(k)} \\x_2^{(k)} \\\vdots \\x_n^{(k)} \\\end{bmatrix}=\begin{bmatrix}0&-\frac{a_{12}}{a_{11}}&\ldots&-\frac{a_{1n}}{a_{11}} \\-\frac{a_{21}}{a_{22}}&0&\ldots&-\frac{a_{2n}}{a_{22}} \\\vdots&\vdots&\ddots&\vdots \\-\frac{a_{n1}}{a_{nn}}&-\frac{a_{n2}}{a_{nn}}&\ldots&0 \\\end{bmatrix}\begin{bmatrix}x_{1}^{(k-1)} \\x_2^{(k-1)} \\\vdots \\x_n^{(k-1)} \\\end{bmatrix}+\begin{bmatrix}\frac{b_{1}}{a_{11}} \\\frac{b_2}{a_{22}} \\\vdots \\\frac{b_n}{a_{nn}} \\\end{bmatrix} \]

Método de Jacobi

Vamos a escribir la matriz de iteración del método de Jacobi de otra forma.

Descomponemos la matriz del sistema \(\mathbf{A}=(a_{ij})_{i,j=1,\ldots,n}\) de la forma siguiente: \[ \mathbf{A}=\mathbf{D}+\mathbf{L}+\mathbf{U}, \] donde las matrices \(\mathbf{D}\), \(\mathbf{L}\) y \(\mathbf{U}\) contienen los elementos diagonales, los elementos por debajo de la diagonal y por encima de la diagonal respectivamente:

\[ \mathbf{D}=\begin{bmatrix}a_{11}&0&\ldots&0 \\0&a_{22}&\ldots&0 \\\vdots&\vdots&\ddots&\vdots \\0&0&\ldots&a_{nn} \\\end{bmatrix},\ \mathbf{L}=\begin{bmatrix}0&0&\ldots&0 \\a_{21}&0&\ldots&0 \\\vdots&\vdots&\ddots&\vdots \\a_{n1}&a_{n2}&\ldots&0 \\\end{bmatrix},\ \mathbf{U}=\begin{bmatrix}0&a_{12}&\ldots&a_{1n} \\0&0&\ldots&a_{2n} \\\vdots&\vdots&\ddots&\vdots \\0&0&\ldots&0 \\\end{bmatrix}. \]

Método de Jacobi

El sistema \(\mathbf{A}\mathbf{x}=\mathbf{b}\) puede escribirse como: \[ (\mathbf{D}+\mathbf{L}+\mathbf{U})\mathbf{x}=\mathbf{b}. \] Vamos a deducir el método de Jacobi a partir de las matrices anteriores.

  • Dejamos los elementos diagonales y “pasamos” los demás elementos al término de la derecha: \[ \mathbf{D}\mathbf{x}=-(\mathbf{L}+\mathbf{U})\mathbf{x}+\mathbf{b}. \]
  • Despejamos el vector \(\mathbf{x}\): \[ \mathbf{x}=-\mathbf{D}^{-1}(\mathbf{L}+\mathbf{U})\mathbf{x}+\mathbf{D}^{-1}\mathbf{b}. \]

Método de Jacobi

La sucesión de aproximaciones será: \[ \mathbf{x}^{(k)}=-\mathbf{D}^{-1}(\mathbf{L}+\mathbf{U})\mathbf{x}^{(k-1)}+\mathbf{D}^{-1}\mathbf{b}. \] Entonces, la matriz de iteración y el vector independiente del método de Jacobi serán: \[ \mathbf{T}_J=-\mathbf{D}^{-1}(\mathbf{L}+\mathbf{U}),\quad \mathbf{c}_J=\mathbf{D}^{-1}\mathbf{b}. \]

Método de Jacobi. Pseudocódigo

Vamos a dar el pseudocódigo del método de Jacobi usando como criterio de parada el criterio del error absoluto.

Para tener el pseudocódigo usando como criterio de parada el criterio del error relativo basta cambiar la línea de código

\(\|\mathbf{x}-\mathbf{X0}\| <\) TOL then

por

\(\frac{\|\mathbf{x}-\mathbf{X0}\|}{\|\mathbf{x}\|} <\) TOL then.

  • INPUT matriz del sistema \(\mathbf{A}=(a_{ij})_{i=1,\ldots,n,j=1,\ldots,n}\), vector de términos independientes \(\mathbf{b}=(b_i)_{i=1,\ldots,n}\), valor inicial \(\mathbf{X0}=\mathbf{x}^{(0)}\), error absoluto o tolerancia TOL, número máximo de iteraciones Nmax.
  • Set k=1.

Método de Jacobi. Pseudocódigo

  • While k <= Nmax
    • For i=1,...,n
      • Set \(x_i=\frac{1}{a_{ii}}\left(-\sum_{j=1,j\neq i}^n a_{ij}X0_j+b_i\right)\).
    • If \(\|\mathbf{x}-\mathbf{X0}\| <\) TOL then
      • Print \(x_1,\ldots,x_n\)
      • STOP.
    • Set k=k+1.
    • For i=1,...,n
      • Set \(X0_i =x_i\).
  • Print número máximo de iteraciones alcanzado. El método no converge.
  • STOP.

Ejemplo

Consideremos el siguiente sistema de 4 ecuaciones con 4 incógnitas: \[ \begin{align*} E_1: & 22x_1 & +5 x_2 & +5 x_3 & +6 x_4 & = 5,\\ E_2: & 5x_1 & +19 x_2 & +3 x_3 & +6 x_4 & = 7,\\ E_3: & 5x_1 & +5 x_2 & +24 x_3& +5 x_4 & = 8,\\ E_4: & 7x_1 & +7 x_2 & +4 x_3 & +25 x_4 & = 5. \end{align*} \] Para aplicar el método de Jacobi al sistema anterior, despejamos las incógnitas \(x_i\) de sus respectivas ecuaciones: \[ \begin{align*} E_1: x_1 & =\frac{5}{22}-\left(\frac{5}{22} x_2 +\frac{5}{22} x_3 +\frac{6}{22} x_4\right),\\ E_2: x_2 & =\frac{7}{19}-\left(\frac{5}{19} x_1 +\frac{3}{19} x_3 +\frac{6}{19} x_4\right),\\ E_3: x_3 & =\frac{8}{24}-\left(\frac{5}{24} x_1 +\frac{5}{24} x_2 +\frac{5}{24} x_4\right),\\ E_4: x_4 & =\frac{5}{25}-\left(\frac{7}{25} x_1 +\frac{7}{25} x_2 +\frac{4}{25} x_3\right). \end{align*} \]

Ejemplo (continuación)

Entonces, a partir de un vector inicial de aproximación \(\mathbf{x}^{(0)}\), por ejemplo \(\mathbf{x}^{(0)}=\begin{bmatrix}0\\ 0\\0 \\ 0\end{bmatrix}\), definimos la sucesión de aproximaciones de la solución \((\mathbf{x}^{(k)})_{k\geq 0}\) de la forma siguiente: \[ \begin{align*} x_1^{(k)} & =\frac{5}{22}-\left(\frac{5}{22} x_2^{(k-1)} +\frac{5}{22} x_3^{(k-1)} +\frac{6}{22} x_4^{(k-1)}\right),\\ x_2^{(k)} & =\frac{7}{19}-\left(\frac{5}{19} x_1^{(k-1)} +\frac{3}{19} x_3^{(k-1)} +\frac{6}{19} x_4^{(k-1)}\right),\\ x_3^{(k)} & =\frac{8}{24}-\left(\frac{5}{24} x_1^{(k-1)} +\frac{5}{24} x_2^{(k-1)} +\frac{5}{24} x_4^{(k-1)}\right),\\ x_4^{(k)} & =\frac{5}{25}-\left(\frac{7}{25} x_1^{(k-1)} +\frac{7}{25} x_2^{(k-1)} +\frac{4}{25} x_3^{(k-1)}\right). \end{align*} \]

Ejemplo (continuación)

Las primeras aproximaciones son las siguientes: \[ \mathbf{x}^{(0)}=\begin{bmatrix}0 \\0 \\0 \\0 \\\end{bmatrix},\ \mathbf{x}^{(1)}=\begin{bmatrix}0.227273 \\0.368421 \\0.333333 \\0.2 \\\end{bmatrix},\ \mathbf{x}^{(2)}=\begin{bmatrix}0.013238 \\0.192823 \\0.167564 \\-0.020128 \\\end{bmatrix},\ \mathbf{x}^{(3)}=\begin{bmatrix}0.150856 \\0.344836 \\0.294597 \\0.115493 \\\end{bmatrix},\ldots \] Si queremos que el error absoluto entre la aproximación \(\mathbf{x}^{(k)}\) y \(\mathbf{x}^{(k-1)}\) sea menor que \(10^{-7}\), es decir \(\|\mathbf{x}^{(k)}-\mathbf{x}^{(k-1)}\|\leq 10^{-7}\), tenemos que realizar \(k=46\) iteraciones y la aproximación vale: \(\mathbf{x}^{(46)}=\begin{bmatrix}0.091578 \\0.288732 \\0.242711 \\0.05468 \\\end{bmatrix}\).

Si queremos que el error relativo entre la aproximación \(\mathbf{x}^{(k)}\) y \(\mathbf{x}^{(k-1)}\) sea menor que \(10^{-7}\), es decir \(\frac{\|\mathbf{x}^{(k)}-\mathbf{x}^{(k-1)}\|}{\|\mathbf{x}^{(k)}\|}\leq 10^{-7}\), tenemos que realizar \(k=49\) iteraciones y la aproximación vale: \(\mathbf{x}^{(49)}=\begin{bmatrix}0.091578 \\0.288732 \\0.242711 \\0.05468 \\\end{bmatrix}\).

Ejemplo (continuación)

El método de Jacobi se puede encontrar implementado en:

Método de Gauss-Seidel

El método de Gauss-Seidel consiste en aplicar el método de Jacobi con una modificación: las componentes del vector \(\mathbf{x}^{(k)}\) de la iteración actual, \(x_i^{(k)}\), que se van calculando, se usan para el cálculo de las componentes \(x_{i+1}^{(k)},\ldots,x_n^{(k)}\) de dicho vector.

Es decir, la sucesión de aproximaciones se calcula de la forma siguiente: \[ \begin{align*} x_1^{(k)} & =\frac{1}{a_{11}}(b_1-(a_{12}x_2^{(k-1)}+\cdots +a_{1n}x_n^{(k-1)})),\\ x_2^{(k)} & =\frac{1}{a_{22}}(b_2-(a_{21}x_1^{(k)}+a_{23}x_3^{(k-1)}+\cdots +a_{2n}x_n^{(k-1)})),\\ \vdots & \\ x_i^{(k)}& =\frac{1}{a_{ii}}(b_i-(a_{i1}x_1^{(k)}+\cdots +a_{i,i-1}x_{i-1}^{(k)}+a_{i,i+1}x_{i+1}^{(k-1)}+\cdots +a_{in}x_n^{(k-1)})),\\ \vdots & \\ x_n^{(k)} & =\frac{1}{a_{nn}}(b_n-(a_{n1}x_1^{(k)}+\cdots +a_{n,n-1}x_{n-1}^{(k)})). \end{align*} \]

Método de Gauss-Seidel

Matricialmente, la sucesión de aproximaciones se calcularía de la forma siguiente:

\[ \begin{bmatrix}x_{1}^{(k)} \\x_2^{(k)} \\\vdots \\x_n^{(k)} \\\end{bmatrix}=\begin{bmatrix}0&0&\ldots&0 \\-\frac{a_{21}}{a_{22}}&0&\ldots&0 \\\vdots&\vdots&\ddots&\vdots \\-\frac{a_{n1}}{a_{nn}}&-\frac{a_{n2}}{a_{nn}}&\ldots&0 \\\end{bmatrix}\begin{bmatrix}x_{1}^{(k)} \\x_2^{(k)} \\\vdots \\x_n^{(k)} \\\end{bmatrix}+\begin{bmatrix}0&-\frac{a_{12}}{a_{11}}&\ldots&-\frac{a_{1n}}{a_{11}} \\0&0&\ldots&-\frac{a_{2n}}{a_{22}} \\\vdots&\vdots&\ddots&\vdots \\0&0&\ldots&0 \\\end{bmatrix}\begin{bmatrix}x_{1}^{(k-1)} \\x_2^{(k-1)} \\\vdots \\x_n^{(k-1)} \\\end{bmatrix}+\begin{bmatrix}\frac{b_{1}}{a_{11}} \\\frac{b_2}{a_{22}} \\\vdots \\\frac{b_n}{a_{nn}} \\\end{bmatrix}. \]

Método de Gauss-Seidel

Llamando \(\mathbf{T}_1\) y \(\mathbf{T}_2\) a las matrices siguientes: \[ \mathbf{T}_1=\begin{bmatrix}0&0&\ldots&0 \\-\frac{a_{21}}{a_{22}}&0&\ldots&0 \\\vdots&\vdots&\ddots&\vdots \\-\frac{a_{n1}}{a_{nn}}&-\frac{a_{n2}}{a_{nn}}&\ldots&0 \\\end{bmatrix},\ \mathbf{T}_2=\begin{bmatrix}0&-\frac{a_{12}}{a_{11}}&\ldots&-\frac{a_{1n}}{a_{11}} \\0&0&\ldots&-\frac{a_{2n}}{a_{22}} \\\vdots&\vdots&\ddots&\vdots \\0&0&\ldots&0 \\\end{bmatrix}, \] el método de Gauss-Seidel puede escribirse de la forma siguiente: \[ \mathbf{x}^{(k)}=\mathbf{T}_1\mathbf{x}^{(k)}+\mathbf{T}_2\mathbf{x}^{(k-1)}+\mathbf{c}_J, \]

Método de Gauss-Seidel

o, si se quiere: \[ \begin{align*} (\mathbf{Id}-\mathbf{T}_1)\mathbf{x}^{(k)} & =\mathbf{T}_2\mathbf{x}^{(k-1)}+\mathbf{c}_J,\ \Rightarrow\\ \mathbf{x}^{(k)} & =(\mathbf{Id}-\mathbf{T}_1)^{-1}\mathbf{T}_2\mathbf{x}^{(k-1)}+(\mathbf{Id}-\mathbf{T}_1)^{-1}\mathbf{c}_J. \end{align*} \] La matriz de iteración del método de Gauss Seidel será: \[ \mathbf{T}_{GS}=(\mathbf{Id}-\mathbf{T}_1)^{-1}\mathbf{T}_2, \] y el vector independiente será: \[ \mathbf{c}_{GS}=(\mathbf{Id}-\mathbf{T}_1)^{-1}\mathbf{c}_J. \]

Método de Gauss-Seidel

Observación.

La matriz \(\mathbf{Id}-\mathbf{T}_1\) es invertible ya que: \[ \mathbf{Id}-\mathbf{T}_1=\begin{bmatrix}1&0&\ldots&0 \\\frac{a_{21}}{a_{22}}&1&\ldots&0 \\\vdots&\vdots&\ddots&\vdots \\\frac{a_{n1}}{a_{nn}}&\frac{a_{n2}}{a_{nn}}&\ldots&1 \\\end{bmatrix}, \] es triangular inferior con unos en la diagonal. Su determinante será, por tanto, \(1\).

Método de Gauss-Seidel

Deduzcamos la matriz de iteración y el vector independiente del método de Gauss-Seidel a partir de la descomposición de la matriz del sistema \(\mathbf{A}\) que vimos anteriormente: \[ \mathbf{A}=\mathbf{D}+\mathbf{L}+\mathbf{U}. \] El sistema que tenemos que resolver és \(\mathbf{A}\mathbf{x}=\mathbf{b}\) o, si se quiere: \((\mathbf{D}+\mathbf{L}+\mathbf{U})\mathbf{x}=\mathbf{b}\):

  • Dejamos los elementos diagonales y “pasamos” los demás elementos al término de la derecha: \[ \mathbf{D}\mathbf{x}=-(\mathbf{L}+\mathbf{U})\mathbf{x}+\mathbf{b}. \]
  • “Separamos” las componentes calculadas de las no calculadas del vector \(\mathbf{x}\): \[ \mathbf{D}\mathbf{x}=-\mathbf{L}\mathbf{x}-\mathbf{U}\mathbf{x}+\mathbf{b}. \]

Método de Gauss-Seidel

  • Si escribimos la expresión anterior en función de la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) obtenemos: \[ \mathbf{D}\mathbf{x}^{(k)}=-\mathbf{L}\mathbf{x}^{(k)}-\mathbf{U}\mathbf{x}^{(k-1)}+\mathbf{b}. \]
  • “Pasamos” al término de la izquierda todo lo que depende de \(\mathbf{x}^{(k)}\): \[ (\mathbf{D}+\mathbf{L})\mathbf{x}^{(k)}=-\mathbf{U}\mathbf{x}^{(k-1)}+\mathbf{b}. \]
  • Despejamos \(\mathbf{x}^{(k)}\): \[ \mathbf{x}^{(k)}=-(\mathbf{D}+\mathbf{L})^{-1}\mathbf{U}\mathbf{x}^{(k-1)}+(\mathbf{D}+\mathbf{L})^{-1}\mathbf{b}. \]

Entonces, la matriz de iteración y el vector independiente del método de Gauss-Seidel serán: \[ \mathbf{T}_{GS}=-(\mathbf{D}+\mathbf{L})^{-1}\mathbf{U},\quad \mathbf{c}_{GS}=(\mathbf{D}+\mathbf{L})^{-1}\mathbf{b}. \]

Método de Gauss-Seidel. Pseudocódigo

Vamos a dar el pseudocódigo del método de Gauss-Seidel usando como criterio de parada el criterio del error absoluto.

  • INPUT matriz del sistema \(\mathbf{A}=(a_{ij})_{i=1,\ldots,n,j=1,\ldots,n}\), vector de términos independientes \(\mathbf{b}=(b_i)_{i=1,\ldots,n}\), valor inicial \(\mathbf{X0}=\mathbf{x}^{(0)}\), error absoluto o tolerancia TOL, número máximo de iteraciones Nmax.
  • Set k=1.

Método de Gauss-Seidel. Pseudocódigo

  • While k <= Nmax
    • For i=1,...,n
      • Set \(x_i=\frac{1}{a_{ii}}\left(-\sum_{j=1}^{i-1} a_{ij}x_j-\sum_{j=i+1}^n a_{ij}X0_j+b_i\right)\).
    • If \(\|\mathbf{x}-\mathbf{X0}\| <\) TOL then
      • Print \(x_1,\ldots,x_n\)
      • STOP.
    • Set k=k+1.
    • For i=1,...,n
      • Set \(X0_i =x_i\).
  • Print número máximo de iteraciones alcanzado. El método no converge.
  • STOP.

Ejemplo

Apliquemos el método de Gauss-Seidel al sistema de 4 ecuaciones con 4 incógnitas anterior: \[ \begin{align*} E_1: & 22x_1 & +5 x_2 & +5 x_3 & +6 x_4 & = 5,\\ E_2: & 5x_1 & +19 x_2 & +3 x_3 & +6 x_4 & = 7,\\ E_3: & 5x_1 & +5 x_2 & +24 x_3& +5 x_4 & = 8,\\ E_4: & 7x_1 & +7 x_2 & +4 x_3 & +25 x_4 & = 5. \end{align*} \]

Ejemplo (continuación)

A partir de un vector inicial de aproximación \(\mathbf{x}^{(0)}\), por ejemplo \(\mathbf{x}^{(0)}=\begin{bmatrix}0\\ 0\\0 \\ 0\end{bmatrix}\), definimos la sucesión de aproximaciones de la solución \((\mathbf{x}^{(k)})_{k\geq 0}\) de la forma siguiente: \[ \begin{align*} x_1^{(k)} & =\frac{5}{22}-\left(\frac{5}{22} x_2^{(k-1)} +\frac{5}{22} x_3^{(k-1)} +\frac{6}{22} x_4^{(k-1)}\right),\\ x_2^{(k)} & =\frac{7}{19}-\left(\frac{5}{19} x_1^{(k)} +\frac{3}{19} x_3^{(k-1)} +\frac{6}{19} x_4^{(k-1)}\right),\\ x_3^{(k)} & =\frac{8}{24}-\left(\frac{5}{24} x_1^{(k)} +\frac{5}{24} x_2^{(k)} +\frac{5}{24} x_4^{(k-1)}\right),\\ x_4^{(k)} & =\frac{5}{25}-\left(\frac{7}{25} x_1^{(k)} +\frac{7}{25} x_2^{(k)} +\frac{4}{25} x_3^{(k)}\right). \end{align*} \]

Ejemplo (continuación)

Las primeras aproximaciones son las siguientes: \[ \mathbf{x}^{(0)}=\begin{bmatrix}0 \\0 \\0 \\0 \\\end{bmatrix},\ \mathbf{x}^{(1)}=\begin{bmatrix}0.227273 \\0.308612 \\0.221691 \\0.014482 \\\end{bmatrix},\ \mathbf{x}^{(2)}=\begin{bmatrix}0.1028 \\0.301792 \\0.246026 \\0.04735 \\\end{bmatrix},\ \mathbf{x}^{(3)}=\begin{bmatrix}0.089855 \\0.290976 \\0.244129 \\0.054307 \\\end{bmatrix},\ldots \] Si queremos que el error absoluto entre la aproximación \(\mathbf{x}^{(k)}\) y \(\mathbf{x}^{(k-1)}\) sea menor que \(10^{-7}\), es decir \(\|\mathbf{x}^{(k)}-\mathbf{x}^{(k-1)}\|\leq 10^{-7}\), tenemos que realizar \(k=11\) iteraciones y la aproximación vale: \(\mathbf{x}^{(11)}=\begin{bmatrix}0.091578 \\0.288732 \\0.242711 \\0.05468 \\\end{bmatrix}\).

Si queremos que el error relativo entre la aproximación \(\mathbf{x}^{(k)}\) y \(\mathbf{x}^{(k-1)}\) sea menor que \(10^{-7}\), es decir \(\frac{\|\mathbf{x}^{(k)}-\mathbf{x}^{(k-1)}\|}{\|\mathbf{x}^{(k)}\|}\leq 10^{-7}\), tenemos que realizar \(k=11\) iteraciones y la aproximación vale: \(\mathbf{x}^{(11)}=\begin{bmatrix}0.091578 \\0.288732 \\0.242711 \\0.05468 \\\end{bmatrix}\).

Ejemplo (continuación)

Vemos que en este caso el método de Gauss-Seidel requiere menos iteraciones para converger que el método de Jacobi usando el mismo criterio de parada.

Sin embargo, hay casos en que ocurre el efecto contrario: es el método de Jacobi que converge más rápidamente.

Como veremos más adelante, depende de las matrices de iteración de los dos métodos.

El método de Gauss-Seidel se puede encontrar implementado en:

Métodos de iteración generales

Introducción

En esta sección vamos a estudiar un método iterativo general para resolver un sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\) donde la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) viene dada en forma recurrente por la expresión siguiente: \[ \mathbf{x}^{(k)}=\mathbf{T}\mathbf{x}^{(k-1)}+\mathbf{c}, \] donde \(\mathbf{T}\) es la matriz de iteración y \(\mathbf{c}\), el vector independiente, usando un vector \(\mathbf{x}^{(0)}\) inicial.

Los métodos de Jacobi y Gauss-Seidel serían casos particulares de métodos iterativos definidos usando la expresión anterior.

Estudio de la convergencia

Tal como comentamos en su momento, para hallar la recurrencia que gobierna la sucesión de aproximaciones \(\mathbf{x}^{(k)}\), tranformamos el sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\) en el sistema lineal equivalente \(\mathbf{x}=\mathbf{T}\mathbf{x}+\mathbf{c}\) y, a partir de la última expresión, definimos la recurrencia de las aproximaciones \(\mathbf{x}^{(k)}\).

Entonces, si la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) converge a la solución \(\mathbf{x}\), ésta verificará: \[ \mathbf{x}=\mathbf{T}\mathbf{x}+\mathbf{c},\ \Rightarrow (\mathbf{Id}-\mathbf{T})\mathbf{x}=\mathbf{c},\ \Rightarrow \mathbf{x}=(\mathbf{Id}-\mathbf{T})^{-1}\mathbf{c}. \]

Estudio de la convergencia

Veamos a continuación si somos capaces de escribir la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) en función de la aproximación inicial \(\mathbf{x}^{(0)}\): \[ \begin{align*} \mathbf{x}^{(1)} & = \mathbf{T}\mathbf{x}^{(0)}+\mathbf{c},\\ \mathbf{x}^{(2)} & = \mathbf{T}\mathbf{x}^{(1)}+\mathbf{c}=\mathbf{T}(\mathbf{T}\mathbf{x}^{(0)}+\mathbf{c})+\mathbf{c}=\mathbf{T}^2\mathbf{x}^{(0)}+\mathbf{T}\mathbf{c}+\mathbf{c},\\ \mathbf{x}^{(3)} & = \mathbf{T}\mathbf{x}^{(2)}+\mathbf{c}=\mathbf{T}(\mathbf{T}^2\mathbf{x}^{(0)}+\mathbf{T}\mathbf{c}+\mathbf{c})+\mathbf{c}=\mathbf{T}^3\mathbf{x}^{(0)}+\mathbf{T}^2\mathbf{c}+\mathbf{T}{c}+\mathbf{c}. \end{align*} \] En general, puede demostrarse fácilmente por inducción que: \[ \mathbf{x}^{(k)}=\mathbf{T}^k\mathbf{x}^{(0)}+\mathbf{T}^{k-1}\mathbf{c}+\cdots +\mathbf{T}\mathbf{c}+\mathbf{c}=\mathbf{T}^k\mathbf{x}^{(0)}+\left(\sum_{i=0}^{k-1}\mathbf{T}^i\right)\mathbf{c}. \]

Estudio de la convergencia

Teniendo en cuenta que el límite \(\mathbf{x}\) de la sucesión de aproximaciones, en caso de existir, verifica que \(\mathbf{x}=(\mathbf{Id}-\mathbf{T})^{-1}\mathbf{c}\), intuitivamente y usando la expresión anterior, \[ \mathbf{x}^{(k)}=\mathbf{T}^k\mathbf{x}^{(0)}+\left(\sum_{i=0}^{k-1}\mathbf{T}^i\right)\mathbf{c}, \] parece que para que la sucesión de aproximaciones sea convergente, la sucesión de matrices \(\mathbf{T}^k\) debe tender a la matriz \(\mathbf{0}\) y que el sumatorio anterior de matrices \(\displaystyle\left(\sum_{i=0}^{k-1}\mathbf{T}^i\right)\) debe tender a \((\mathbf{Id}-\mathbf{T})^{-1}\).

El siguiente lema es un primer intento de responder a las cuestiones planteadas:

Estudio de la convergencia

Lema. Convergencia de una serie de matrices.

Sea \(\mathbf{T}\) una matriz cuadrada \(n\times n\) cuyo radio espectral es menor que \(1\), \(\rho(\mathbf{T})<1\). Entonces, \[ (\mathbf{Id}-\mathbf{T})^{-1}=\mathbf{Id}+\mathbf{T}+\mathbf{T}^2+\cdots =\sum_{j=0}^\infty \mathbf{T}^j. \] Es decir, la serie o la suma infinita de matrices \(\displaystyle\sum_{j=0}^\infty \mathbf{T}^j\) es convergente si el radio espectral de la matriz \(\mathbf{T}\) de la que hallamos las potencias es menor que \(1\).

Demostración del lema

En primer lugar, fijémonos que si \(\lambda\) es un valor propio de \(\mathbf{T}\), entonces \(1-\lambda\) es un valor propio de \(\mathbf{Id}-\mathbf{T}\) y al contrario, si \(\mu\) es un valor propio de \(\mathbf{Id}-\mathbf{T}\) entonces \(1-\mu\) es valor propio de \(\mathbf{T}\)

  • si \(\lambda\) es un valor propio de \(\mathbf{T}\), existe un vector propio \(\mathbf{x}\) tal que \(\mathbf{T}\mathbf{x}=\lambda\mathbf{x}\). Entonces, \[ (\mathbf{Id}-\mathbf{T})\mathbf{x}=\mathbf{x}-\mathbf{T}\mathbf{x}=\mathbf{x}-\lambda\mathbf{x}=(1-\lambda)\mathbf{x}, \] lo que significa que dicho vector propio \(\mathbf{x}\) es vector propio de la matriz \(\mathbf{Id}-\mathbf{T}\) de valor propio \(1-\lambda\).

  • si \(\mu\) es un valor propio de \(\mathbf{Id}-\mathbf{T}\), existe un vector propio \(\mathbf{x}\) tal que \((\mathbf{Id}-\mathbf{T})\mathbf{x}=\mu\mathbf{x}\). Entonces, \[ \mathbf{T}\mathbf{x}=(\mathbf{Id}-(\mathbf{Id}-\mathbf{T}))\mathbf{x}=\mathbf{x}-\mu\mathbf{x}=(1-\mu)\mathbf{x}, \] lo que significa que dicho vector propio \(\mathbf{x}\) es vector propio de la matriz \(\mathbf{T}\) de valor propio \(1-\mu\).

Como el radio espectral de \(\mathbf{T}\) es menor que \(1\), \(\rho(\mathbf{T})<1\), \(1\) no puede ser valor propio de \(\mathbf{T}\) ya que en este caso, \(\rho(\mathbf{T})=\max_{\lambda}|\lambda|\geq 1\) y tendríamos una contradicción.

Demostración del lema (continuación)

Por tanto, por lo dicho anteriormente, \(0\) no puede ser valor propio de \(\mathbf{Id}-\mathbf{T}\) ya que si lo fuera, \(1-0=1\) sería valor propio de la matriz \(\mathbf{T}\) y acabamos de decir que esto es imposible.

Decir que \(0\) no es valor propio de la matriz \(\mathbf{Id}-\mathbf{T}\) es equivalente a decir que el determinante de dicha matriz es distinto de \(0\) (recordad que los valores propios \(\lambda\) de una matriz general \(\mathbf{B}\) cumplen \(\mathrm{det}(\mathbf{B}-\lambda\mathbf{Id})=0\), entonces si \(0\) no es valor propio de la matriz \(\mathbf{Id}-\mathbf{T}\), el determinante de la matriz \(\mathrm{det}(\mathbf{Id}-\mathbf{T}-0\mathbf{Id})=\mathrm{det}(\mathbf{Id}-\mathbf{T})\) no puede ser \(0\)).

Por tanto, la matriz \(\mathbf{Id}-\mathbf{T}\) es invertible y la matriz \((\mathbf{Id}-\mathbf{T})^{-1}\) existe.

Sea \(\mathbf{S}_m =\mathbf{Id}+\mathbf{T}+\cdots + \mathbf{T}^m\).

Calculemos \((\mathbf{Id}-\mathbf{T})\mathbf{S}_m\): \[ (\mathbf{Id}-\mathbf{T})\mathbf{S}_m=\mathbf{S}_m-\mathbf{T}\mathbf{S}_m =\mathbf{Id}+\mathbf{T}+\cdots + \mathbf{T}^m-(\mathbf{T}+\cdots + \mathbf{T}^{m+1})=\mathbf{Id}-\mathbf{T}^{m+1}. \]

Demostración del lema (continuación)

Veamos a continuación que \(\displaystyle\lim_{m\to\infty}\mathbf{Id}-\mathbf{T}^{m+1}=\mathbf{Id}\), para una cierta norma matricial \(\|\cdot\|\): \[ \lim_{m\to\infty}\|\mathbf{Id}-(\mathbf{Id}-\mathbf{T}^{m+1})\|=\lim_{m\to\infty}\|\mathbf{T}^{m+1}\|\leq \lim_{m\to\infty}\|\mathbf{T}\|^{m+1}. \] Como \(\rho(\mathbf{T})<1\), existe \(\epsilon >0\) tal que \(\rho(\mathbf{T})+\epsilon <1\). Para dicho \(\epsilon >0\) existe una norma matricial \(\|\cdot\|\) tal que \(\|\mathbf{T}\|\leq \rho(\mathbf{T})+\epsilon < 1\).

Como \(\|\mathbf{T}\|<1\), \(\displaystyle \lim_{m\to\infty} \|\mathbf{T}\|^{m+1}=0\) y por tanto, \(\displaystyle \lim_{m\to\infty}\|\mathbf{Id}-(\mathbf{Id}-\mathbf{T}^{m+1})\|=0\), tal como queríamos ver.

Ahora, como \(\displaystyle\displaystyle\lim_{m\to\infty}\mathbf{Id}-\mathbf{T}^{m+1}=\mathbf{Id}\), tendremos que: \[ \lim_{m\to\infty} (\mathbf{Id}-\mathbf{T})\mathbf{S}_m=\mathbf{Id},\ \Rightarrow\lim_{m\to\infty}\mathbf{S}_m=(\mathbf{Id}-\mathbf{T})^{-1},\ \Rightarrow \sum_{j=0}^\infty \mathbf{T}^j = (\mathbf{Id}-\mathbf{T})^{-1}, \] tal como queríamos ver.

Estudio de la convergencia

Ya tenemos los ingredientes necesarios para demostrar el teorema que dice cuando un método iterativo es convergente:

Teorema. Condición necesaria y suficiente de convergencia.

Sea \(\mathbf{x}^{(k)}\) una sucesión de aproximaciones para hallar la solución del sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\) a partir de la recurrencia \(\mathbf{x}^{(k)}=\mathbf{T}\mathbf{x}^{(k-1)}+\mathbf{c}\). Entonces la sucesión anterior converge si, y sólo si, el radio espectral de la matriz de iteración \(\mathbf{T}\) es menor que \(1\), \(\rho(\mathbf{T})<1\).

Demostración del teorema

Supongamos primero que \(\rho(\mathbf{T})<1\). Usando la demostración del lema anterior tenemos que existe una norma matricial \(\|\cdot\|\) tal que \(\|\mathbf{T}\|<1\). Por tanto, \(\displaystyle\lim_{m\to\infty}\mathbf{T}^m =\mathbf{0}\).

Usando el lema otra vez, tenemos que \(\displaystyle\sum_{j=0}^\infty \mathbf{T}^j =(\mathbf{Id}-\mathbf{T})^{-1}\).

Por último como \[ \mathbf{x}^{(k)}=\mathbf{T}^k\mathbf{x}^{(0)}+\left(\sum_{i=0}^{k-1}\mathbf{T}^i\right)\mathbf{c}, \] haciendo límite en la expresión anterior, tenemos: \[ \lim_{k\to\infty}\mathbf{x}^{(k)}=\mathbf{0}\mathbf{x}^{(0)}+(\mathbf{Id}-\mathbf{T})^{-1}\mathbf{c}=(\mathbf{Id}-\mathbf{T})^{-1}\mathbf{c}, \] tal como queríamos demostrar.

Demostración del teorema (continuación)

Supongamos ahora que la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) converge a \(\mathbf{x}\) tal que \(\mathbf{x}=\mathbf{T}\mathbf{x}+\mathbf{c}\).

Veamos que para cualquier vector \(\mathbf{z}\in\mathbb{R}^n\), \(\displaystyle\lim_{m\to\infty}\mathbf{T}^m\mathbf{z}=\mathbf{0}\).

Se puede demostrar que la condición anterior equivale a afirmar que \(\rho(\mathbf{T})<1\).

Sea pues un vector \(\mathbf{z}\). Sea \(\mathbf{x}^{(0)}=\mathbf{x}-\mathbf{z}\) el valor inicial de la sucesión de aproximaciones. Como \(\displaystyle\lim_{k\to\infty}\mathbf{x}^{(k)}=\mathbf{x}\), \[ \mathbf{x}-\mathbf{x}^{(k)}=(\mathbf{T}\mathbf{x}+\mathbf{c})-(\mathbf{T}\mathbf{x}^{(k-1)}+\mathbf{c})=\mathbf{T}(\mathbf{x}-\mathbf{x}^{(k-1)}). \] Entonces: \[ \mathbf{x}-\mathbf{x}^{(k)}=\mathbf{T}(\mathbf{x}-\mathbf{x}^{(k-1)})=\mathbf{T}^2(\mathbf{x}-\mathbf{x}^{(k-2)})=\cdots = \mathbf{T}^k(\mathbf{x}-\mathbf{x}^{(0)})=\mathbf{T}^k(\mathbf{x}-(\mathbf{x}-\mathbf{z}))=\mathbf{T}^k\mathbf{z}. \] Como \(\displaystyle\lim_{k\to\infty}\mathbf{x}-\mathbf{x}^{(k)}=\mathbf{0}\), tenemos que \(\displaystyle\lim_{k\to\infty} \mathbf{T}^k\mathbf{z}=\mathbf{0}\) tal como queríamos demostrar.

Estudio de la convergencia

El teorema anterior es importante porque nos da una condición necesaria y suficiente para que la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) converja.

Sin embargo, no es aplicable en la práctica ya que hallar el radio espectral de una matriz es un problema mucho más complejo desde el punto de vista del análisis numèrico que resolver un sistema lineal.

El corolario siguiente intenta resolver este problema, es decir, nos da una condición suficiente de convergencia en función de la norma de la matriz del sistema:

Estudio de la convergencia

Corolario.

Sea \(\mathbf{x}^{(k)}\) una sucesión de aproximaciones para hallar la solución del sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\) a partir de la recurrencia \(\mathbf{x}^{(k)}=\mathbf{T}\mathbf{x}^{(k-1)}+\mathbf{c}\).

Si existe una norma matricial para la cual, la norma de la matriz de iteración \(\mathbf{T}\) es menor que \(1\), \(\|\mathbf{T}\|<1\), entonces la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) converge a la solución del sistema anterior \(\mathbf{x}\) para cualquier aproximación inicial \(\mathbf{x}^{(0)}\) y además los errores cometidos vienen acotados por las expresiones siguientes:

  • \(\|\mathbf{x}^{(k)}-\mathbf{x}\|\leq \|\mathbf{T}\|^k\|\mathbf{x}^{(0)}-\mathbf{x}\|\),
  • \(\|\mathbf{x}^{(k)}-\mathbf{x}\|\leq \frac{\|\mathbf{T}\|^k}{1-\|\mathbf{T}\|}\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|\).

Demostración del corolario

Como cualquier norma matricial verifica que \(\rho(\mathbf{T})\leq \|\mathbf{T}\|\), y por hipótesis \(\|\mathbf{T}\|<1\), se cumplirá que \(\rho(\mathbf{T})\leq \|\mathbf{T}\|<1\). Por tanto, usando el teorema anterior, tendremos que la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) convergerá hacia la solución del sistema \(\mathbf{x}\).

Veamos las cotas de los errores.

Sabemos que en general, para todo \(k\) (ver la demostración del teorema), \[ \mathbf{x}^{(k)}-\mathbf{x} = \mathbf{T}(\mathbf{x}^{(k-1)}-\mathbf{x}), \] donde recordemos que \(\mathbf{x}\) es la solución del sistema lineal o el límite de la sucesión de aproximaciones \(\mathbf{x}^{(k)}\): \(\displaystyle\mathbf{x}=\lim_{k\to\infty}\mathbf{x}^{(k)}\).

Aplicando la expresión anterior \(k\) veces tenemos que: \[ \mathbf{x}^{(k)}-\mathbf{x} = \mathbf{T}(\mathbf{x}^{(k-1)}-\mathbf{x})=\mathbf{T}^2(\mathbf{x}^{(k-2)}-\mathbf{x})=\cdots = \mathbf{T}^k (\mathbf{x}^{(0)}-\mathbf{x}). \] Por tanto: \[ \|\mathbf{x}^{(k)}-\mathbf{x}\|=\|\mathbf{T}^k (\mathbf{x}^{(0)}-\mathbf{x})\|\leq \|\mathbf{T}^k\|\|\mathbf{x}^{(0)}-\mathbf{x}\|\leq \|\mathbf{T}\|^k\|\mathbf{x}^{(0)}-\mathbf{x}\|, \] tal como queríamos ver.

Demostración del corolario (continuación)

Veamos la segunda desigualdad.

Antes de nada, comprobemos que para todo \(l\) se cumple que: \[ \|\mathbf{x}^{(l)}-\mathbf{x}^{(l-1)}\|\leq \|\mathbf{T}\|^{l-1}\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|. \] Efectivamente, \[ \begin{align*} \|\mathbf{x}^{(l)}-\mathbf{x}^{(l-1)}\| & =\|\mathbf{T}\mathbf{x}^{(l-1)}+\mathbf{c}-(\mathbf{T}\mathbf{x}^{(l-2)}+\mathbf{c})\|=\|\mathbf{T}(\mathbf{x}^{(l-1)}-\mathbf{x}^{(l-2)})\|\\ & =\|\mathbf{T}^2(\mathbf{x}^{(l-2)}-\mathbf{x}^{(l-3)})\|=\cdots = \|\mathbf{T}^{l-1}(\mathbf{x}^{(1)}-\mathbf{x}^{(0)})\|\\ & \leq \|\mathbf{T}^{l-1}\|\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|\leq \|\mathbf{T}\|^{l-1}\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|. \end{align*} \]

Sea \(m>k\). Aplicando la desigualdad triangular y la desigualdad anterior, tenemos que: \[ \begin{align*} \|\mathbf{x}^{(m)}-\mathbf{x}^{(k)}\| & \leq \|\mathbf{x}^{(m)}-\mathbf{x}^{(m-1)}\|+\|\mathbf{x}^{(m-1)}-\mathbf{x}^{(m-2)}\|+\cdots + \|\mathbf{x}^{(k+1)}-\mathbf{x}^{(k)}\|\\ & \leq \left(\|\mathbf{T}\|^{m-1}+\|\mathbf{T}\|^{m-2}+\cdots +\|\mathbf{T}\|^{k}\right)\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|\\ & \leq \left(\sum_{i=k}^\infty \|\mathbf{T}\|^{i}\right)\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|=\frac{\|\mathbf{T}\|^k}{1-\|\mathbf{T}\|}\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|, \end{align*} \]

Demostración del corolario (continuación)

Como la parte de la “derecha” de la desigualdad anterior no depende de \(m\), hacemos tender \(m\) hacia \(\infty\) y, como \(\displaystyle\lim_{m\to\infty}\mathbf{x}^{(m)}=\mathbf{x}\), obtenemos \[ \|\mathbf{x}-\mathbf{x}^{(k)}\|\leq \frac{\|\mathbf{T}\|^k}{1-\|\mathbf{T}\|}\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|, \] tal como queríamos demostrar.

Estudio de la convergencia

Observación.

La primera desigualdad del teorema no tiene aplicación práctica al no conocer \(\mathbf{x}\) pero nos indica que cuanto menor sea la norma de la matriz de iteración, más “rápidamente” tenderá a cero el error cometido \(\|\mathbf{x}^{(k)}-\mathbf{x}\|\).

Sin embargo, usando la segunda desigualdad podemos estimar el número de iteraciones máximo a realizar para que el error \(\|\mathbf{x}^{(k)}-\mathbf{x}\|\) sea menor que una cierta tolerancia \(\epsilon\) ya que: \[ \|\mathbf{x}^{(k)}-\mathbf{x}\|\leq \frac{\|\mathbf{T}\|^k}{1-\|\mathbf{T}\|}\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|\leq \epsilon,\ \Rightarrow \|\mathbf{T}\|^k \leq \frac{\epsilon(1-\|\mathbf{T}\|)}{\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|}. \]

Estudio de la convergencia

Observación (continuación).

Tomando logaritmos en la expresión anterior, tenemos que el número máximo de iteraciones a realizar para obtener una tolerancia menor que \(\epsilon\) vale: \[ k\leq \frac{\ln\left(\frac{\epsilon(1-\|\mathbf{T}\|)}{\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|}\right)}{\ln\|\mathbf{T}\|} = \frac{\ln\epsilon+\ln(1-\|\mathbf{T}\|)-\ln(\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|)}{\ln\|\mathbf{T}\|}. \]

Métodos de Jacobi y Gauss-Seidel. Convergencia

Los métodos de Jacobi y Gauss-Seidel definían la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) de la forma siguiente:

  • Método de Jacobi: \[ \mathbf{x}^{(k)}=\mathbf{T}_J\mathbf{x}^{(k-1)}+\mathbf{c}_J. \]
  • Método de Gauss-Seidel: \[ \mathbf{x}^{(k)}=\mathbf{T}_{GS}\mathbf{x}^{(k-1)}+\mathbf{c}_{GS}. \]

Métodos de Jacobi y Gauss-Seidel. Convergencia

Las matrices de iteración eran las siguientes: \[ \mathbf{T}_J =-\mathbf{D}^{-1}(\mathbf{L}+\mathbf{U}),\quad\mathbf{T}_{GS} =-(\mathbf{D}+\mathbf{L})^{-1}\mathbf{U}, \] donde las matrices \(\mathbf{D}\), \(\mathbf{L}\) y \(\mathbf{U}\) eran la matriz diagonal, la matriz triangular inferior y la matriz triangular superior de la matriz del sistema a resolver \(\mathbf{A}\): \(\mathbf{A}=\mathbf{D}+\mathbf{L}+\mathbf{U}\).

Aplicando lo visto anteriormente, si el radio espectral de la matriz de iteración de Jacobi \(\rho(\mathbf{T}_J)<1\) es menor que \(1\), el método de Jacobi será convergente y lo mismo para el método de Gauss Seidel, es decir, si \(\rho(\mathbf{T}_{GS})<1\) es menor que \(1\), el método de Gauss-Seidel será convergente

Métodos de Jacobi y Gauss-Seidel. Convergencia

De la misma manera, si existe una norma matricial para la que \(\|\mathbf{T}_J\|<1\), el método de Jacobi también será convergente y lo mismo para el método de Gauss-Seidel, es decir, si existe una norma matricial para la que \(\|\mathbf{T}_{GS}\|<1\), el método de Gauss-Seidel también será convergente y además en estos casos tenemos una manera de estimar el número de iteraciones para que el error entre \(\mathbf{x}^{(k)}\) y la solución exacta \(\mathbf{x}\) sea menor que una cierta tolerancia \(\epsilon\).

Veamos que si la matriz del sistema \(\mathbf{A}=(a_{ij})_{i,j=1,\ldots,n}\) es estrictamente diagonal dominante, donde recordemos que significa que \[ |a_{ii}| > \sum_{j=1,j\neq i}^n |a_{ij}|,\ i=1,\ldots,n, \] los métodos de Jacobi y Gauss-Seidel convergen:

Métodos de Jacobi y Gauss-Seidel. Convergencia

Proposición. Convergencia de los métodos de Jacobi y Gauss-Seidel cuando la matriz del sistema es estrictamente diagonal dominante.

Sea \(\mathbf{x}^{(k)}_J\), \(\mathbf{x}^{(k)}_{GS}\) las sucesiones de aproximaciones generadas por los métodos de Jacobi y Gauss-Seidel, respectivamente, para hallar la solución del sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\). Si la matriz del sistema \(\mathbf{A}\) es estrictamente diagonal dominante, las sucesiones anteriores convergen a la solución de sistema \(\mathbf{x}\).

Para demostrar la proposición anterior veremos que \(\|\mathbf{T}_J\|_\infty <1\) y \(\|\mathbf{T}_{GS}\|_\infty <1\). Entonces, usando el corolario anterior, podemos afirmar que las sucesiones de aproximaciones generadas por los métodos de Jacobi y Gauss-Seidel convergen.

Demostración de la proposición

Recordemos que dada una matriz cualquiera \(\mathbf{B}=(b_{ij})_{i,j=1,\ldots,n}\), la norma infinito de dicha matriz es el máximo de la suma de las componentes en valor absoluto de todas las filas: \[ \|\mathbf{B}\|_\infty =\max_{i=1,\ldots,n}\sum_{j=1}^n |b_{ij}|. \] Veamos primero que la norma infinito de la matriz de iteración del método de Jacobi es menor que \(1\), \(\|\mathbf{T}_J\|_\infty <1\).

Recordemos que

\[ \mathbf{T}_J =-\mathbf{D}^{-1}(\mathbf{L}+\mathbf{U})=\begin{bmatrix}0&-\frac{a_{12}}{a_{11}}&\ldots&-\frac{a_{1n}}{a_{11}} \\-\frac{a_{21}}{a_{22}}&0&\ldots&-\frac{a_{2n}}{a_{22}} \\\vdots&\vdots&\ddots&\vdots \\-\frac{a_{n1}}{a_{nn}}&-\frac{a_{n2}}{a_{nn}}&\ldots&0 \\\end{bmatrix}. \]

Demostración de la proposición (continuación)

Dada la fila \(i\)-ésima, la suma en valor absoluto de sus componentes valdrá: \(\displaystyle\sum_{j=1,j\neq i}^n \left|\frac{a_{ij}}{a_{ii}}\right|\). Dicha suma estará acotada por: \[ \sum_{j=1,j\neq i}^n \left|\frac{a_{ij}}{a_{ii}}\right| =\frac{1}{|a_{ii}|}\sum_{j=1,j\neq i}^n \left|a_{ij}\right| < 1, \] ya que como la matriz del sistema \(\mathbf{A}\) es estrictamente diagonal dominante, \[ \sum_{j=1,j\neq i}^n \left|a_{ij}\right|< |a_{ii}|,\ \Rightarrow \frac{1}{|a_{ii}|}\sum_{j=1,j\neq i}^n \left|a_{ij}\right| < 1. \] Por tanto, \[ \|\mathbf{T}_J\|_\infty =\max_{i=1,\ldots,n}\sum_{j=1,j\neq i}^n \left|\frac{a_{ij}}{a_{ii}}\right| <1, \] tal como queríamos demostrar.

Demostración de la proposición (continuación)

Veamos a continuación que \(\|\mathbf{T}_{GS}\|_\infty <1\).

Recordemos que: \(\mathbf{T}_{GS} =-(\mathbf{D}+\mathbf{L})^{-1}\mathbf{U}\).

El valor de la norma infinito de la matriz de iteración de Gauss-Seidel se puede calcular de la forma siguiente: \[ \|\mathbf{T}_{GS}\|_\infty =\max_{\mathbf{x}}\frac{\|\mathbf{T}_{GS}\mathbf{x}\|_\infty}{\|\mathbf{x}\|_\infty}. \] Sea \(\mathbf{x}\in\mathbb{R}^n\) fijo. Llamamos \(\mathbf{y}=\mathbf{T}_{GS}\mathbf{x}\). Entonces la norma infinito de la matriz de iteración de Gauss-Seidel puede escribirse como: \[ \|\mathbf{T}_{GS}\|_\infty =\max_{\mathbf{x}}\frac{\|\mathbf{y}\|_\infty}{\|\mathbf{x}\|_\infty}. \] Sea \(k\) la componente que hace máximo las componentes del vector \(\mathbf{y}\) en valor absoluto, es decir, \[ |y_k|=\|\mathbf{y}\|_\infty=\max_{i=1,\ldots,n}|y_i|. \] Como \(\mathbf{y}=\mathbf{T}_{GS}\mathbf{x}\), tenemos que \(\mathbf{y}=-(\mathbf{D}+\mathbf{L})^{-1}\mathbf{U}\mathbf{x}\).

Demostración de la proposición (continuación)

Por tanto, \[ (\mathbf{D}+\mathbf{L})\mathbf{y}=-\mathbf{U}\mathbf{x}. \] Si escribimos la componente \(k\)-ésima de la expresión anterior, obtenemos: \[ a_{kk}y_k+\sum_{j=1}^{k-1}a_{kj} y_j =-\sum_{j=k+1}^n a_{kj}x_j. \] Por tanto, \[ \begin{align*} \left|\sum_{j=k+1}^n a_{kj}x_j\right| & =\left|a_{kk}y_k+\sum_{j=1}^{k-1}a_{kj} y_j\right|\geq |a_{kk}||y_k|-\sum_{j=1}^{k-1}|a_{kj}| |y_j|\geq |a_{kk}||y_k|-|y_k|\sum_{j=1}^{k-1}|a_{kj}|\\ & =|a_{kk}|\|\mathbf{y}\|_\infty-\|\mathbf{y}\|_\infty\sum_{j=1}^{k-1}|a_{kj}|=\|\mathbf{y}\|_\infty\left(|a_{kk}|-\sum_{j=1}^{k-1}|a_{kj}|\right). \end{align*} \] Por otro lado, \[ \left|\sum_{j=k+1}^n a_{kj}x_j\right|\leq \|\mathbf{x}\|_\infty\sum_{j=k+1}^n |a_{kj}|. \]

Demostración de la proposición (continuación)

En resumen, acabamos de demostrar que: \[ \|\mathbf{y}\|_\infty\left(|a_{kk}|-\sum_{j=1}^{k-1}|a_{kj}|\right)\leq \|\mathbf{x}\|_\infty\sum_{j=k+1}^n |a_{kj}|, \] o, si se quiere, \[ \frac{\|\mathbf{y}\|_\infty}{\|\mathbf{x}\|_\infty}\leq \frac{\sum_{j=k+1}^n |a_{kj}|}{|a_{kk}|-\sum_{j=1}^{k-1}|a_{kj}|}, \] pero como la matriz del sistema \(\mathbf{A}\) es estrictamente diagonal dominante, \[ \sum_{j=1}^{k-1}|a_{kj}|+\sum_{j=k+1}^n |a_{kj}|<|a_{kk}|, \] o, lo que es lo mismo, \[ \sum_{j=k+1}^n |a_{kj}| <|a_{kk}|-\sum_{j=1}^{k-1}|a_{kj}|,\ \Rightarrow \frac{\sum_{j=k+1}^n |a_{kj}|}{|a_{kk}|-\sum_{j=1}^{k-1}|a_{kj}|}<1. \]

Demostración de la proposición (continuación)

Acabamos de demostrar que para cualquier \(\mathbf{x}\in\mathbb{R}^n\), con \(\mathbf{y}=\mathbf{T}_{GS}\mathbf{x}\), \(\frac{\|\mathbf{y}\|_\infty}{\|\mathbf{x}\|_\infty}<1\).

Por tanto, \[ \|\mathbf{T}_{GS}\|_\infty =\max_{\mathbf{x}}\frac{\|\mathbf{y}\|_\infty}{\|\mathbf{x}\|_\infty}<1, \] tal como queríamos demostrar.

Ejemplo anterior

Anteriormente, aplicamos el método de Jacobi para la resolución del sistema siguiente: \[ \begin{align*} E_1: & 22x_1 & +5 x_2 & +5 x_3 & +6 x_4 & = 5,\\ E_2: & 5x_1 & +19 x_2 & +3 x_3 & +6 x_4 & = 7,\\ E_3: & 5x_1 & +5 x_2 & +24 x_3& +5 x_4 & = 8,\\ E_4: & 7x_1 & +7 x_2 & +4 x_3 & +25 x_4 & = 5. \end{align*} \] Vemos que la matriz \(\mathbf{A}\) del sistema: \[ \mathbf{A}=\begin{bmatrix}22&5&5&6 \\5&19&3&6 \\5&5&24&5 \\7&7&4&25 \\\end{bmatrix}, \] es estrictamente diagonal dominante ya que \[ 22 > 5+5+6=16,\ 19>5+3+6=14,\ 24>5+5+5=15,\ 25>7+7+4=18. \]

Ejemplo anterior (continuación)

Comprobemos que la matriz de iteración del método de Jacobi tiene norma infinito menor que \(1\).

La descomposición de la matriz \(\mathbf{A}\) del sistema (\(\mathbf{A}=\mathbf{D}+\mathbf{L}+\mathbf{U}\)) será: \[ \begin{bmatrix}22&5&5&6 \\5&19&3&6 \\5&5&24&5 \\7&7&4&25 \\\end{bmatrix}=\begin{bmatrix}22&0&0&0 \\0&19&0&0 \\0&0&24&0 \\0&0&0&25 \\\end{bmatrix}+\begin{bmatrix}0&0&0&0 \\5&0&0&0 \\5&5&0&0 \\7&7&4&0 \\\end{bmatrix}+\begin{bmatrix}0&5&5&6 \\0&0&3&6 \\0&0&0&5 \\0&0&0&0 \\\end{bmatrix} \]

La matriz de iteración del método de Jacobi será: \[ \begin{align*} \mathbf{T}_J & =-\mathbf{D}^{-1}(\mathbf{L}+\mathbf{U})\\ & =-\begin{bmatrix}0.045455&0&0&0 \\0&0.052632&0&0 \\0&0&0.041667&0 \\0&0&0&0.04 \\\end{bmatrix}\cdot \left(\begin{bmatrix}0&0&0&0 \\5&0&0&0 \\5&5&0&0 \\7&7&4&0 \\\end{bmatrix}+\begin{bmatrix}0&5&5&6 \\0&0&3&6 \\0&0&0&5 \\0&0&0&0 \\\end{bmatrix}\right)\\ & = \begin{bmatrix}0&-0.227273&-0.227273&-0.272727 \\-0.263158&0&-0.157895&-0.315789 \\-0.208333&-0.208333&0&-0.208333 \\-0.28&-0.28&-0.16&0 \\\end{bmatrix}. \end{align*} \]

Ejemplo anterior (continuación)

La norma infinito de la matriz anterior vale: \(0.7368421\).

Para obtener un error \(\|\mathbf{x}^{(k)}-\mathbf{x}\|<\epsilon\) que cierta tolerancia \(\epsilon\), donde \(\mathbf{x}\) es la solución exacta del sistema tenemos que realizar como máximo: \[ k\leq \frac{\ln\epsilon+\ln(1-\|\mathbf{T}_J\|)-\ln(\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|)}{\ln\|\mathbf{T}_J\|}, \] iteraciones.

Por ejemplo, suponiendo que \(\mathbf{x}^{(0)}=\mathbf{0}\) y \(\epsilon=10^{-7}\), el valor de \(\mathbf{x}_1\) vale \(\mathbf{x}_1=\begin{bmatrix}0.227273 \\0.368421 \\0.333333 \\0.2 \\\end{bmatrix}\), hemos de realizar como máximo:

\[ \begin{align*} k & \leq \left\lceil\frac{\ln0.0000001+\ln(1-0.736842)-\ln(0.368421)}{\ln(0.736842)}\right\rceil\\ & =\left\lceil\frac{-16.118096-1.335001-(-0.998529)}{-0.305382}\right\rceil = 54\ \mathrm{iteraciones.} \end{align*} \]

Ejemplo anterior (continuación)

Comprobemos que la matriz de iteración del método de Gauss-Seidel tiene norma infinito menor que \(1\).

La matriz de iteración del método de Gauss-Seidel será: \[ \begin{align*} \mathbf{T}_{GS} & =-(\mathbf{D}+\mathbf{L})^{-1}\mathbf{U}\\ & =-\begin{bmatrix}0.045455&0&0&0 \\-0.011962&0.052632&0&0 \\-0.006978&-0.010965&0.041667&0 \\-0.008262&-0.012982&-0.006667&0.04 \\\end{bmatrix}\cdot \begin{bmatrix}0&5&5&6 \\0&0&3&6 \\0&0&0&5 \\0&0&0&0 \\\end{bmatrix}\\ & = \begin{bmatrix}0&-0.227273&-0.227273&-0.272727 \\0&0.059809&-0.098086&-0.244019 \\0&0.034888&0.067783&-0.100678 \\0&0.041308&0.080255&0.160797 \\\end{bmatrix}. \end{align*} \]

Ejemplo anterior (continuación)

La norma infinito de la matriz anterior vale: \(0.7272727\).

Para obtener un error \(\|\mathbf{x}^{(k)}-\mathbf{x}\|<\epsilon\) que cierta tolerancia \(\epsilon\), donde \(\mathbf{x}\) es la solución exacta del sistema tenemos que realizar como máximo: \[ k\leq \frac{\ln\epsilon+\ln(1-\|\mathbf{T}_{GS}\|)-\ln(\|\mathbf{x}^{(1)}-\mathbf{x}^{(0)}\|)}{\ln\|\mathbf{T}_{GS}\|}, \] iteraciones.

Por ejemplo, suponiendo que \(\mathbf{x}^{(0)}=\mathbf{0}\) y \(\epsilon=10^{-7}\), el valor de \(\mathbf{x}_1\) vale \(\mathbf{x}_1=\begin{bmatrix}0.227273 \\0.308612 \\0.221691 \\0.014482 \\\end{bmatrix}\), hemos de realizar como máximo:

\[ \begin{align*} k & \leq \left\lceil\frac{\ln0.0000001+\ln(1-0.727273)-\ln(0.308612)}{\ln(0.727273)}\right\rceil\\ & =\left\lceil\frac{-16.118096-1.299283-(-1.175669)}{-0.318454}\right\rceil = 52\ \mathrm{iteraciones.} \end{align*} \]

Métodos de sobrerelajación (SOR)

Introducción

Hemos visto en la sección anterior que la clave para ver si la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) es el radio espectral de la matriz de iteración \(\mathbf{T}\) de tal forma que la sucesión de aproximaciones se define como: \[ \mathbf{x}^{(k)}=\mathbf{T}\mathbf{x}^{(k-1)}+\mathbf{c}. \] Concretamente, si el radio espectral de la matriz de iteración es menor que \(1\), \(\rho(\mathbf{T})<1\), la sucesión de aproximaciones \(\mathbf{x}^{(k)}\) convergerá a la solución exacta del sistema lineal \(\mathbf{x}\).

La idea sería diseñar un método dependiendo de un parámetro y estudiar para qué valores del parámetro el radio espectral de la matriz de iteración correspondiente tiene un valor lo más pequeño posible.

Para ello, vamos a hallar un método iterativo dependiendo de un parámetro \(w\) hallando un sistema equivalente al sistema a resolver \(\mathbf{A}\mathbf{x}=\mathbf{b}\).

Métodos SOR

Recordemos que podemos descomponer la matriz del sistema \(\mathbf{A}\) en la parte diagonal \(\mathbf{D}\), la parte triangular inferior \(\mathbf{L}\) y la parte triangular superior \(\mathbf{U}\): \(\mathbf{A}=\mathbf{D}+\mathbf{L}+\mathbf{U}\).

Escribamos el sistema \(\mathbf{A}\mathbf{x}=\mathbf{b}\) en un sistema equivalente introduciendo un parámetro \(w\): \[ \begin{align*} \mathbf{A}\mathbf{x} & = \mathbf{b},\ \Rightarrow (\mathbf{D}+\mathbf{L}+\mathbf{U})\mathbf{x} = \mathbf{b},\\ w(\mathbf{D}+\mathbf{L}+\mathbf{U})\mathbf{x} & = w\mathbf{b},\\ (w\mathbf{D}+w\mathbf{L}+w\mathbf{U})\mathbf{x} & = w\mathbf{b},\\ (\mathbf{D}+(w-1)\mathbf{D}+w\mathbf{L}+w\mathbf{U})\mathbf{x} & = w\mathbf{b},\\ (\mathbf{D}+w\mathbf{L})\mathbf{x} & = ((1-w)\mathbf{D}-w\mathbf{U})\mathbf{x}+w\mathbf{b}. \end{align*} \]

Métodos SOR

La sucesión de aproximaciones \(\mathbf{x}^{(k)}_w\) definida por los métodos anteriores parametrizados por el parámetro \(w\) viene dada por: \[ (\mathbf{D}+w\mathbf{L})\mathbf{x}^{(k)}_w = ((1-w)\mathbf{D}-w\mathbf{U})\mathbf{x}^{(k-1)}_w +w\mathbf{b} \]

La matriz de iteración del método anterior parametrizado por el parámetro \(w\) será: \(\mathbf{T}_w =(\mathbf{D}+w\mathbf{L})^{-1}((1-w)\mathbf{D}-w\mathbf{U})\) con vector independiente \(\mathbf{c}_w =w(\mathbf{D}+w\mathbf{L})^{-1}\mathbf{b}\).

Fijarse que para \(w=1\), redescubrimos el conocido método de Gauss-Seidel. Por tanto, los métodos anteriores pueden considerarse una generalización del método de Gauss-Seidel.

Los métodos anteriores se denominan métodos de relajación. Si \(0<w<1\), el método se denomina método de infrarelajación y si \(w>1\), método de sobrerelajación. Dichos métodos se abrevian con métodos SOR. (successive over-relaxation)

Método SOR. Pseudocódigo

Vamos a dar el pseudocódigo del método SOR usando como criterio de parada el criterio del error absoluto.

  • INPUT matriz del sistema \(\mathbf{A}=(a_{ij})_{i=1,\ldots,n,j=1,\ldots,n}\), vector de términos independientes \(\mathbf{b}=(b_i)_{i=1,\ldots,n}\), valor inicial \(\mathbf{X0}=\mathbf{x}^{(0)}\), error absoluto o tolerancia TOL, número máximo de iteraciones Nmax, valor del parámetro \(w\).
  • Set k=1.

Método SOR. Pseudocódigo

  • While k <= Nmax
    • For i=1,...,n
      • Set \(x_i=(1-w)X0_i+\frac{w}{a_{ii}}\left(-\sum_{j=1}^{i-1} a_{ij}x_j-\sum_{j=i+1}^n a_{ij}X0_j+b_i\right)\).
    • If \(\|\mathbf{x}-\mathbf{X0}\| <\) TOL then
      • Print \(x_1,\ldots,x_n\)
      • STOP.
    • Set k=k+1.
    • For i=1,...,n
      • Set \(X0_i =x_i\).
  • Print número máximo de iteraciones alcanzado. El método no converge.
  • STOP.

Ejemplo

Vamos a aplicar el método SOR al sistema anterior de 4 ecuaciones con 4 incógnitas: \[ \begin{align*} E_1: & 22x_1 & +5 x_2 & +5 x_3 & +6 x_4 & = 5,\\ E_2: & 5x_1 & +19 x_2 & +3 x_3 & +6 x_4 & = 7,\\ E_3: & 5x_1 & +5 x_2 & +24 x_3& +5 x_4 & = 8,\\ E_4: & 7x_1 & +7 x_2 & +4 x_3 & +25 x_4 & = 5. \end{align*} \]

Ejemplo (continuación)

Fijado un parámetro \(w\), a partir de un vector inicial de aproximación \(\mathbf{x}^{(0)}_w\), por ejemplo \(\mathbf{x}^{(0)}_w=\begin{bmatrix}0\\ 0\\0 \\ 0\end{bmatrix}\), definimos la sucesión de aproximaciones de la solución \((\mathbf{x}^{(k)}_w)_{k\geq 0}\) de la forma siguiente: \[ \begin{align*} x_{1,w}^{(k)} & =\frac{5w}{22}+(1-w) x_{1,w}^{(k-1)}-\left(\frac{5}{22} w\cdot x_{2,w}^{(k-1)} +\frac{5}{22} w\cdot x_{3,w}^{(k-1)} +\frac{6}{22} w\cdot x_{4,w}^{(k-1)}\right),\\ x_{2,w}^{(k)} & =\frac{7w}{19}+(1-w) x_{2,w}^{(k-1)}-\left(\frac{5}{19} w\cdot x_{1,w}^{(k)} +\frac{3}{19} w\cdot x_{3,w}^{(k-1)} +\frac{6}{19} w\cdot x_{4,w}^{(k-1)}\right),\\ x_{3,w}^{(k)} & =\frac{8w}{24}+(1-w) x_{3,w}^{(k-1)}-\left(\frac{5}{24} w\cdot x_{1,w}^{(k)} +\frac{5}{24} w\cdot x_{2,w}^{(k)} +\frac{5}{24} w\cdot x_{4,w}^{(k-1)}\right),\\ x_{4,w}^{(k)} & =\frac{5w}{25}+(1-w) x_{4,w}^{(k-1)}-\left(\frac{7}{25} w\cdot x_{1,w}^{(k)} +\frac{7}{25} w\cdot x_{2,w}^{(k)} +\frac{4}{25} w\cdot x_{3,w}^{(k)}\right). \end{align*} \]

Ejemplo (continuación)

Fijado \(w=1.5\), las primeras aproximaciones son las siguientes: \[ \mathbf{x}^{(0)}_w=\begin{bmatrix}0 \\0 \\0 \\0 \\\end{bmatrix},\ \mathbf{x}^{(1)}_w=\begin{bmatrix}0.340909 \\0.418062 \\0.262821 \\-0.081845 \\\end{bmatrix},\ \mathbf{x}^{(2)}_w=\begin{bmatrix}-0.028183 \\0.331247 \\0.299458 \\0.141766 \\\end{bmatrix},\ \mathbf{x}^{(3)}_w=\begin{bmatrix}0.081992 \\0.216566 \\0.212669 \\0.052682 \\\end{bmatrix},\ldots \] Si queremos que el error absoluto entre la aproximación \(\mathbf{x}^{(k)}_w\) y \(\mathbf{x}^{(k-1)}_w\) sea menor que \(10^{-7}\), es decir \(\|\mathbf{x}^{(k)}_w-\mathbf{x}^{(k-1)}_w\|\leq 10^{-7}\), tenemos que realizar \(k=29\) iteraciones y la aproximación vale: \(\mathbf{x}^{(29)}=\begin{bmatrix}0.091578 \\0.288732 \\0.242711 \\0.05468 \\\end{bmatrix}\).

Si queremos que el error relativo entre la aproximación \(\mathbf{x}^{(k)}_w\) y \(\mathbf{x}^{(k-1)}_w\) sea menor que \(10^{-7}\), es decir \(\frac{\|\mathbf{x}^{(k)}_w-\mathbf{x}^{(k-1)}_w\|}{\|\mathbf{x}^{(k)}_w\|}\leq 10^{-7}\), tenemos que realizar \(k=31\) iteraciones y la aproximación vale: \(\mathbf{x}^{(31)}=\begin{bmatrix}0.091578 \\0.288732 \\0.242711 \\0.05468 \\\end{bmatrix}\).

Ejemplo (continuación)

El método SOR se encuentra implementado en:

Convergencia en los métodos SOR

El siguiente resultado nos dice que para que un método iterativo SOR converja, el parámetro tiene que estar necesariamente entre \(0\) y \(2\):

Teorema de Kahan.

Sea \(\mathbf{x}^{(k)}_w\) una sucesión de aproximaciones para hallar la solución del sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\) a partir de la recurrencia \(\mathbf{x}^{(k)}_w=\mathbf{T}_w\mathbf{x}^{(k-1)}_w+\mathbf{c}_w\) dada por un método SOR.

Supongamos que \(a_{ii}\neq 0\), para todo \(i=1,2,\ldots,n\). Entonces el radio espectral de la matriz de iteración \(\mathbf{T}_w\) cumple: \(\rho(\mathbf{T}_w)\geq |w-1|.\)

Convergencia en los métodos SOR

Corolario.

Sea \(\mathbf{x}^{(k)}_w\) una sucesión de aproximaciones para hallar la solución del sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\) a partir de la recurrencia \(\mathbf{x}^{(k)}_w=\mathbf{T}_w\mathbf{x}^{(k-1)}_w+\mathbf{c}_w\) dada por un método SOR.

Si \(a_{ii}\neq 0\), \(i=1,\ldots,n\) y si la sucesión de aproximaciones anterior converge, el valor del parámetro \(w\) está entre \(0\) y \(2\): \(0<w<2\).

Demostración del corolario

Como la sucesión de aproximaciones \(\mathbf{x}^{(k)}_w\) converge, usando el Teorema de convergencia general, tenemos que \(\rho(\mathbf{T}_w)<1\).

Usando el Teorema de Kahan, tenemos que: \[ 1 > \rho(\mathbf{T}_w)\geq |w-1|. \] Como \(|w-1|<1\), significa que \(-1<w-1<1\) o, lo que es lo mismo, \(0<w<2\), tal como queríamos demostrar.

Demostración del Teorema de Kahan

Fijamos un valor del parámetro \(w\). Sean \(\lambda_1,\ldots,\lambda_n\) los valores propios (posiblemente repetidos y/o complejos) de la matriz de iteración \(\mathbf{T}_w\).

Tendremos que el determinante de dicha matriz será el producto de los valores propios \(\lambda_i\), \(i=1,\ldots,n\): \[ \mathrm{det}(\mathbf{T}_w)=\prod_{i=1}^n\lambda_i. \] A continuación, recordemos la expresión de la matriz de iteración \(\mathbf{T}_w\): \(\mathbf{T}_w =(\mathbf{D}-w\mathbf{L})^{-1}((1-w)\mathbf{D}-w\mathbf{U})\). Entonces, \[ \mathrm{det}(\mathbf{T}_w)=\mathrm{det}\left((\mathbf{D}-w\mathbf{L})^{-1}\right)\cdot\mathrm{det}((1-w)\mathbf{D}-w\mathbf{U})=\frac{1}{\mathrm{det}(\mathbf{D}-w\mathbf{L})}\cdot\mathrm{det}((1-w)\mathbf{D}-w\mathbf{U}). \] Ahora bien, \(\mathrm{det}(\mathbf{D}-w\mathbf{L})=\mathrm{det}(\mathbf{D})\) ya que la matriz \(\mathbf{D}-w\mathbf{L}\) es triangular inferior con valores \(d_{ii}\), \(i=1,\ldots,n\) en su diagonal y, por tanto, \(\mathrm{det}(\mathbf{D}-w\mathbf{L})=d_{11}\cdots d_{nn}=\mathrm{det}(\mathbf{D})\).

Por otro lado, \(\mathrm{det}((1-w)\mathbf{D}-w\mathbf{U})=(1-w)^n\mathrm{det}(\mathbf{D})\), ya que la matriz \((1-w)\mathbf{D}-w\mathbf{U}\) es triangular superior con valores \((1-w)d_{ii}\), \(i=1,\ldots,n\) en su diagonal y, por tanto, \(\mathrm{det}((1-w)\mathbf{D}-w\mathbf{U})=(1-w)d_{11}\cdots (1-w)d_{nn}=(1-w)^nd_{11}\cdots d_{nn}=(1-w)^n\mathrm{det}(\mathbf{D})\).

Demostración del Teorema de Kahan (cont.)

El determinante de la matriz de iteración \(\mathbf{T}_w\), será, pues, \[ \mathrm{det}(\mathbf{T}_w)=\frac{1}{\mathrm{det}(\mathbf{D})}\cdot (1-w)^n\mathrm{det}(\mathbf{D})=(1-w)^n. \]

Sea ahora \(\lambda_k\) el valor propio que nos da el radio espectral de la matriz de iteración \(\mathbf{T}_w\), es decir, \(\rho(\mathbf{T}_w)=\max_{i=1,\ldots,n}|\lambda_i|=|\lambda_k|.\)

Podemos acotar el módulo del determinante de dicha matriz por: \[ |1-w|^n = \left|\mathrm{det}(\mathbf{T}_w)\right|=\left|\prod_{i=1}^n \lambda_i\right|=\prod_{i=1}^n |\lambda_i|\leq |\lambda_k|^n =|\rho(\mathbf{T}_w)|^n. \] Entonces, \(|1-w|\leq |\rho(\mathbf{T}_w)|,\) tal como queríamos demostrar.

Ejemplo anterior

En el gráfico siguiente mostramos el radio espectral de la matriz \(\mathbf{T}_w\) para el ejemplo que hemos ido desarrollando en función del parámetro \(w\):

Ejemplo anterior (continuación)

Observamos que el valor de \(w\) para el que el radio espectral de la matriz \(\rho(\mathbf{T}_w)\) sea mínimo vale \(1.02\) con un valor del radio espectral de \(0.1755293\).

Para dicho valor de \(w\), las primeras aproximaciones son las siguientes: \[ \mathbf{x}^{(0)}_w=\begin{bmatrix}0 \\0 \\0 \\0 \\\end{bmatrix},\ \mathbf{x}^{(1)}_w=\begin{bmatrix}0.231818 \\0.313565 \\0.224106 \\0.011665 \\\end{bmatrix},\ \mathbf{x}^{(2)}_w=\begin{bmatrix}0.099295 \\0.303015 \\0.247548 \\0.048467 \\\end{bmatrix},\ \mathbf{x}^{(3)}_w=\begin{bmatrix}0.088719 \\0.290435 \\0.244179 \\0.054894 \\\end{bmatrix},\ldots \] Si queremos que el error absoluto entre la aproximación \(\mathbf{x}^{(k)}_w\) y \(\mathbf{x}^{(k-1)}_w\) sea menor que \(10^{-7}\), es decir \(\|\mathbf{x}^{(k)}_w-\mathbf{x}^{(k-1)}_w\|\leq 10^{-7}\), tenemos que realizar \(k=10\) iteraciones y la aproximación vale: \(\mathbf{x}^{(10)}=\begin{bmatrix}0.091578 \\0.288732 \\0.242711 \\0.05468 \\\end{bmatrix}\).

Observamos también que el método SOR converge para \(w\in (0,2)\).

Ejemplo anterior (continuación)

Si queremos que el error relativo entre la aproximación \(\mathbf{x}^{(k)}_w\) y \(\mathbf{x}^{(k-1)}_w\) sea menor que \(10^{-7}\), es decir \(\frac{\|\mathbf{x}^{(k)}_w-\mathbf{x}^{(k-1)}_w\|}{\|\mathbf{x}^{(k)}_w\|}\leq 10^{-7}\), tenemos que realizar \(k=11\) iteraciones y la aproximación vale: \(\mathbf{x}^{(11)}=\begin{bmatrix}0.091578 \\0.288732 \\0.242711 \\0.05468 \\\end{bmatrix}\).

Hallar el valor del parámetro \(w\) óptimo a partir del radio espectral no se puede llevar a la práctica ya que como hemos comentado anteriormente, el cálculo del radio espectral de una matriz es un problema mucho más complejo que resolver un sistema de ecuaciones.

Ejemplo anterior (continuación)

Lo que podríamos hacer es hallar el valor del parámetro \(w\) que minimiza la norma infinito de la matriz de iteración \(\mathbf{T}_w\). El gráfico siguiente muestra la norma infinito de la matriz \(\mathbf{T}_w\) para el ejemplo que hemos ido desarrollando en función del parámetro \(w\):

Ejemplo anterior (continuación)

Observamos que el valor del parámetro óptimo usando el criterio de la norma infinito se alcanza para \(w=1\), es decir, el método de Gauss-Seidel!

Observamos también que, según dicho criterio, podemos asegurar que el método SOR converge para \(w\in (0,1.16)\).

En general, el cálculo del valor óptimo del parámetro \(w\) usando los dos criterios anteriores se puede encontrar implementado en:

Convergencia en los métodos SOR

Tal como vimos en el ejemplo anterior, la convergencia de un método SOR no está asegurada para cualquier valor \(w\in (0,2)\).

Sin embargo, existe el resultado siguiente:

Teorema de Ostrowski-Reich.

Si la matriz del sistema \(\mathbf{A}\) es simétrica y definida positiva y \(0<w<2\), el método iterativo SOR converge para cualquier aproximación inicial \(\mathbf{x}^{(0)}\).

Convergencia en los métodos SOR

El resultado siguiente nos dice cuál es el valor de \(w\) óptimo, es decir, el valor que minimiza el radio espectral de la matriz de iteración \(\mathbf{T}_w\) en el caso en que la matriz del sistema \(\mathbf{A}\) cumpla las condiciones siguientes:

Teorema.

Si la matriz \(\mathbf{A}\) del sistema es simétrica, definida positiva y tridiagonal, el radio espectral de la matriz de iteración del método de Gauss-Seidel es el cuadrado del radio espectral de la matriz de iteración del método de Jacobi, \(\rho(\mathbf{T}_{GS})=\rho(\mathbf{T}_J)^2 <1\) y además dichos métodos son convergentes.

El valor del parámetro \(w\) óptimo es el siguiente: \(\tilde{w}=\frac{2}{1+\sqrt{1-\rho(\mathbf{T}_J)^2}}=\frac{2}{\rho(\mathbf{T}_J)^2}\left(1-\sqrt{1-\rho(\mathbf{T}_J)^2}\right),\) con valor de radio espectral: \(\rho(\mathbf{T}_{\tilde{w}})=\tilde{w}-1=\frac{2}{\rho(\mathbf{T}_J)^2}\left(2-\rho(\mathbf{T}_J)^2-2\sqrt{1-\rho(\mathbf{T}_J)^2}\right).\)

Métodos iterativos vs. métodos directos

  • Cuando la dimensión de la matriz del sistema lineal a resolver \(\mathbf{A}\mathbf{x}=\mathbf{b}\) no es demasiado grande, es mejor usar los métodos directos al ser éstos más eficientes en este caso y proporcionar soluciones exactas.

  • En cambio, si la dimensión de la matriz del sistema lineal es muy grande y es una matriz sparse que significa que tiene muchos ceros sin ninguna estructura predefinida, es mejor usar métodos iterativos ya que ahorran en almacenamiento y tienen un coste computacional más bajo que los métodos directos. Los sistemas de este segundo tipo aparecen en problemas de frontera en ecuaciones en derivadas parciales así como en problemas de redes neuronales en el campo de la inteligencia artificial.

El método del gradiente conjugado

Introducción

El método del gradiente conjugado, como veremos, puede usarse como método directo donde resuelve el sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\) en \(n\) pasos o como método iterativo hallando soluciones aproximadas del sistema anterior.

Como método directo, es computacionalmente más costoso que el método de Gauss con pivotaje.

Sin embargo, como método iterativo, es muy útil para resolver sistemas sparse, es decir, sistemas lineales donde la matriz del sistema \(\mathbf{A}\) tiene dimensiones \(n\times n\) muy grandes y con muchos ceros. Este tipo de sistemas aparecen en el análisis de redes neuronales.

Recordemos que dentro del ámbito del álgebra lineal, suponemos que los vectores vienen representados en columnas. En este contexto, \(\mathbf{u}^\top \mathbf{v}\) simboliza el producto escalar entre los vectores \(\mathbf{u}\) y \(\mathbf{v}\).

Introducción

El método del gradiente conjugado está basado en el resultado siguiente:

Teorema.

Consideremos el sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\), donde la matriz del sistema \(\mathbf{A}\) es simétrica y definida positiva.

Entonces, el vector \(\tilde{\mathbf{x}}\) es solución del sistema anterior \(\mathbf{A}\mathbf{x}=\mathbf{b}\) si, y sólo si, \(\tilde{\mathbf{x}}\) minimiza la función siguiente \(g(\mathbf{x})=\mathbf{x}^\top (\mathbf{A}\mathbf{x})-2(\mathbf{x}^\top \mathbf{b})\).

Demostración del teorema

Sean \(\mathbf{x}\) y \(\mathbf{v}\neq\mathbf{0}\) dos vectores fijos y \(t\in\mathbb{R}\) un valor real. Entonces: \[ \begin{align*} g(\mathbf{x}+t\mathbf{v}) & = (\mathbf{x}+t\mathbf{v})^\top (\mathbf{A}(\mathbf{x}+t\mathbf{v}))-2((\mathbf{x}+t\mathbf{v})^\top \mathbf{b})\\ & =\mathbf{x}^\top (\mathbf{A}\mathbf{x})+t(\mathbf{x}^\top (\mathbf{A}\mathbf{v}))+t(\mathbf{v}^\top (\mathbf{A}\mathbf{x}))+t^2 (\mathbf{v}^\top (\mathbf{A}\mathbf{v}))-2(\mathbf{x}^\top \mathbf{b})-2t(\mathbf{v}^\top \mathbf{b}) \end{align*} \] Por ser la matriz \(\mathbf{A}\) simétrica (\(\mathbf{A}=\mathbf{A}^\top\)), \(\mathbf{x}^\top (\mathbf{A}\mathbf{v})=\mathbf{v}^\top (\mathbf{A}\mathbf{x})\) ya que: \[ \mathbf{x}^\top (\mathbf{A}\mathbf{v})=\mathbf{x}^\top\mathbf{A}\mathbf{v}=\mathbf{v}^\top\mathbf{A}^\top\mathbf{x}=\mathbf{v}^\top\mathbf{A}\mathbf{x}=\mathbf{v}^\top (\mathbf{A}\mathbf{x}). \] Entonces, \[ \begin{align*} g(\mathbf{x}+t\mathbf{v}) & =t^2(\mathbf{v}^\top (\mathbf{A}\mathbf{v}))+2t(\mathbf{v}^\top (\mathbf{A}\mathbf{x})-\mathbf{v}^\top \mathbf{b})+\mathbf{x}^\top (\mathbf{A}\mathbf{x})-2(\mathbf{x}^\top \mathbf{b})\\ & = t^2(\mathbf{v}^\top (\mathbf{A}\mathbf{v}))-2t \mathbf{v}^\top (\mathbf{b}-\mathbf{A}\mathbf{x})+g(\mathbf{x}). \end{align*} \] Si definimos \(h(t)=g(\mathbf{x}+t\mathbf{v})\) como una función real de variable real, vemos que la función \(h\) es una función de segundo grado, es decir, es una parábola y como el coeficiente de \(t^2\), \(\mathbf{v}^\top (\mathbf{A}\mathbf{v})=\mathbf{v}^\top\mathbf{A}\mathbf{v}\geq 0\), al ser la matriz \(\mathbf{A}\) definida positiva, tiene un mínimo en \(\tilde{t}\) que verifica \(h'(\tilde{t})=0\): \[ h'(t)=2t(\mathbf{v}^\top (\mathbf{A}\mathbf{v}))-2\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\mathbf{x})=0. \]

Demostración del teorema (continuación)

El valor de \(\tilde{t}\) será: \[ \tilde{t}=\frac{\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\mathbf{x})}{\mathbf{v}^\top (\mathbf{A}\mathbf{v})}. \] El valor de \(h(\tilde{t})=g(\mathbf{x}+\tilde{t}\mathbf{v})\) vale: \[ \begin{align*} h(\tilde{t}) & =g(\mathbf{x}+\tilde{t}\mathbf{v}) = \tilde{t}^2(\mathbf{v}^\top (\mathbf{A}\mathbf{v}))-2\tilde{t} \mathbf{v}^\top (\mathbf{b}-\mathbf{A}\mathbf{x})+g(\mathbf{x})\\ &= \left(\frac{\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\mathbf{x})}{\mathbf{v}^\top (\mathbf{A}\mathbf{v})}\right)^2(\mathbf{v}^\top (\mathbf{A}\mathbf{v}))-2\frac{\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\mathbf{x})}{\mathbf{v}^\top (\mathbf{A}\mathbf{v})} \mathbf{v}^\top (\mathbf{b}-\mathbf{A}\mathbf{x})+g(\mathbf{x}) \\ & =g(\mathbf{x})- \frac{(\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\mathbf{x}))^2}{\mathbf{v}^\top (\mathbf{A}\mathbf{v})}. \end{align*} \] Observamos que \(g(\mathbf{x}+\tilde{t}\mathbf{v})<g(\mathbf{x})\) a no ser que \(\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\mathbf{x})=0\) en cuyo caso \(g(\mathbf{x})=g(\mathbf{x}+\tilde{t}\mathbf{v})\).

Demostración del teorema (continuación)

Pasemos a continuación a demostrar el teorema.

Supongamos que \(\hat{\mathbf{x}}\) es la solución del sistema lineal \(\mathbf{A}\hat{\mathbf{x}}=\mathbf{b}\). Entonces \(\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\hat{\mathbf{x}})=0\), para cualquier vector \(\mathbf{v}\). En este caso, tendremos que \(g(\mathbf{x})\) no puede ser menor que \(g(\hat{\mathbf{x}})\), para cualquier \(\mathbf{x}\) ya que si consideramos \(\mathbf{v}=(\mathbf{x}-\hat{\mathbf{x}})\) y \(t=1\), \[ g(\mathbf{x})=g\left(\hat{\mathbf{x}}+t\mathbf{v}\right) =t^2\mathbf{v}^\top (\mathbf{A}\mathbf{v})+g(\hat{\mathbf{x}})\geq g(\hat{\mathbf{x}}), \] al ser la matriz \(\mathbf{A}\) definida positiva y, por tanto, \(\mathbf{v}^\top (\mathbf{A}\mathbf{v})\geq 0\).

Por tanto, \(\hat{\mathbf{x}}\) minimiza la función \(g(\mathbf{x})\).

Supongamos ahora que \(\hat{\mathbf{x}}\) minimiza la función \(g(\mathbf{x})\). Entonces para cualquier vector \(\mathbf{v}\), se cumplirá que \(g(\hat{\mathbf{x}}+\tilde{t}\mathbf{v})\geq g(\hat{\mathbf{x}})\), donde \(\tilde{t}=\frac{\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\hat{\mathbf{x}})}{\mathbf{v}^\top (\mathbf{A}\mathbf{v})}\) pero hemos visto que: \[ g(\hat{\mathbf{x}}+\tilde{t}\mathbf{v})=g(\hat{\mathbf{x}})- \frac{(\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\hat{\mathbf{x}}))^2}{\mathbf{v}^\top (\mathbf{A}\mathbf{v})}. \] Entonces, necesariamente \(\mathbf{v}^\top (\mathbf{b}-\mathbf{A}\hat{\mathbf{x}})=0\), para cualquier vector \(\mathbf{v}\), lo que implica que \(\mathbf{b}-\mathbf{A}\hat{\mathbf{x}}=\mathbf{0}\), o, lo que es lo mismo, que \(\hat{\mathbf{x}}\) es la solución del sistema \(\mathbf{A}\hat{\mathbf{x}}=\mathbf{b}\), tal como queríamos demostrar.

Algoritmo del gradiente conjugado

Para desarrollar el algoritmo del gradiente conjugado, supongamos que tenemos \(\mathbf{x}\) una solución aproximada del sistema \(\mathbf{A}\mathbf{x}=\mathbf{b}\) y consideramos un vector \(\mathbf{v}\neq\mathbf{0}\).

La idea es buscar una dirección para avanzar a partir de la solución aproximada anterior \(\mathbf{x}\) que nos dé una aproximación mejor de tal forma que minimice la función \(g(\mathbf{x})\) definida anteriormente ya que el teorema anterior dice que cuanto mejor minimicemos la función \(g(\mathbf{x})\), mejor solución hallaremos del sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\).

Sea \(\mathbf{r}=\mathbf{b}-\mathbf{A}\mathbf{x}\) el residuo asociado a la solución aproximada \(\mathbf{x}\) y sea \(t=\frac{\mathbf{v}^\top \mathbf{r}}{\mathbf{v}^\top \mathbf{A}\mathbf{v}},\) el valor que hace que la función \(g(\mathbf{x}+t\mathbf{v})\) sea mínimo en la dirección \(\mathbf{v}\), tal como vimos en la demostración del teorema.

Definimos \(\hat{\mathbf{x}}=\mathbf{x}+t\mathbf{v}\) la nueva aproximación a partir de la dirección \(\mathbf{v}\) que sabemos que es la mejor ya que \(\hat{\mathbf{x}}\) minimiza \(g(\mathbf{x})\) en la dirección \(\mathbf{v}\), es decir, minimiza la función \(h(t)=g(\mathbf{x}+t\mathbf{v})\).

Algoritmo del gradiente conjugado

A partir de las consideraciones anteriores, ya tenemos el algoritmo preliminar del gradiente conjugado:

  • Sea \(\mathbf{x}^{(0)}\) una aproximación inicial y sea \(\mathbf{v}^{(1)}\neq\mathbf{0}\) una dirección de búsqueda inicial. Sea \(\mathbf{r}^{(0)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)}\).
  • Calculamos \(\mathbf{x}^{(1)}\) de la siguiente forma: \[ t_1=\frac{(\mathbf{v}^{(1)})^\top (\mathbf{r}^{(0)})}{(\mathbf{v}^{(1)})^\top (\mathbf{A}\mathbf{v}^{(1)})},\quad \mathbf{x}^{(1)}=\mathbf{x}^{(0)}+t_1\mathbf{v}^{(1)}. \]
  • En general, supongamos que tenemos \(\mathbf{x}^{(0)},\ldots,\mathbf{x}^{(k-1)}\) y direcciones de búsqueda \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(k)}\). Sea \(\mathbf{r}^{(k-1)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(k-1)}\). Definimos: \[ t_k=\frac{(\mathbf{v}^{(k)})^\top (\mathbf{r}^{(k-1)})}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})},\quad \mathbf{x}^{(k)}=\mathbf{x}^{(k-1)}+t_k\mathbf{v}^{(k)}. \]

Algoritmo del gradiente conjugado

En la descripción del algoritmo anterior, no se indica cómo encontrar las direcciones de búsqueda. Éste es el motivo que sea una versión preliminar.

Dada una aproximación inicial, la dirección de búsqueda tiene que ser aquélla que tenga una máxima disminución en la función \(g(\mathbf{x})\).

Dada una función de \(n\) variables \(g(\mathbf{x})\) y una aproximación inicial \(\mathbf{x}\) sabemos a partir del Análisis multivariante que la dirección de disminución máxima de la función \(g(\mathbf{x})\) viene dada por el gradiente de \(g\): \[ \nabla g(\mathbf{x})=\left(\frac{\partial g}{\partial x_1}(\mathbf{x}),\frac{\partial g}{\partial x_2}(\mathbf{x}),\ldots,\frac{\partial g}{\partial x_n}(\mathbf{x})\right). \]

Algoritmo del gradiente conjugado

Hallemos pues el gradiente de la función \(g(\mathbf{x})\).

Recordemos que la función \(g(\mathbf{x})=g(x_1,\ldots,x_n)\) era la siguiente: \[ g(\mathbf{x})=\mathbf{x}^\top (\mathbf{A}\mathbf{x})-2(\mathbf{x}^\top \mathbf{b})=\sum_{i,j=1}^n a_{ij}x_i x_j-2\sum_{i=1}^n x_i b_i. \] El valor de \(\frac{\partial g}{\partial x_k}(\mathbf{x})\) será: \(\displaystyle\frac{\partial g}{\partial x_k}(\mathbf{x})=2\sum_{i=1}^n a_{ki}x_i-2 b_k.\)

Matricialmente: \[ \nabla g(\mathbf{x})=2\mathbf{A}\mathbf{x}-2\mathbf{b}=2(\mathbf{A}\mathbf{x}-\mathbf{b})=-2\mathbf{r}, \] donde recordemos que \(\mathbf{r}\) es el residuo: \(\mathbf{r}=\mathbf{b}-\mathbf{A}\mathbf{x}\).

Algoritmo del gradiente conjugado

Entonces en el algoritmo anterior, la dirección de búsqueda en el paso \(k\)-ésimo será: \(\mathbf{v}^{(k)}=\mathbf{r}^{(k-1)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(k-1)}\).

El método que usa la dirección de búsqueda anterior se denomina método del máximo descenso. Dicho método es raramente usado en la resolución de sistemas lineales debido a la lentitud de la convergencia del mismo. Sin embargo, sí se usa en problemas de resolución de sistemas no lineales y problemas de optimización.

Algoritmo del gradiente conjugado

Una manera de acelerar la convergencia es usar un conjunto de direcciones de búsqueda \(\mathbf{v}^{(1)},\ldots, \mathbf{v}^{(k)}\) que sean \(\mathbf{A}\)-ortogonales, es decir, \((\mathbf{v}^{(i)})^\top (\mathbf{A}\mathbf{v}^{(j)})=0\), si \(i\neq j\).

Antes de describir cómo hallar las direcciones de búsqueda anteriores, enunciemos el teorema que nos asegura que si las direcciones de búsqueda son \(\mathbf{A}\)-ortogonales, resolvemos el sistema lineal en \(n\) pasos:

Algoritmo del gradiente conjugado

Teorema.

Sean \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(n)}\), \(n\) vectores no nulos \(\mathbf{A}\)-ortogonales. Sea \(\mathbf{x}^{(0)}\) un vector inicial arbitrario. Definimos, \[ t_k =\frac{(\mathbf{v}^{(k)})^\top (b-\mathbf{A}\mathbf{x}^{(k-1)})}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})},\quad \mathbf{x}^{(k)}=\mathbf{x}^{(k-1)}+t_k\mathbf{v}^{(k)}, \] para \(k=1,\ldots,n\). Entonces, suponiendo que no hay errores de redondeo ni errores en las operaciones, el vector \(\mathbf{x}^{(n)}\) es la solución del sistema lineal \(\mathbf{A}\mathbf{x}=\mathbf{b}\), es decir, \(\mathbf{A}\mathbf{x}^{(n)}=\mathbf{b}\).

Lema previo

Antes de demostrar el teorema, demostremos el lema siguiente:

Lema.

Sean \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(n)}\), \(n\) vectores no nulos \(\mathbf{A}\)-ortogonales, donde la matriz \(\mathbf{A}\) es simétrica, definida positiva y no singular.. Entonces los vectores anteriores \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(n)}\) son linealmente independientes.

Demostración del lema

Para ver que los vectores \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(n)}\) son linealmente independientes, supondremos una combinación lineal de los mismos igual a cero y tenemos que ver que todos los coeficientes de dicha combinación lineal son cero.

Es decir, suponemos: \[ a_1\mathbf{v}^{(1)}+a_2\mathbf{v}^{(2)}+\cdots +a_n\mathbf{v}^{(n)}=\mathbf{0}, \] implica necesariamente que los valores \(a_i\) son cero: \(a_i=0,\ i=1,\ldots,n\).

Demostración del lema (continuación)

Como \(a_1\mathbf{v}^{(1)}+a_2\mathbf{v}^{(2)}+\cdots +a_n\mathbf{v}^{(n)}=\mathbf{0}\), se cumplirá que para todo \(j=1,\ldots,n\), \[(a_1\mathbf{v}^{(1)}+a_2\mathbf{v}^{(2)}+\cdots +a_n\mathbf{v}^{(n)})^\top \mathbf{A}\mathbf{v}^{(j)}=\mathbf{0}^\top \mathbf{A}\mathbf{v}^{(j)}=0.\]

Usando que los vectores \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(n)}\) son \(\mathbf{A}\)-ortogonales, es decir, \((\mathbf{v}^{(i)})^\top \mathbf{A}\mathbf{v}^{(j)}=0\), para \(i\neq j\), podemos escribir la expresión anterior como: \[ (a_1\mathbf{v}^{(1)}+a_2\mathbf{v}^{(2)}+\cdots +\mathbf{v}^{(n)})^\top \mathbf{A}\mathbf{v}^{(j)}=\sum_{i=1}^n a_i(\mathbf{v}^{(i)})^\top \mathbf{A}\mathbf{v}^{(j)}=a_j(\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(j)}=0. \] Entonces, o \(a_j=0\) o \((\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(j)}=0\). Veamos que la segunda condición no puede ser, de hecho, veamos que para cualquier vector \(\mathbf{x}\neq \mathbf{0}\), \(\mathbf{x}^\top \mathbf{A}{\mathbf{x}}\neq 0\). Si vemos la condición anterior, ya habremos demostrado el lema, ya que los valores \(a_j=0\), para \(j=1,\ldots,n\), lo que significa que los vectores \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(n)}\) son linealmente independientes.

Sea entonces un vector \(\mathbf{x}\neq\mathbf{0}\). Como la matriz \(\mathbf{A}\) es simétrica, definida positiva y no singular, sabemos que existe una base \(\mathbf{w}^{(1)},\mathbf{w}^{(2)},\ldots,\mathbf{w}^{(n)}\) de vectores propios de valores propios \(\lambda_1>0,\ldots,\lambda_n>0\) todos estrictamente positivos y además ortogonales entre sí: \((\mathbf{w}^{(i)})^\top \mathbf{w}^{(j)}=0,\ i\neq j\).

Demostración del lema (continuación)

Entonces el vector \(\mathbf{x}\) se puede escribir como \(\displaystyle\mathbf{x}=\alpha_1\mathbf{w}^{(1)}+\cdots +\alpha_n\mathbf{w}^{(n)}=\sum_{i=1}^n\alpha_i\mathbf{w}^{(i)},\) para coeficientes \(\alpha_i\) no todos cero, \(i=1,\ldots,n\).

Supongamos que \(\mathbf{x}^\top \mathbf{A}\mathbf{x}=0\). Usando la descomposición anterior, tenemos que: \[ \begin{align*} \mathbf{x}^\top \mathbf{A}\mathbf{x} & =\left(\sum_{i=1}^n\alpha_i\mathbf{w}^{(i)}\right)^\top \mathbf{A}\left(\sum_{i=1}^n\alpha_i\mathbf{w}^{(i)}\right)=\sum_{i,j=1}^n \alpha_i\alpha_j(\mathbf{w}^{(i)})^\top \mathbf{A}\mathbf{w}^{(j)}=\sum_{i,j=1}^n \alpha_i\alpha_j\lambda_j(\mathbf{w}^{(i)})^\top \mathbf{w}^{(j)}\\ & = \sum_{i=1}^n \lambda_i\alpha_i^2 (\mathbf{w}^{(i)})^\top \mathbf{w}^{(i)} = \sum_{i=1}^n \lambda_i\alpha_i^2 \|\mathbf{w}^{(i)}\|_2^2 =0. \end{align*} \] Hemos obtenido que la suma de \(n\) valores positivos son cero, lo que significa que para todo \(i=1,\ldots,n\), \(\lambda_i\alpha_i^2=0\) pero \(\lambda_i>0\), lo que significa que \(\alpha_i^2=0\), para \(i=1,\ldots,n\). En este caso: \(\displaystyle \mathbf{x}=\sum_{i=1}^n\alpha_i\mathbf{w}^{(i)}=\mathbf{0}\), lo que contradice lo que supusimos que \(\mathbf{x}\neq \mathbf{0}\). Esto significa que \(\mathbf{x}^\top \mathbf{A}\mathbf{x}\neq 0\) tal como queríamos demostrar.

Demostración del teorema

Veamos a continuación la demostración del teorema.

Como para \(k=1,\ldots,n\), \(\mathbf{x}^{(k)}=\mathbf{x}^{(k-1)}+t_k\mathbf{v}^{(k)}\), tenemos que el valor de \(\mathbf{A}\mathbf{x}^{(n)}\) será: \[ \begin{align*} \mathbf{A}\mathbf{x}^{(n)} & = \mathbf{A}\mathbf{x}^{(n-1)}+t_n\mathbf{A}\mathbf{v}^{(n)}=\mathbf{A}(\mathbf{x}^{(n-2)}+t_{n-1}\mathbf{v}^{(n-1)})+t_n\mathbf{A}\mathbf{v}^{(n)}\\ & =\mathbf{A}\mathbf{x}^{(n-2)}+t_{n-1}\mathbf{A}\mathbf{v}^{(n-1)}+t_n\mathbf{A}\mathbf{v}^{(n)} \\ & =\cdots = \mathbf{A}\mathbf{x}^{(0)}+t_{1}\mathbf{A}\mathbf{v}^{(1)}+t_{2}\mathbf{A}\mathbf{v}^{(2)}+\cdots + t_n\mathbf{A}\mathbf{v}^{(n)}. \end{align*} \] Entonces: \[ \mathbf{A}\mathbf{x}^{(n)}-\mathbf{b}= \mathbf{A}\mathbf{x}^{(0)}-\mathbf{b}+t_{1}\mathbf{A}\mathbf{v}^{(1)}+t_{2}\mathbf{A}\mathbf{v}^{(2)}+\cdots + t_n\mathbf{A}\mathbf{v}^{(n)}. \] Si multiplicamos la expresión anterior por cada vector \(\mathbf{v}^{(j)}\) obtenemos: \[ (\mathbf{A}\mathbf{x}^{(n)}-\mathbf{b})^\top \mathbf{v}^{(j)}=(\mathbf{A}\mathbf{x}^{(0)}-\mathbf{b})^\top \mathbf{v}^{(j)}+t_{1}(\mathbf{A}\mathbf{v}^{(1)})^\top \mathbf{v}^{(j)}+t_{2}(\mathbf{A}\mathbf{v}^{(2)})^\top \mathbf{v}^{(j)}+\cdots + t_n(\mathbf{A}\mathbf{v}^{(n)})^\top \mathbf{v}^{(j)}. \] Usando que los vectores \(\mathbf{v}^{(j)}\) son \(\mathbf{A}\)-ortogonales, (\((\mathbf{v}^{(i)})^\top \mathbf{A}\mathbf{v}^{(j)}=0,\ i\neq j\)), la expresión anterior será: \[ (\mathbf{A}\mathbf{x}^{(n)}-\mathbf{b})^\top \mathbf{v}^{(j)}=(\mathbf{A}\mathbf{x}^{(0)}-\mathbf{b})^\top \mathbf{v}^{(j)}+t_{j}(\mathbf{A}\mathbf{v}^{(j)})^\top \mathbf{v}^{(j)}. \]

Demostración del teorema (continuación)

Ahora, usando que \[ t_j(\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(j)}=\frac{(\mathbf{v}^{(j)})^\top (\mathbf{b}-\mathbf{A}\mathbf{x}^{(j-1)})}{(\mathbf{v}^{(j)})^\top (\mathbf{A}\mathbf{v}^{(j)})}\left((\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(j)}\right)=(\mathbf{v}^{(j)})^\top (\mathbf{b}-\mathbf{A}\mathbf{x}^{(j-1)}), \] obtenemos: \[ \begin{align*} t_j(\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(j)} & = (\mathbf{v}^{(j)})^\top (\mathbf{b}-\mathbf{A}\mathbf{x}^{(j-1)})\\ &= (\mathbf{v}^{(j)})^\top (\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)}+\mathbf{A}\mathbf{x}^{(0)}-\mathbf{A}\mathbf{x}^{(1)}+\cdots -\mathbf{A}\mathbf{x}^{(j-2)}+\mathbf{A}\mathbf{x}^{(j-2)}-\mathbf{A}\mathbf{x}^{(j-1)})\\ &= (\mathbf{v}^{(j)})^\top (\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)})+(\mathbf{v}^{(j)})^\top (\mathbf{A}\mathbf{x}^{(0)}-\mathbf{A}\mathbf{x}^{(1)})+\cdots +(\mathbf{v}^{(j)})^\top (\mathbf{A}\mathbf{x}^{(j-2)}-\mathbf{A}\mathbf{x}^{(j-1)}). \end{align*} \] Ahora bien, como \(\mathbf{x}^{(i)}=\mathbf{x}^{(i-1)}+t_i\mathbf{v}^{(i)}\), tenemos que \(\mathbf{A}\mathbf{x}^{(i)}=\mathbf{A}\mathbf{x}^{(i-1)}+t_i\mathbf{A}\mathbf{v}^{(i)}\) y, por tanto, \[ \mathbf{A}\mathbf{x}^{(i-1)}-\mathbf{A}\mathbf{x}^{(i)}=-t_i\mathbf{A}\mathbf{v}^{(i)}. \] Entonces, \[ t_j(\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(j)} =(\mathbf{v}^{(j)})^\top (\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)})-t_1(\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(1)}-\cdots -t_{j-1}(\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(j-1)}. \] Usando otra vez que los vectores \(\mathbf{v}^{(j)}\) son \(\mathbf{A}\)-ortogonales, \((\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(i)}=0\), para \(i=1,\ldots,j-1\), obtenemos: \[ t_j(\mathbf{v}^{(j)})^\top \mathbf{A}\mathbf{v}^{(j)}=(\mathbf{v}^{(j)})^\top (\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)}). \]

Demostración del teorema (continuación)

Entonces el valor de \((\mathbf{A}\mathbf{x}^{(n)}-\mathbf{b})^\top \mathbf{v}^{(j)}\) será: \[ \begin{align*} (\mathbf{A}\mathbf{x}^{(n)}-\mathbf{b})^\top \mathbf{v}^{(j)} & =(\mathbf{A}\mathbf{x}^{(0)}-\mathbf{b})^\top \mathbf{v}^{(j)}+t_{j}(\mathbf{A}\mathbf{v}^{(j)})^\top \mathbf{v}^{(j)} = (\mathbf{A}\mathbf{x}^{(0)}-\mathbf{b})^\top \mathbf{v}^{(j)}+(\mathbf{v}^{(j)})^\top (\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)}) \\ &= (\mathbf{A}\mathbf{x}^{(0)}-\mathbf{b})^\top \mathbf{v}^{(j)}+(\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)})^\top \mathbf{v}^{(j)}=\mathbf{0}^\top \mathbf{v}^{(j)}=0. \end{align*} \] Como el vector \(\mathbf{A}\mathbf{x}^{(n)}-\mathbf{b}\) es ortogonal a todos los vectores \(\mathbf{v}^{(j)}\), \(j=1,\ldots,n\) y éstos son linealmente independientes usando el lema anterior, tenemos que \(\mathbf{A}\mathbf{x}^{(n)}-\mathbf{b}=\mathbf{0}\), tal como queríamos demostrar.

Algoritmo del gradiente conjugado

Antes de enunciar el algoritmo veamos que si los vectores \(\mathbf{v}^{(j)}\) son \(\mathbf{A}\)-ortogonales, entonces los residuos \(\mathbf{r}^{(k)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(k)}\) y los vectores \(\mathbf{v}^{(j)}\) son ortogonales:

Proposición.

Sean \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(n)}\), \(n\) vectores no nulos \(\mathbf{A}\)-ortogonales. Sea \(\mathbf{x}^{(0)}\) un vector inicial arbitrario y sea \(\mathbf{r}^{(0)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)}\). Definimos: \[ t_k =\frac{(\mathbf{v}^{(k)})^\top (b-\mathbf{A}\mathbf{x}^{(k-1)})}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})},\quad \mathbf{x}^{(k)}=\mathbf{x}^{(k-1)}+t_k\mathbf{v}^{(k)},\quad \mathbf{r}^{(k)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(k)}, \] para \(k=1,\ldots,n\). Entonces los vectores \(\mathbf{v}^{(j)}\), \(j=1,\ldots,k\) son ortogonales al vector \(\mathbf{r}^{(k)}\): \((\mathbf{r}^{(k)})^\top \mathbf{v}^{(j)}=0\), \(j=1,\ldots,k\).

Demostración de la proposición

Vamos a demostrar la proposición anterior por inducción sobre \(k\).

Supongamos \(k=1\). Veamos que \((\mathbf{r}^{(1)})^\top \mathbf{v}^{(1)}=0\): \[ \begin{align*} (\mathbf{r}^{(1)})^\top \mathbf{v}^{(1)} & =(\mathbf{b}-\mathbf{A}\mathbf{x}^{(1)})^\top \mathbf{v}^{(1)} =(\mathbf{b}-\mathbf{A}(\mathbf{x}^{(0)}+t_1 \mathbf{v}^{(1)}))^\top \mathbf{v}^{(1)} \\ & = (\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)})^\top \mathbf{v}^{(1)}-t_1(\mathbf{A}\mathbf{v}^{(1)})^\top \mathbf{v}^{(1)}=0, \end{align*} \] donde la última igualdad se verifica por definición de \(t_1\).

Supongamos ahora que \((\mathbf{r}^{(k-1)})^\top \mathbf{v}^{(j)}=0\), para \(j=1,\ldots,k-1\). Veamos que si \(j\) está entre \(1\) y \(k\), entonces \((\mathbf{r}^{(k)})^\top \mathbf{v}^{(j)}=0\).

Supongamos primero que \(j\) está entre \(1\) y \(k-1\). En este caso, tenemos que: \[ \begin{align*} (\mathbf{r}^{(k)})^\top \mathbf{v}^{(j)} & =(\mathbf{b}-\mathbf{A}\mathbf{x}^{(k)})^\top \mathbf{v}^{(j)} =(\mathbf{b}-\mathbf{A}(\mathbf{x}^{(k-1)}+t_k \mathbf{v}^{(k)}))^\top \mathbf{v}^{(j)} \\ & = (\mathbf{b}-\mathbf{A}\mathbf{x}^{(k-1)})^\top \mathbf{v}^{(j)}-t_k(\mathbf{A}\mathbf{v}^{(k)})^\top \mathbf{v}^{(j)}=(\mathbf{r}^{(k-1)})^\top \mathbf{v}^{(j)}-t_k(\mathbf{A}\mathbf{v}^{(k)})^\top \mathbf{v}^{(j)}. \end{align*} \] El valor \((\mathbf{r}^{(k-1)})^\top \mathbf{v}^{(j)}=0\) es cero por hipótesis de inducción y el valor \((\mathbf{A}\mathbf{v}^{(k)})^\top \mathbf{v}^{(j)}=0\) porque los vectores \(\mathbf{v}^{(j)}\) son \(A\)-ortogonales. Por tanto, queda demostrado que \((\mathbf{r}^{(k)})^\top \mathbf{v}^{(j)}=0\), si \(j\) está entre \(1\) y \(k-1\).

Demostración de la proposición (continuación)

Supongamos ahora que \(j=k\). En este caso tenemos: \[ \begin{align*} (\mathbf{r}^{(k)})^\top \mathbf{v}^{(k)} & =(\mathbf{b}-\mathbf{A}\mathbf{x}^{(k)})^\top \mathbf{v}^{(k)} =(\mathbf{b}-\mathbf{A}(\mathbf{x}^{(k-1)}+t_k \mathbf{v}^{(k)}))^\top \mathbf{v}^{(k)} \\ & = (\mathbf{b}-\mathbf{A}\mathbf{x}^{(k-1)})^\top \mathbf{v}^{(k)}-t_k(\mathbf{A}\mathbf{v}^{(k)})^\top \mathbf{v}^{(k)}=0, \end{align*} \] por definición de \(t_k\).

Algoritmo del gradiente conjugado

El algoritmo del gradiente conjugado se basa en definir la sucesión de soluciones aproximadas \(\mathbf{x}^{(k)}\) a partir de una solución inicial \(\mathbf{x}^{(0)}\) usando la recurrencia vista anteriormente: \[ t_k =\frac{(\mathbf{v}^{(k)})^\top (b-\mathbf{A}\mathbf{x}^{(k-1)})}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})}=\frac{(\mathbf{v}^{(k)})^\top \mathbf{r}^{(k-1)}}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})},\quad \mathbf{x}^{(k)}=\mathbf{x}^{(k-1)}+t_k\mathbf{v}^{(k)}, \] eligiendo los vectores \(\mathbf{v}^{(k)}\), \(\mathbf{A}\)-ortogonales y además se verificará que los residuos \(\mathbf{r}^{(k)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(k)}\) serán ortogonales entre sí: \({\mathbf{r}^{(i)}}^\top \mathbf{r}^{(j)}=0\), para \(i\neq j\).

Algoritmo del gradiente conjugado

Veamos cómo funciona.

Sea \(\mathbf{x}^{(0)}\) una aproximación inicial con residuo inicial \(\mathbf{r}^{(0)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)}\).

  • Elegimos \(\mathbf{v}^{(1)}=\mathbf{r}^{(0)}\). La aproximación \(\mathbf{x}^{(1)}\) es de la forma \(\mathbf{x}^{(1)}=\mathbf{x}^{(0)}+t_1\mathbf{v}^{(1)}\), donde \(t_1 =\frac{(\mathbf{v}^{(1)})^\top (b-\mathbf{A}\mathbf{x}^{(0)})}{(\mathbf{v}^{(1)})^\top (\mathbf{A}\mathbf{v}^{(1)})}=\frac{(\mathbf{v}^{(1)})^\top \mathbf{r}^{(0)}}{(\mathbf{v}^{(1)})^\top (\mathbf{A}\mathbf{v}^{(1)})}\).

  • Seguidamente tenemos que hallar \(\mathbf{x}^{(2)}=\mathbf{x}^{(1)}+t_2\mathbf{v}^{(2)}\).

    • Escribimos \(\mathbf{v}^{(2)}\) de la forma: \(\mathbf{v}^{(2)}=\mathbf{r}^{(1)}+s_1\mathbf{v}^{(1)}\).
    • Como \(\mathbf{v}^{(1)}\) y \(\mathbf{v}^{(2)}\) son \(\mathbf{A}\)-ortogonales, \[ {\mathbf{v}^{(1)}}^\top \mathbf{A}\mathbf{v}^{(2)}=0,\ \Rightarrow {\mathbf{v}^{(1)}}^\top \mathbf{A}\mathbf{r}^{(1)}+s_1{\mathbf{v}^{(1)}}^\top \mathbf{A}\mathbf{v}^{(1)}=0, \] de donde deducimos que \(s_1=-\frac{{\mathbf{v}^{(1)}}^\top \mathbf{A}\mathbf{r}^{(1)}}{{\mathbf{v}^{(1)}}^\top \mathbf{A}\mathbf{v}^{(1)}}.\)

Algoritmo del gradiente conjugado

    • El siguiente paso es hallar \(t_2\): \[ \begin{align*} t_2 & =\frac{(\mathbf{v}^{(2)})^\top \mathbf{r}^{(1)}}{(\mathbf{v}^{(2)})^\top (\mathbf{A}\mathbf{v}^{(2)})}=\frac{(\mathbf{r}^{(1)}+s_1\mathbf{v}^{(1)})^\top \mathbf{r}^{(1)}}{(\mathbf{v}^{(2)})^\top (\mathbf{A}\mathbf{v}^{(2)})} ,\\ & = \frac{(\mathbf{r}^{(1)})^\top \mathbf{r}^{(1)}}{(\mathbf{v}^{(2)})^\top (\mathbf{A}\mathbf{v}^{(2)})}+s_1 \frac{(\mathbf{v}^{(1)})^\top \mathbf{r}^{(1)}}{(\mathbf{v}^{(2)})^\top (\mathbf{A}\mathbf{v}^{(2)})} \end{align*} \]
    • Por último tenemos la aproximación \(\mathbf{x}^{(2)}=\mathbf{x}^{(1)}+t_2\mathbf{v}^{(2)}\).

Algoritmo del gradiente conjugado

  • En general, supongamos que hemos hallado las aproximaciones \(\mathbf{x}^{(0)},\mathbf{x}^{(1)},\ldots,\mathbf{x}^{(k-1)}\) con direcciones conjugadas \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(k-1)}\) que suponemos \(\mathbf{A}\)-ortogonales, es decir \((\mathbf{v}^{(i)})^\top \mathbf{A}\mathbf{v}^{(j)}=0\), para \(i,j=1,\ldots,k-1\) con \(i\neq j\).
    • La nueva aproximación \(\mathbf{x}^{(k)}\) se escribe de la forma: \(\mathbf{x}^{(k)}=\mathbf{x}^{(k-1)}+t_k\mathbf{v}^{(k)}\).

Algoritmo del gradiente conjugado

    • Escribimos la nueva dirección conjugada \(\mathbf{v}^{(k)}\) como \(\mathbf{v}^{(k)}=\mathbf{r}^{(k-1)}+s_{k-1}\mathbf{v}^{(k-1)}\). Como \(\mathbf{v}^{(k)}\) y \(\mathbf{v}^{(k-1)}\) son \(\mathbf{A}\)-ortogonales, tenemos que: \[ {\mathbf{v}^{(k-1)}}^\top \mathbf{A}\mathbf{v}^{(k)}=0,\ \Rightarrow {\mathbf{v}^{(k-1)}}^\top \mathbf{A}\mathbf{r}^{(k-1)}+s_{k-1}{\mathbf{v}^{(k-1)}}^\top \mathbf{A}\mathbf{v}^{(k-1)}=0, \] de donde deducimos que \(s_{k-1}=-\frac{{\mathbf{v}^{(k-1)}}^\top \mathbf{A}\mathbf{r}^{(k-1)}}{{\mathbf{v}^{(k-1)}}^\top \mathbf{A}\mathbf{v}^{(k-1)}}.\)

Se puede demostrar usando técnicas avanzadas de álgebra lineal que \((\mathbf{v}^{(i)})^\top \mathbf{A}\mathbf{v}^{(k)}=0\), para \(i=1,\ldots,k-2\). Por tanto, los vectores \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(k)}\) serán \(A\)-ortogonales.

Algoritmo del gradiente conjugado

    • El siguiente paso es hallar \(t_k\): \[ \begin{align*} t_k & =\frac{(\mathbf{v}^{(k)})^\top \mathbf{r}^{(k-1)}}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})}=\frac{(\mathbf{r}^{(k-1)}+s_{k-1}\mathbf{v}^{(k-1)})^\top \mathbf{r}^{(k-1)}}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})} ,\\ & = \frac{(\mathbf{r}^{(k-1)})^\top \mathbf{r}^{(k-1)}}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})}+s_{k-1} \frac{(\mathbf{v}^{(k-1)})^\top \mathbf{r}^{(k-1)}}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})}=\frac{(\mathbf{r}^{(k-1)})^\top \mathbf{r}^{(k-1)}}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})}. \end{align*} \] En la última igualdad hemos usado la proposición anterior que asegura que \((\mathbf{r}^{(k-1)})^\top \mathbf{v}^{(k-1)}=0\).
    • Por último tenemos la aproximación \(\mathbf{x}^{(k)}=\mathbf{x}^{(k-1)}+t_k\mathbf{v}^{(k)}\).

Algoritmo del gradiente conjugado

Observación.

Los residuos \(\mathbf{r}^{(k)}\) cumplen la expresión siguiente: \[ \begin{align*} \mathbf{r}^{(k)} & =\mathbf{b}-\mathbf{A}\mathbf{x}^{(k)}=\mathbf{b}-\mathbf{A}(\mathbf{x}^{(k-1)}+t_k\mathbf{v}^{(k)})=\mathbf{b}-\mathbf{A}\mathbf{x}^{(k-1)}-t_k\mathbf{A}\mathbf{v}^{(k)}\\ & =\mathbf{r}^{(k-1)}-t_k\mathbf{A}\mathbf{v}^{(k)} \end{align*} \] A partir de la expresión anterior, tenemos que: \[ (\mathbf{r}^{(k)})^\top \mathbf{r}^{(k)}=(\mathbf{r}^{(k)})^\top \mathbf{r}^{(k-1)}-t_k(\mathbf{r}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})=-t_k (\mathbf{r}^{(k)})^\top \mathbf{A}\mathbf{v}^{(k)}. \] Además, a partir de la definición de \(t_k\), tenemos que: \[ (\mathbf{v}^{(k)})^\top \mathbf{A}{\mathbf{v}^{(k)}}=\frac{1}{t_{k}}(\mathbf{v}^{(k)})^\top \mathbf{r}^{(k-1)}. \]

Algoritmo del gradiente conjugado

Observación (continuación).

Por último, podemos simplificar el valor de \(s_{k}\) de la forma siguiente: \[ \begin{align*} s_{k} & =-\frac{(\mathbf{v}^{(k)})^\top \mathbf{A}\mathbf{r}^{(k)}}{{\mathbf{v}^{(k)}}^\top \mathbf{A}\mathbf{v}^{(k)}}=-\frac{(\mathbf{r}^{(k)})^\top \mathbf{A}\mathbf{v}^{(k)}}{{\mathbf{v}^{(k)}}^\top \mathbf{A}\mathbf{v}^{(k)}}= \frac{\frac{1}{t_{k}}(\mathbf{r}^{(k)})^\top \mathbf{r}^{(k)}}{\frac{1}{t_{k}}(\mathbf{v}^{(k)})^\top \mathbf{r}^{(k-1)}}\\ &= \frac{(\mathbf{r}^{(k)})^\top \mathbf{r}^{(k)}}{(\mathbf{r}^{(k-1)})^\top \mathbf{v}^{(k)}}= \frac{(\mathbf{r}^{(k)})^\top \mathbf{r}^{(k)}}{(\mathbf{r}^{(k-1)})^\top (\mathbf{r}^{(k-1)}+s_{k-1}\mathbf{v}^{(k-1)})}\\ & =\frac{(\mathbf{r}^{(k)})^\top \mathbf{r}^{(k)}}{(\mathbf{r}^{(k-1)})^\top \mathbf{r}^{(k-1)}+s_{k-1}(\mathbf{r}^{(k-1)})^\top \mathbf{v}^{(k-1)}}=\frac{(\mathbf{r}^{(k)})^\top \mathbf{r}^{(k)}}{(\mathbf{r}^{(k-1)})^\top \mathbf{r}^{(k-1)}}. \end{align*} \] En la última igualdad hemos usado la proposición anterior que asegura que \((\mathbf{r}^{(k-1)})^\top \mathbf{v}^{(k-1)}=0\).

Algoritmo del gradiente conjugado

En resumen, el algoritmo del gradiente conjugado se compone de los pasos siguientes:

  • Paso \(0\): empezamos con una aproximación inicial \(\mathbf{x}^{(0)}\) y un residuo inicial \(\mathbf{r}^{(0)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)}\).
  • Paso \(1\): consideramos como dirección inicial \(\mathbf{v}^{(1)}\), \(\mathbf{v}^{(1)}=\mathbf{r}^{(0)}\).
    • Calculamos \(\mathbf{x}^{(1)}=\mathbf{x}^{(0)}+t_1\mathbf{v}^{(1)}\), con \(t_1=\frac{(\mathbf{r}^{(0)})^\top \mathbf{r}^{(0)}}{(\mathbf{v}^{(1)})^\top (\mathbf{A}\mathbf{v}^{(1)})}.\)
  • \(\cdots\)

Algoritmo del gradiente conjugado

  • Paso \(k\): suponemos calculadas las aproximaciones \(\mathbf{x}^{(0)},\ldots,\mathbf{x}^{(k-1)}\), los residuos \(\mathbf{r}^{(0)},\ldots,\mathbf{r}^{(k-1)}\) y las direcciones \(\mathbf{v}^{(1)},\ldots,\mathbf{v}^{(k-1)}\).
    • Calculamos \(\mathbf{v}^{(k)}\): \(\mathbf{v}^{(k)}=\mathbf{r}^{(k-1)}+s_{k-1}\mathbf{v}^{(k-1)}\), con \(s_{k-1}=\frac{(\mathbf{r}^{(k-1)})^\top \mathbf{r}^{(k-1)}}{(\mathbf{r}^{(k-2)})^\top \mathbf{r}^{(k-2)}}.\)
    • Calculamos \(\mathbf{x}^{(k)}=\mathbf{x}^{(k-1)}+t_k\mathbf{v}^{(k)}\), con \(t_k=\frac{(\mathbf{r}^{(k-1)})^\top \mathbf{r}^{(k-1)}}{(\mathbf{v}^{(k)})^\top (\mathbf{A}\mathbf{v}^{(k)})}.\)

hasta llegar al paso \(k=n\) donde \(\mathbf{x}^{(n)}\) es la solución del sistema \(\mathbf{A}\mathbf{x}=\mathbf{b}\).

Pseudocódigo del gradiente conjugado

  • INPUT matriz del sistema \(\mathbf{A}=(a_{ij})_{i=1,\ldots,n,j=1,\ldots,n}\), vector de términos independientes \(\mathbf{b}=(b_i)_{i=1,\ldots,n}\), valor inicial \(\mathbf{x}=\mathbf{x}^{(0)}\).

  • Set \(\mathbf{r}=\mathbf{b}-\mathbf{A}\mathbf{x}\). (Calculamos \(\mathbf{r}^{(0)}\))

  • Set \(\mathbf{v}=\mathbf{r}\). (Calculamos \(\mathbf{v}^{(1)}\))

  • Set \(t=\frac{\mathbf{r}^\top \mathbf{r}}{\mathbf{v}^\top \mathbf{A}\mathbf{v}}\). (Calculamos \(t_1\))

  • Set \(\mathbf{x}=\mathbf{x}+t\mathbf{v}\). (Calculamos \(\mathbf{x}^{(1)}\))

  • Set \(\mathbf{r}_1=\mathbf{b}-\mathbf{A}\mathbf{x}\). (Calculamos \(\mathbf{r}^{(1)}\))

Pseudocódigo del gradiente conjugado

  • For k=2,...,n
    • Set \(s=\frac{(\mathbf{r}_{1})^\top \mathbf{r}_{1}}{\mathbf{r}^\top \mathbf{r}}\). (Calculamos \(s_{k-1}\))
    • Set \(\mathbf{v}=\mathbf{r}_1+s\mathbf{v}\). (Calculamos \(\mathbf{v}^{(k)}\))
    • Set \(t=\frac{(\mathbf{r}_{1})^\top \mathbf{r}_{1}}{\mathbf{v}^\top \mathbf{A}\mathbf{v}}\). (Calculamos \(t_k\))
    • Set \(\mathbf{x}=\mathbf{x}+t\mathbf{v}\). (Calculamos \(\mathbf{x}^{(k)}\))
    • Set \(\mathbf{r}=\mathbf{r}_1\). (Actualizamos \(\mathbf{r}^{(k-1)}\) para el cálculo de \(s_{k-1}\) en la próxima iteración)
    • Set \(\mathbf{r}_{1}=\mathbf{b}-\mathbf{A}\mathbf{x}\). (Calculamos \(\mathbf{r}^{(k)}\))
  • Print \(\mathbf{x}\) (Solución del sistema \(\mathbf{A}\mathbf{x}=\mathbf{b}\))

Ejemplo

Consideremos el siguiente sistema de ecuaciones de \(5\) ecuaciones con \(5\) incógnitas: \[ \begin{align*} E_1: & 5.4x_1 & +5 x_2 & +4.4 x_3 & +5 x_4 & +3.4 x_5 & = 1,\\ E_2: & 5x_1 & +6 x_2 & +3 x_3 & +4.8 x_4 & +2.6 x_5 & = 2,\\ E_3: & 4.4x_1 & +3 x_2 & +4.8 x_3& +4.6 x_4 & +4 x_5 & = 3,\\ E_4: & 5x_1 & +4.8 x_2 & +4.6 x_3 & +6 x_4 & +4.6 x_5 & = 4, \\ E_5: & 3.4x_1 & +2.6 x_2 & +4 x_3 & +4.6 x_4 & +4.2 x_5 & = 5. \end{align*} \] Vamos a resolverlo usando el método del gradiente conjugado.

Ejemplo (continuación)

  • Paso \(0\): consideramos \(\mathbf{x}^{(0)}=\begin{bmatrix}0 \\0 \\0 \\0 \\0 \\\end{bmatrix}\). El residuo inicial \(\mathbf{r}^{(0)}\) será: \[ \mathbf{r}^{(0)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(0)}=\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}-\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix}\cdot\begin{bmatrix}0 \\0 \\0 \\0 \\0 \\\end{bmatrix}=\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}. \]

Ejemplo (continuación)

  • Paso \(1\): la dirección inicial \(\mathbf{v}^{(1)}\) será \(\mathbf{v}^{(1)}=\mathbf{r}^{(0)}=\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}\). A continuación calculamos: \[ t_1 = \frac{(\mathbf{r}^{(0)})^\top \mathbf{r}^{(0)}}{(\mathbf{v}^{(1)})^\top (\mathbf{A}\mathbf{v}^{(1)})}=\frac{\begin{bmatrix}1&2&3&4&5 \\\end{bmatrix} \begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}}{\begin{bmatrix}1&2&3&4&5 \\\end{bmatrix}\left(\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix}\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}\right)}=\frac{55}{973.2}=0.056515. \]

Ejemplo (continuación)

La aproximación \(\mathbf{x}^{(1)}\) será: \[ \mathbf{x}^{(1)}=\mathbf{x}^{(0)}+t_1\mathbf{v}^{(1)}=\begin{bmatrix}0 \\0 \\0 \\0 \\0 \\\end{bmatrix}+0.0565\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix} =\begin{bmatrix}0.056515 \\0.113029 \\0.169544 \\0.226058 \\0.282573 \\\end{bmatrix}. \]

  • Paso \(2\): la dirección \(\mathbf{v}^{(2)}\) será \(\mathbf{v}^{(2)}=\mathbf{r}^{(1)}+s_1\mathbf{v}^{(1)}\). Calculemos previamente el valor de \(\mathbf{r}^{(1)}\): \[ \mathbf{r}^{(1)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(1)}=\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}-\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix} \begin{bmatrix}0.056515 \\0.113029 \\0.169544 \\0.226058 \\0.282573 \\\end{bmatrix}=\begin{bmatrix}-2.707357 \\-1.289149 \\-0.571722 \\-0.2612 \\1.609125 \\\end{bmatrix}. \]

Ejemplo (continuación)

El valor de \(s_1\) vale: \[ s_1=\frac{(\mathbf{r}^{(1)})^\top \mathbf{r}^{(1)}}{(\mathbf{r}^{(0)})^\top \mathbf{r}^{(0)}}=\frac{\begin{bmatrix}-2.7074&-1.2891&-0.5717&-0.2612&1.6091 \\\end{bmatrix} \begin{bmatrix}-2.7074 \\-1.2891 \\-0.5717 \\-0.2612 \\1.6091 \\\end{bmatrix}}{\begin{bmatrix}1&2&3&4&5 \\\end{bmatrix} \begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}}=0.217747 \]

Ejemplo (continuación)

El valor de \(\mathbf{v}^{(2)}\) vale: \[ \mathbf{v}^{(2)}=\mathbf{r}^{(1)}+s_1\mathbf{v}^{(1)}=\begin{bmatrix}-2.707357 \\-1.289149 \\-0.571722 \\-0.2612 \\1.609125 \\\end{bmatrix}+0.217747\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}=\begin{bmatrix}-2.489611 \\-0.853656 \\0.081518 \\0.609786 \\2.697857 \\\end{bmatrix}. \]

Ejemplo (continuación)

A continuación calculamos: \[ \begin{align*} t_2 & = \frac{(\mathbf{r}^{(1)})^\top \mathbf{r}^{(1)}}{(\mathbf{v}^{(2)})^\top (\mathbf{A}\mathbf{v}^{(2)})}\\ & =\frac{\begin{bmatrix}-2.707357&-1.289149&-0.571722&-0.2612&1.609125 \\\end{bmatrix} \begin{bmatrix}-2.707357 \\-1.289149 \\-0.571722 \\-0.2612 \\1.609125 \\\end{bmatrix}}{\begin{bmatrix}-2.489611&-0.853656&0.081518&0.609786&2.697857 \\\end{bmatrix}\left(\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix}\begin{bmatrix}-2.489611 \\-0.853656 \\0.081518 \\0.609786 \\2.697857 \\\end{bmatrix}\right)}\\ & =0.40946. \end{align*} \]

Ejemplo (continuación)

Por último el valor de \(\mathbf{x}^{(2)}\) será: \[ \mathbf{x}^{(2)}=\mathbf{x}^{(1)}+t_2\mathbf{v}^{(2)}=\begin{bmatrix}0.056515 \\0.113029 \\0.169544 \\0.226058 \\0.282573 \\\end{bmatrix}+0.40946\begin{bmatrix}-2.489611 \\-0.853656 \\0.081518 \\0.609786 \\2.697857 \\\end{bmatrix}=\begin{bmatrix}-0.96288 \\-0.236508 \\0.202922 \\0.475741 \\1.387237 \\\end{bmatrix}. \]

  • Paso \(3\): la dirección \(\mathbf{v}^{(3)}\) será \(\mathbf{v}^{(3)}=\mathbf{r}^{(2)}+s_2\mathbf{v}^{(2)}\). Calculemos previamente el valor de \(\mathbf{r}^{(2)}\): \[ \mathbf{r}^{(2)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(2)}=\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}-\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix} \begin{bmatrix}-0.96288 \\-0.236508 \\0.202922 \\0.475741 \\1.387237 \\\end{bmatrix}=\begin{bmatrix}-0.60607 \\1.734314 \\-0.765182 \\-0.219534 \\0.062225 \\\end{bmatrix}. \]

Ejemplo (continuación)

El valor de \(s_2\) vale: \[ s_2=\frac{(\mathbf{r}^{(2)})^\top \mathbf{r}^{(2)}}{(\mathbf{r}^{(1)})^\top \mathbf{r}^{(1)}}=\frac{\begin{bmatrix}-0.60607&1.734314&-0.765182&-0.219534&0.062225 \\\end{bmatrix} \begin{bmatrix}-0.60607 \\1.734314 \\-0.765182 \\-0.219534 \\0.062225 \\\end{bmatrix}}{\begin{bmatrix}-2.707357&-1.289149&-0.571722&-0.2612&1.609125 \\\end{bmatrix} \begin{bmatrix}-2.707357 \\-1.289149 \\-0.571722 \\-0.2612 \\1.609125 \\\end{bmatrix}}=0.335063 \]

Ejemplo (continuación)

El valor de \(\mathbf{v}^{(3)}\) vale: \[ \mathbf{v}^{(3)}=\mathbf{r}^{(2)}+s_2\mathbf{v}^{(2)}=\begin{bmatrix}-0.60607 \\1.734314 \\-0.765182 \\-0.219534 \\0.062225 \\\end{bmatrix}+0.335063\begin{bmatrix}-2.489611 \\-0.853656 \\0.081518 \\0.609786 \\2.697857 \\\end{bmatrix}=\begin{bmatrix}-1.440247 \\1.448285 \\-0.737868 \\-0.015217 \\0.966177 \\\end{bmatrix}. \]

Ejemplo (continuación)

A continuación calculamos: \[ \begin{align*} t_3 & = \frac{(\mathbf{r}^{(2)})^\top \mathbf{r}^{(2)}}{(\mathbf{v}^{(3)})^\top (\mathbf{A}\mathbf{v}^{(3)})}\\ & =\frac{\begin{bmatrix}-0.60607&1.734314&-0.765182&-0.219534&0.062225 \\\end{bmatrix} \begin{bmatrix}-0.60607 \\1.734314 \\-0.765182 \\-0.219534 \\0.062225 \\\end{bmatrix}}{\begin{bmatrix}-1.440247&1.448285&-0.737868&-0.015217&0.966177 \\\end{bmatrix}\left(\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix}\begin{bmatrix}-1.440247 \\1.448285 \\-0.737868 \\-0.015217 \\0.966177 \\\end{bmatrix}\right)}\\ & =0.893845. \end{align*} \]

Ejemplo (continuación)

Por último el valor de \(\mathbf{x}^{(3)}\) será: \[ \mathbf{x}^{(3)}=\mathbf{x}^{(2)}+t_3\mathbf{v}^{(3)}=\begin{bmatrix}-0.96288 \\-0.236508 \\0.202922 \\0.475741 \\1.387237 \\\end{bmatrix}+0.893845\begin{bmatrix}-1.440247 \\1.448285 \\-0.737868 \\-0.015217 \\0.966177 \\\end{bmatrix}=\begin{bmatrix}-2.250239 \\1.058035 \\-0.456618 \\0.46214 \\2.25085 \\\end{bmatrix}. \]

  • Paso \(4\): la dirección \(\mathbf{v}^{(4)}\) será \(\mathbf{v}^{(4)}=\mathbf{r}^{(3)}+s_3\mathbf{v}^{(3)}\). Calculemos previamente el valor de \(\mathbf{r}^{(3)}\): \[ \mathbf{r}^{(3)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(3)}=\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}-\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix} \begin{bmatrix}-2.250239 \\1.058035 \\-0.456618 \\0.46214 \\2.25085 \\\end{bmatrix}=\begin{bmatrix}-0.093352 \\0.20236 \\0.789473 \\-0.853676 \\0.146983 \\\end{bmatrix}. \]

Ejemplo (continuación)

El valor de \(s_3\) vale: \[ s_3=\frac{(\mathbf{r}^{(3)})^\top \mathbf{r}^{(3)}}{(\mathbf{r}^{(2)})^\top \mathbf{r}^{(2)}}=\frac{\begin{bmatrix}-0.093352&0.20236&0.789473&-0.853676&0.146983 \\\end{bmatrix} \begin{bmatrix}-0.093352 \\0.20236 \\0.789473 \\-0.853676 \\0.146983 \\\end{bmatrix}}{\begin{bmatrix}-0.60607&1.734314&-0.765182&-0.219534&0.062225 \\\end{bmatrix} \begin{bmatrix}-0.60607 \\1.734314 \\-0.765182 \\-0.219534 \\0.062225 \\\end{bmatrix}}=0.354695 \]

Ejemplo (continuación)

El valor de \(\mathbf{v}^{(4)}\) vale: \[ \mathbf{v}^{(4)}=\mathbf{r}^{(3)}+s_3\mathbf{v}^{(3)}=\begin{bmatrix}-0.093352 \\0.20236 \\0.789473 \\-0.853676 \\0.146983 \\\end{bmatrix}+0.354695\begin{bmatrix}-1.440247 \\1.448285 \\-0.737868 \\-0.015217 \\0.966177 \\\end{bmatrix}=\begin{bmatrix}-0.6042 \\0.71606 \\0.527754 \\-0.859073 \\0.489681 \\\end{bmatrix}. \]

Ejemplo (continuación)

A continuación calculamos: \[ \begin{align*} t_4 & = \frac{(\mathbf{r}^{(3)})^\top \mathbf{r}^{(3)}}{(\mathbf{v}^{(4)})^\top (\mathbf{A}\mathbf{v}^{(4)})}\\ & =\frac{\begin{bmatrix}-0.093352&0.20236&0.789473&-0.853676&0.146983 \\\end{bmatrix} \begin{bmatrix}-0.093352 \\0.20236 \\0.789473 \\-0.853676 \\0.146983 \\\end{bmatrix}}{\begin{bmatrix}-0.6042&0.71606&0.527754&-0.859073&0.489681 \\\end{bmatrix}\left(\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix}\begin{bmatrix}-0.6042 \\0.71606 \\0.527754 \\-0.859073 \\0.489681 \\\end{bmatrix}\right)}\\ & =18.366386. \end{align*} \]

Ejemplo (continuación)

Por último el valor de \(\mathbf{x}^{(4)}\) será: \[ \mathbf{x}^{(4)}=\mathbf{x}^{(3)}+t_4\mathbf{v}^{(4)}=\begin{bmatrix}-2.250239 \\1.058035 \\-0.456618 \\0.46214 \\2.25085 \\\end{bmatrix}+18.366386\begin{bmatrix}-0.6042 \\0.71606 \\0.527754 \\-0.859073 \\0.489681 \\\end{bmatrix}=\begin{bmatrix}-13.34721 \\14.20946 \\9.236323 \\-15.315927 \\11.244528 \\\end{bmatrix}. \]

  • Paso \(5\) y último: la dirección \(\mathbf{v}^{(5)}\) será \(\mathbf{v}^{(5)}=\mathbf{r}^{(4)}+s_4\mathbf{v}^{(4)}\). Calculemos previamente el valor de \(\mathbf{r}^{(4)}\): \[ \mathbf{r}^{(4)}=\mathbf{b}-\mathbf{A}\mathbf{x}^{(4)}=\begin{bmatrix}1 \\2 \\3 \\4 \\5 \\\end{bmatrix}-\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix} \begin{bmatrix}-13.34721 \\14.20946 \\9.236323 \\-15.315927 \\11.244528 \\\end{bmatrix}=\begin{bmatrix}-0.263948 \\0.050997 \\0.240146 \\0.214289 \\-0.283128 \\\end{bmatrix}. \]

Ejemplo (continuación)

El valor de \(s_4\) vale: \[ s_4=\frac{(\mathbf{r}^{(4)})^\top \mathbf{r}^{(4)}}{(\mathbf{r}^{(3)})^\top \mathbf{r}^{(3)}}=\frac{\begin{bmatrix}-0.263948&0.050997&0.240146&0.214289&-0.283128 \\\end{bmatrix} \begin{bmatrix}-0.263948 \\0.050997 \\0.240146 \\0.214289 \\-0.283128 \\\end{bmatrix}}{\begin{bmatrix}-0.093352&0.20236&0.789473&-0.853676&0.146983 \\\end{bmatrix} \begin{bmatrix}-0.093352 \\0.20236 \\0.789473 \\-0.853676 \\0.146983 \\\end{bmatrix}}=0.179878 \]

Ejemplo (continuación)

El valor de \(\mathbf{v}^{(5)}\) vale: \[ \mathbf{v}^{(5)}=\mathbf{r}^{(4)}+s_4\mathbf{v}^{(4)}=\begin{bmatrix}-0.263948 \\0.050997 \\0.240146 \\0.214289 \\-0.283128 \\\end{bmatrix}+0.179878\begin{bmatrix}-0.6042 \\0.71606 \\0.527754 \\-0.859073 \\0.489681 \\\end{bmatrix}=\begin{bmatrix}-0.37263 \\0.179801 \\0.335077 \\0.05976 \\-0.195045 \\\end{bmatrix}. \]

Ejemplo (continuación)

A continuación calculamos: \[ \begin{align*} t_5 & = \frac{(\mathbf{r}^{(4)})^\top \mathbf{r}^{(4)}}{(\mathbf{v}^{(5)})^\top (\mathbf{A}\mathbf{v}^{(5)})}\\ & =\frac{\begin{bmatrix}-0.263948&0.050997&0.240146&0.214289&-0.283128 \\\end{bmatrix} \begin{bmatrix}-0.263948 \\0.050997 \\0.240146 \\0.214289 \\-0.283128 \\\end{bmatrix}}{\begin{bmatrix}-0.37263&0.179801&0.335077&0.05976&-0.195045 \\\end{bmatrix}\left(\begin{bmatrix}5.4&5&4.4&5&3.4 \\5&6&3&4.8&2.6 \\4.4&3&4.8&4.6&4 \\5&4.8&4.6&6&4.6 \\3.4&2.6&4&4.6&4.2 \\\end{bmatrix}\begin{bmatrix}-0.37263 \\0.179801 \\0.335077 \\0.05976 \\-0.195045 \\\end{bmatrix}\right)}\\ & =82.260682. \end{align*} \]

Ejemplo (continuación)

Por último el valor de \(\mathbf{x}^{(5)}\) y solución del sistema \(\mathbf{A}\mathbf{x}=\mathbf{b}\) será: \[ \mathbf{x}^{(5)}=\mathbf{x}^{(4)}+t_5\mathbf{v}^{(5)}=\begin{bmatrix}-13.34721 \\14.20946 \\9.236323 \\-15.315927 \\11.244528 \\\end{bmatrix}+82.260682\begin{bmatrix}-0.37263 \\0.179801 \\0.335077 \\0.05976 \\-0.195045 \\\end{bmatrix}=\begin{bmatrix}-44 \\29 \\36.8 \\-10.4 \\-4.8 \\\end{bmatrix}. \]

El método del gradiente conjugado se puede encontrar implementado en: