Nonlinear Differential Equations Using Finite Differences: Can we Use Sparse Matrices?

3 years ago
12

NOTE: WHEN RECORDING THIS, i ACCIDENTALLY FORGOT TO USE THE SPARSE IDENTITY MATRIX IN MATLAB. THE GITHUB CODE HAS BEEN UPDATED AND IS CORRECT. THE 10000-DIMENSIONAL SYSTEM IS NOW SOLVED IN 0.9 SECONDS INSTEAD OF TWO MINUTES!

In answer to a question, we look at using sparse matrices in the solution of boundary value problems. For nonlinear problems, things become more complicated, but we can still use fsolve to solve the underlying system of equations. The issue with Python is the solver cannot handle sparse Jacobian matrices so this limits the utility of this method to small problems. For solvers that can handle sparse Jaboians such as MATLAB’s, we can still get good performance despite having to use a nonlinear solver.

Wikipedia Article on the Jacobian Matrix: https://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant

Github Python Notebook: https://github.com/kpmooney/numerical_methods_youtube/blob/master/bvp/Nonlinear%20BVP.ipynb
Github MATLAB Code: https://github.com/kpmooney/numerical_methods_youtube/blob/master/bvp/Nonlinear.m

Tip Jar: https://paypal.me/kpmooney

Loading comments...