Compute Jacobian of a function using Automatic Differentiation

조회 수: 19 (최근 30일)
Evan Scope Crafts
Evan Scope Crafts 2021년 4월 5일
답변: Matt J 2023년 5월 5일
I have a vector valued function,, and would like to compute the jacobian of f using automatic differentiation. To accomplish this, my original idea was to use the deep learning toolbox and the built in 'dlgradient' function. However 'dlgradient' seems to only work with scalar valued functions. Is there a way to use automatic differentiation in Matlab to compute the Jacobian of a vector valued function?

답변 (2개)

Aditya
Aditya 2023년 2월 27일
Hi,
Your observation is correct. You cannot use autodiff from Deep Learning Toolbox to compute Jacobian of a Vector valued function. However, You can use the jacobian from the Symbolic Math Toolbox to calculate the jacobian matrix of a vector valued function.
syms x y z
jacobian([x*y*z,y^2,x + z],[x,y,z])
ans = 
The above example computes the Jacobian Matrix of [x*y*z,y^2,x + z] with respect to [x,y,z].
  댓글 수: 1
Nick
Nick 2023년 5월 5일
I've found that jacobian from the Symblic Math Toolbox does not scale well to larger more complex functions in terms of copmutation time, espeically if I want to generate a function file for the function. I've started using CasADi instead because of this. Do you think there will be any functionality added that will make this possible in MATLAB any time soon?

댓글을 달려면 로그인하십시오.


Matt J
Matt J 2023년 5월 5일

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by