{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "8.2.2 Gauss-Jordan with Appended System" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Copy this notebook first! At each step, if you make a mistake, rerun all the cells above the current cell!!!\n", "\n", "
\n", "\n", "With this notebook, we walk you through both Homework 8.2.1.1 and Homework 8.2.2.1. Let's start with the first step in Homework 8.2.1.1:\n", "\n", " \n", "\n", "Let's set this up as an appended matrix and the application of a Gauss transform. Here matrix $ A $ holds the appended system\n", "$ \n", "\\left( \\begin{array}{ r r r | r }\n", "-2 & 2 & -5 & -7 \\\\\n", "2 & -3 & 7 & 11 \\\\\n", "-4 & 3 & -7 & -9\n", "\\end{array} \\right)\n", "$\n", "Now, fill in the ? in $ G_0 $ with appropriate values to introduce zeroes in the off-diagonal elements of the first column of $ A $:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import numpy as np\n", "\n", "A = np.matrix( '-2, 2, -5, -7;\\\n", " 2, -3, 7, 11;\\\n", " -4, 3, -7, -9' )\n", "\n", "print( 'A = ' )\n", "print( A )\n", "\n", "G0 = np.matrix( ' 1, 0, 0;\\\n", " 1, 1, 0;\\\n", " -2, 0, 1' );\n", "\n", "A0 = G0 * A\n", "\n", "print( 'A0 = ' )\n", "print( A0 )" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you did this right, the result matrix $ A_0 = G_0 A $ has zeroes in the off-diagonal entries of the first column, which then corresponds to the below answer to the first step in Homework 8.2.2.1:\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This also answers the question for Step 1 in Homework 8.2.1.1.\n", "\n", "Now, let's look at the next step in Homework 8.2.1.1:\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The appended system is now represented by A0 :" ] }, { "cell_type": "code", "collapsed": false, "input": [ "print( 'A0 =' )\n", "print( A0 )" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, fill in the ? in $ G_1 $ with appropriate values to introduce zeroes in the off-diagonal elemental of the second column of $ A_0 $:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "G1 = np.matrix( ' 1, 2, 0;\\\n", " 0, 1, 0;\\\n", " 0, -1, 1' );\n", "\n", "A1 = G1 * A0\n", "\n", "print( 'A1 = ' )\n", "print( A1 )" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you did this right, the result matrix $ A_1 = G_1 A_0 = G_1 G_0 A $ has zeroes in the off-diagonal entries of the first column and the second column, which then corresponds to the below answer to the second step in Homework 8.2.2.1:\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This also answers the question for Step 2 in Homework 8.2.1.1.\n", "\n", "Now, let's look at the third step in Homework 8.2.1.1:\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The appended system is now represented by A1 :" ] }, { "cell_type": "code", "collapsed": false, "input": [ "print( 'A1 =' )\n", "print( A1 )" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, fill in the ? in $ G_2 $ with appropriate values to introduce zeroes in the off-diagonal elemental of the third column of $ A_1 $:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "G2 = np.matrix( ' 1, 0, 1;\\\n", " 0, 1, -2;\\\n", " 0, 0, 1' );\n", "\n", "A2 = G2 * A1\n", "\n", "print( 'A2 = ' )\n", "print( A2 )" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you did this right, the result matrix $ A_2 = G_2 A_1 = G_2 G_1 A_0 = G_2 G_1 G_0 A $ has zeroes in the off-diagonal entries of the first, second, and third column, which then corresponds to the below answer to the third step in Homework 8.2.2.1:\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This also answers the question for Step 3 in Homework 8.2.1.1.\n", "\n", "Now, let's look at the fourth step in Homework 8.2.1.1:\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The appended system is now represented by A2 :" ] }, { "cell_type": "code", "collapsed": false, "input": [ "print( 'A2 =' )\n", "print( A2 )" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, fill in the ? in $ D $ with appropriate values to set the diagonal elements in the appended system to one, making the first three columns into an identity matrix:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "D = np.matrix( '-0.5, 0, 0;\\\n", " 0, -1, 0;\\\n", " 0, 0, 1' );\n", "\n", "A3 = D * A2\n", "\n", "print( 'A3 = ' )\n", "print( A3 )" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you did this right, the result matrix \n", "\n", "$ A_3 = D A_2 = D G_2 A_1 = D G_2 G_1 A_0 = D G_2 G_1 G_0 A $ \n", "\n", "has an identity matrix in the first three columns, which then corresponds to the below answer to the fourth step in Homework 8.2.2.1:\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This also answers the question for Step 4 in Homework 8.2.1.1.\n", "\n", "Now, the answer above is an appended system that represent the system of linear equations\n", "\n", "$ \\begin{array}{c c c c r}\n", "\\chi_0 & & & = & -1 \\\\\n", "& \\chi_1 & & = & -2 \\\\\n", "& & \\chi_2 & = & 1\n", "\\end{array}\n", " $\n", "\n", "which provides the answer to the linear system with which we started:\n", "\n", " \n", "\n", "We can check that we've just done this:\n", "\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "A = np.matrix( '-2, 2, -5;\\\n", " 2, -3, 7;\\\n", " -4, 3, -7' )\n", "\n", "print( 'A = ' )\n", "print( A )\n", "\n", "x = np.matrix( '-1;\\\n", " -2;\\\n", " 1' )\n", "\n", "print( 'x = ' )\n", "print( x )\n", "\n", "print( ' A * x = ' )\n", "print( A * x )" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }