Sie sind auf Seite 1von 1

CL701: Computational Methods in Chemical Engineering

Numerical Jacobian
Course Instructor: Prof. Mani Bhushan (mbhushan@iitb.ac.in)
Course TAs: Om Prakash (prakash.om@iitb.ac.in),
Gaurav Seth (173029001@iitb.ac.in)
August 20, 2019

Aim: To write a function in MATLAB, which can compute the numerical Jacobian matrix for any
vector-valued function.

Consider a function f : Rm → Rn , whose first order partial derivatives exist on Rm . The input
of this function is a point x ∈ Rm , and the output is a vector f (x) ∈ Rn . Then the Jacobian matrix
∂fi
of function f is defined as a n × m matrix, denoted by J, where Ji,j = ∂x j

 ∂f1 ∂f1 ∂f1 


∂x1 ∂x2
. . . ∂xm
 
 ∂f ∂f ∂f2 

 2 2
. . .
 ∂f   1
 ∂x ∂x 2 ∂x m
∂f ∂f
J = ∂x1 ∂x2 . . . ∂xm = 


 .. .. . . .. 
 .
 . . . 
 
∂fn ∂fn ∂fn
∂x1 ∂x2
. . . ∂xm

Do the following:

1. Create a generic function num jacobian, which takes two inputs: (i) The function file, userfunc,
which returns function vector f (x) at a given x. (ii) The point vector, x at which the gradient
is computed. Note that the derivatives in the Jacobian matrix can be computed using the
central difference scheme. Now, you can perturb one component of x at a time in both positive
and negative directions and obtain the corresponding column of the Jacobian matrix.

2. Use the function num jacobian to compute the Jacobian matrix of the following function at
x = {34, 711, 18}.
 1 3x1 4
( ) + x1 ( 7x ) + x1 ( x183 )3
2 3

4 34 711
f (x1 , x2 , x3 ) =  
x1 + cos(x2 )

Learning is fun. Best of Luck!

Das könnte Ihnen auch gefallen