0% found this document useful (0 votes)
2 views2 pages

Computing Assignment 2 2024

The document outlines an assignment for CL 701 Computational Methods for Chemical Engineering, focusing on computing the Jacobian matrix using numerical differentiation. It includes the assignment objectives, programming tasks, and a pseudo-code for implementing the central difference approximation method. The submission deadline is set for September 9, 2024, at 12 pm.

Uploaded by

Amit Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Computing Assignment 2 2024

The document outlines an assignment for CL 701 Computational Methods for Chemical Engineering, focusing on computing the Jacobian matrix using numerical differentiation. It includes the assignment objectives, programming tasks, and a pseudo-code for implementing the central difference approximation method. The submission deadline is set for September 9, 2024, at 12 pm.

Uploaded by

Amit Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CL 701 Computational Methods for Chemical Engineering

Computing Assignment 2: Computing Jacobian Matrix


Submission Deadline: 9 Sept., 2024 (Sunday) 12 pm
Background Information: Consider a normed vector space X Rn and an n 1 function
vector denoted as
T
F(x) = f1 (x) f2 (x) :::: fn (x)
Jacobian matrix of the function vector is de…ned as
2 3
@f1 @f1 @f1
6 @x1 :::::: 7
6 @x2 @xn 7
6 7
@F(x) 6 @f @f2 @f2 7
6 2 :::::: 7
J(x) = =6 7
@x 6 @x1 @x2 @xn 7
6 :::::: :::::: :::::: :::::: 7
6 7
4 @fn @fn @fn 5
::::::
@x1 @x2 @xn x=x
n
where the derivatives are evaluated as x =x 2 R ,i.e.
T
x= x1 x2 ::: xn n 1

and J is n n matrix.
Assignment objective: Given a function vector, F(x); and a point x =x; …nd Jacobian
matrix J(x) using numerical di¤erentiation.
Approximate each derivative numerically using central di¤erence approximation as follows:
@fi (x) fi (x + "j e(j) ) fi (x "j e(j) )
=
@xj 2"j
T
e(j) = 0 ::: 0 1 0 ::: 0 n 1

Here, e(j) represents a unit vector with all elements equal to zero and the j’th element equals 1.
While writing the MATLAB program to approximate Jacobian numerically, you can compute
j’th column of the Jacobian matrix as follows
F(x + "j e(j) ) F(x "j e(j) )
j th column of J(x) =
2"j
Programming Task: Write MATLAB programs to perform the following tasks

1. Write a function that takes vector x as input argument and returns vector Fofx that
contains values of the function
2 3
2x21 4x2 x3 ex1
F(x) = 4 4x21 + 2x22 + x23 sin(x2 ) 5
x1 x22 4x2 x23 cos(x1 )

evaluated at speci…ed x

1
2. Find the Jacobian matrix of function developed in Q.1 at the following two points
T T
x(1) = 1 1 1 and x(1) = 1 0 1 using (a) analytical di¤erentiation of F(x)
(say JA )and (b) numerical di¤erentiation using central di¤erence method (say JN ). Find
1 norm, 2 norm and in…nity norms of matrix (JA JN ) using norm function of MATLAB.

3. Consider the reactor system assigned to your programming group. Write a function that
takes vector x as input argument and returns vector Fofx that contains the steady state
reactor equations.

4. Find Jacobian matrices using numerical di¤erentiation for the reactor system assigned to
your programming group at the operating points 1 and 2 speci…ed in the assignment.

Pseudo-code for Computing Jacobian matrix numerically using the Central Dif-
ference Approximation

Initialize:

– nx : no. of elements in x vector


– Xvec : nx 1 vector equal to the vector for which you need to evaluate Jacobian
– Xp : nx 1 Null vector
– Xn : nx 1 Null vector
– Jacob : nx nx Null matrix to store Jacobian

Compute Numerical Jacobian Matrix for …nite di¤erence


FOR i = 1 : nx
" = Xvec(i) (1 10 5 )
5
IF (" == 0 ) THEN " = 1 10
Xp = Xvec % Equate Xp with Xvec
Xp(i)= Xvec(i) + " % Introduce +ve perturbation in i’th element of Xp
FXpi = myf un( Xp ) % Evaluate the function for X=Xp
Xn = Xvec % Equate Xp with Xvec
Xn(i)= Xvec(i) " % Introduce -ve perturbation in i’th element of Xn
FXni = myf un( Xn ) % Evaluate the function for X=Xp
1
Jacob(:;i) = [FXpi FXni] % Evaluate i’th column of the Jacobian
(2 ")
Matrix
END FOR

Note: Here FofX =myf un( X ) represents the functions that you have been asked to write
in programming tasks 1 and 3.

You might also like