Computing Assignment 2 2024
Computing Assignment 2 2024
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:
Note: Here FofX =myf un( X ) represents the functions that you have been asked to write
in programming tasks 1 and 3.