Starting from:

$30

MATH6015 Math Programming Assignment #3

MATH6015
Math Programming Assignment #3

1. [50 points] Solve the linear system
Hx = b
for x ∈ R
N where the elements of H are dened by
hij =
1
i + j − 1
.
Write a function that solves the this linear system for a given vector b.
(a) The function must be named solve_hilbert verbatim.
(b) The function must take one vector, b of length N as input and return a vector, x of length N as
an output that is the solution to the linear system Hx = b.
(c) Use whatever appropriate linear solver you prefer.
2. [50 points] The nite dierence method (FDM) approximation of the Laplacian operation in 1D can be
written as the tridiagonal matrix
A =











2 −1 0 · · · · · · · · · 0
−1 2 −1 0 · · · · · · 0
0 −1 2 −1 0 · · · 0
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
0 · · · 0 −1 2 −1 0
0 · · · · · · 0 −1 2 −1
0 · · · · · · · · · 0 −1 2











.
Solve, using a banded matrix solver, the linear system
Ax = b
for x ∈ R
N where bi = −2/ (N + 1)2
for i = 1, 2, . . . , N.
(a) The function must be named solve_fdm verbatim.
(b) The function must take a single non-negative integer N, which is the system size, as input and
return x as a numpy array of length N as output.
(c) The function must use a banded matrix solver.
MATH6015 Page 1/1

More products