Scientific Computing Using Python - PHYS:4905 - Fall 2018
Homework #6
Due 9/11/2018


Name _______________________________________________

The answers to this homework must be handed in electronically.

1. (10) Write Python code to perform Gaussian elimination on the augmented matrix below using the functions defined in the lecture for the elementary row operations.

(11|272-1|0)\left(\begin{array}{cc|l} 1 & 1 & | \, 27 \\ 2 & -1 & | \, 0 \\ \end{array}\right)

Your code should print out the matrix at the beginning and after each step and also print out what operation is done at each step, see below for a potential format.  At the end, your code should print out the solution in a user-friendly format.

import eros
m = array([[1.0, 1.0, 27],[2, -1, 0]])
print('Initial matrix')
print(m)
print('Doing row_swap between rows 0 and 1.')

m = row_swap(m, 0, 1)
print(m)
...


2. (20) Write a program to do Gaussian elimination on an augmented matrix with two rows.  The program should print out the matrix at the beginning and after each step and also print out what operation is done at each step.  At the end, your code should print out the solution in a user-friendly format.  Run your code on the augmented matrix from problem #1 to check if it works.  Then run your code on the two augmented matrices below.  Include the outputs from your three runs when you hand in this homework.  Note that the algorithm for Gaussian elimination discussed in lecture 5 may prove useful.

(32|724|3)(03|122-1|3)\left(\begin{array}{cc|l} 3 & 2 & | \, 7 \\ 2 & 4 & | \, 3 \\ \end{array}\right) \;\;\;\;\;\;\;\; \left(\begin{array}{cc|l} 0 & 3 & | \, 12 \\ 2 & -1 & | \, 3 \\ \end{array}\right)