I want to compute the Jacobian of a function in Matlab

Click For Summary
SUMMARY

The discussion focuses on numerically computing the Jacobian of a function in MATLAB using a custom function defined as 'd(f,j)'. The user implements a finite difference method to approximate the Jacobian matrix, but expresses uncertainty about the accuracy of the results. The provided code snippet demonstrates the calculation of the Jacobian matrix 'J' using a small perturbation 'dd'. Suggestions for improvement or alternative methods are sought from the community.

PREREQUISITES
  • Understanding of MATLAB programming and syntax
  • Familiarity with numerical differentiation techniques
  • Knowledge of Jacobian matrices and their significance in multivariable calculus
  • Experience with function handles and array operations in MATLAB
NEXT STEPS
  • Research "MATLAB numerical differentiation techniques" for alternative methods
  • Explore "MATLAB symbolic toolbox" for symbolic Jacobian computation
  • Learn about "finite difference methods" for improved accuracy
  • Investigate "MATLAB function handles" for more efficient function evaluations
USEFUL FOR

Mathematics students, engineers, and researchers who need to compute Jacobians for multivariable functions in MATLAB, as well as developers looking to enhance their numerical analysis skills.

hunt_mat
Homework Helper
Messages
1,816
Reaction score
33
Hi,

I have a function of the form:
function r=d(f,j)
if (j==1)
r=3*f(1)+f(3)*f(2)-3;
elseif(j==2)
r=f(1)+2*f(2)-4;
else
r=f(1)*f(2)*f(3)-1;
end

and I would like to be able to numerically compute the Jacobian for such a function. I have a method of computing the Jacobian but I am not convinced that it is giving the right answer though.

for i=1:3
for j=1:3
T=zeros(3,1);
T(j)=dd;
J(i,j)=(d(f+T,i)-d(f,i))/dd; %This is the jacobian
end
end

Does anyone have anything better?
 
  • Like
Likes   Reactions: tutordelhi

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
2
Views
1K
  • · Replies 41 ·
2
Replies
41
Views
10K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K