# solve large sparse jacobian matrix (with an example)

9 views (last 30 days)
Marko on 7 Jan 2021
Answered: Doddy Kastanya on 12 Jan 2021
Hello Community,
do you have a good suggestion if an iterative solver would be faster.
This jacobian J with ( N = 32 ) took me around 1s of solving this equation x=J\y. The matrix is saved as sparse, and the density is around 3%.
( For N=64 the density ia about 1,6% and solving that matrix cost me about 50s. So the scaling is really bad)
The Dimensions of this matrix J are scaling with (3*(N+1)^2+(N-1)^2,3*(N+1)^2+(N-1)^2).
my desired N will be in the order of 128- 192.
J. Alex Lee on 8 Jan 2021
maybe you can invoke more specific solvers to specify properties of the matrix, though i'm not too knowledgeable in the area.
another comment which may or may not be relevant is that i wonder if your matrix can be permuted a priori into a structure that's more amenable to solvers (again not terrible knowledgeable in the area...)

Doddy Kastanya on 12 Jan 2021
I assume that the Jacobian matrix is needed as a part of implementing Newton's method to solve system of non-linear equations. For the problem with N=192, the Jacobian matrix size is close to 150k by 150k - So, it might not be advisable to simply use "\" to get the answer - knowing that the matrix is highly sparse. It might be more advantageous to use preconditioned Krylov methods to solve the system of equations. You will have an opportunity to develop an appropriate preconditioner to solve the system of equation faster (by taking advantage of the sparse matrix structure). Another thing that you might want to consider is to implement "Jacobian Free Newton Krylov" method where you don't even have to build the Jacobian matrix (which could be costly as well). I hope this helps. Good luck.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!