Looks like I need to do some work on my solution as the resulting matrix is ill-conditioned unsurprisingly