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 ExchangeParallel for-Loops (parfor) についてさらに検索

質問済み:

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