0% found this document useful (0 votes)
34 views

Lab 3

1) The document discusses finding partial derivatives and Jacobian matrices. It provides algorithms for calculating partial derivatives with respect to variables and constructing Jacobian matrices from those partial derivatives. 2) Several examples are shown of calculating partial derivatives of functions and verifying properties like whether second partial derivatives are equal. Jacobians are also computed for examples. 3) The last example shows evaluating the determinant of a Jacobian matrix at a specific point by substituting values into it.

Uploaded by

shriomraikar217
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Lab 3

1) The document discusses finding partial derivatives and Jacobian matrices. It provides algorithms for calculating partial derivatives with respect to variables and constructing Jacobian matrices from those partial derivatives. 2) Several examples are shown of calculating partial derivatives of functions and verifying properties like whether second partial derivatives are equal. Jacobians are also computed for examples. 3) The last example shows evaluating the determinant of a Jacobian matrix at a specific point by substituting values into it.

Uploaded by

shriomraikar217
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

3) Finding partial derivatives and Jacobian

a) Finding partial derivatives


ALGORITHM
Step 1: Start
Step 2: Declare syms x & y
Step 3: Read U
Step 4: Differentiate U w.r.t x
Step 5: Differentiate U w.r.t y
Example 1: If U = e^x(xcosy – ysiny) then check Uxy = Uyx
Code:
syms x y
U = exp(x)*(x*cos(y) - y*sin(y)); %Read Equation
Ux = diff(U,x) ; %Differentiate U w.r.t x
Uxy = diff(Ux,y) ; %Differentiate Ux w.r.t y
Uy = diff(U,y); %Differentiate U w.r.t y
Uyx = diff(Uy,x) ; %Differentiate Uy w.r.t x
if Uxy == Uyx; %Condition check
disp('Uxy = Uyx')
else
disp('Uxy is not equals to Uyx')
end
OUTPUT :
Ux =
Uxy =
Uy =
Uyx =
Uxy = Uyx
Example 2: If U = log(x2 + y2)/(x + y)) then show that xUx + yUy = 1
Code:
syms x y
U = log((x.^2 + y.^2)/(x + y))
Ux = diff(U,x)
xUx = x*Ux
Uy = diff(U,y)
yUy = y*Uy
w = xUx + yUy
w1 = simplify(w)
Output

U=

Ux =

xUx =

Uy =

yUy =

w=
w1 =
Example 3: If U = e^(3x)(x^2cos(y) – y^2sin(y)) then find xUxx + yUyy

Code:
syms x y
U = exp(3*x)*(x.^2*cos(y) - y.^2*sin(y));
Ux = diff(U,x);
Uxx = diff(Ux,x);
xUxx = x*Uxx;
Uy = diff(U,y);
Uyy = diff(Uy,y);
yUyy = y*Uyy;
w = xUxx + yUyy;
w1 = simplify(w)
Output
w1 =
b) Finding Jacobian
ALGORITHM
Step 1: Start
Step 2: Declare syms x y z
Step 3: Read U V W
Step 4: Differentiate U, V, W w.r.t x
Step 5: Differentiate U, V, W w.r.t y
Step 6: Differentiate U, V, W w.r.t z
Step 7: Create a matrix J of with values of partial derivatives
Step 8: Take determinate of Jacobian J
Example 1:- If U = xy/z V = yz/x W = zx/y then show Jacobian = 4
Code:
syms x y z
% Read Equation U V W
U = x*y/z
V = y*z/x
W = z*x/y
% Differentiate U w.r.t x,y,z
Ux = diff(U,x);
Uy = diff(U,y);
Uz = diff(U,z);
% Differentiate V w.r.t x,y,z
Vx = diff(V,x);
Vy = diff(V,y);
Vz = diff(V,z);
% Differentiate W w.r.t x,y,z
Wx = diff(W,x);
Wy = diff(W,y);
Wz = diff(W,z);

%Create a matrix J of with values of partial derivatives


J = [Ux,Uy,Uz;Vx,Vy,Vz;Wx,Wy,Wz]
% Determinate of Jacobian
Jacobian = det(J)
Output:

U=
V=
W=
Ux =
Uy =

Uz =

Vx =

Vy =
Vz =
Wx =

Wy =

Wz =
J=

Jacobian =
Example: If U = x+3y^2 – z^3; V = 4x^2yz; W = 2z^2 - xy then show that at
(1,-1,0)
Code:
syms x y z
% Read Equation U V W
U = x+3*y^2-z^3
V = 4*x^2*y*z
W = 2*z^2-x*y

% Differentiate U w.r.t x,y,z


Ux = diff(U,x);
Uy = diff(U,y);
Uz = diff(U,z);

% Differentiate V w.r.t x,y,z


Vx = diff(V,x);
Vy = diff(V,y);
Vz = diff(V,z);

% Differentiate W w.r.t x,y,z


Wx = diff(W,x);
Wy = diff(W,y);
Wz = diff(W,z);

%Create a matrix J of with values of partial derivatives


J = [Ux,Uy,Uz;Vx,Vy,Vz;Wx,Wy,Wz]

% Determinate of Jacobian
Jacobian = det(J)
J1 = subs(Jacobian,[x,y,z],[1,-1,0])
Output:
U=
V=
W=
Ux =
Uy =
Uz =
Vx =
Vy =
Vz =
Wx =
Wy =
Wz =
J=

Jacobian =
J1 =

You might also like