Scientific Computing Using Python - PHYS:4905
Homework #6
Due 9/17/2019
The answers to this homework must be handed in electronically.
You will need to upload one file for each problem containing your
Python code as a text file. Please have the file name start
with your last name, e.g. smith_hw6_1.py.
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.
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.
from eros import *
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. The code that you hand in should be setup so that when
run in Spyder, it does Gaussian elimination on the two matrices
below printing out each step and the solution. Note that the
algorithm for Gaussian elimination may prove useful.