Coding the Jacobian efficiently in MATLAB

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

 채택된 답변

Matt J
Matt J 2024년 5월 14일
편집: Matt J 2024년 5월 14일

0 개 추천

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2024년 5월 14일

편집:

2024년 5월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by