MAS2008 Scientific Computing: Lab 2 Solutions

Task 1: Row sum norm and condition numbers

This was part of the online test on Moodle and you should go there to see the solutions. The solutions there include the Hilbert matrix even though that was not part of the test. The instructions asked you to comment on Wikipedia's definition of the Hilbert matrix. Our definition has $1/(i+j+1)$ in position $(i,j)$, whereas Wikipedia has $1/(i+j-1)$. The difference just that Wikipedia numbers the rows and columns from $1$ to $n$, whereas we number them from $0$ to $n-1$. For us, the top left corner has $i=j=0$ so the entry is $1/(0+0+1)=1$. For Wikipedia, the top left corner has $i=j=1$ so the entry is $1/(1+1-1)=1$, which is the same.

Task 2: Onion matrices

This was part of the online test on Moodle and you should go there to see the solutions (which give several alternative approaches).

Task 3: Moving average

This was part of the online test on Moodle and you should go there to see the solutions. The solutions define a function a_basic(n, k) which is easy to understand but not super-efficient, and another function a(n, k) which is better but less obvious.

Task 4: Matrix exponentials

See this notebook:
       
Matrix exponentials View Download