Coding the Jacobian efficiently in MATLAB

2 views (last 30 days)
How the Jacobian of F(t,u)= Au - u/1+u be computed in MATLAB? A is a square matrix. How best to compute the Jacobian in Exponential Rosenbrock integrator?
function Jn = J(u)
Jn = -A-1./(1+u).^2;
end

Accepted Answer

Matt J
Matt J on 14 May 2024
Edited: Matt J on 14 May 2024
minusA = -A;
J=@(u) JacobianEngine(u,minusA);
function Jn = JacobianEngine(u,Jn)
p=numel(u);
Jn(1:p+1:end)= Jn(1:p+1:end) + (-1./(1+u).^2);
end

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!