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

Assignment

The document consists of three assignments involving mathematical computations using MATLAB. Assignment 1 focuses on calculating partial derivatives of a function, Assignment 2 involves matrix operations including rank, determinant, and eigenvalues, while Assignment 3 solves a system of equations using matrix rank. Each assignment includes code snippets and their corresponding outputs.

Uploaded by

anitajana127
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)
5 views

Assignment

The document consists of three assignments involving mathematical computations using MATLAB. Assignment 1 focuses on calculating partial derivatives of a function, Assignment 2 involves matrix operations including rank, determinant, and eigenvalues, while Assignment 3 solves a system of equations using matrix rank. Each assignment includes code snippets and their corresponding outputs.

Uploaded by

anitajana127
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/ 3

Assignment 1

Code :

syms x y;

f=exp(x.^2+y.^2)

p=diff(f,x)

q=diff(f,y)

p1=diff(p,x)

q1=diff(q,y)

q2=diff(q,x)

p2=diff(p,y)

p12=subs(p,{x,y},{-1,1});

q12=subs(q,{x,y},{-1,1});

p21=subs(p2,{x,y},{-1,1});

q21=subs(q2,{x,y},{-1,1});

if (p21 == q21)

disp('Mixed partial derivative is same at (-1,1)')

end

disp(p21);

disp(q21);

Run:

>> ass1

f = exp(x^2 + y^2)

p = 2*x*exp(x^2 + y^2)

q = 2*y*exp(x^2 + y^2)

p1 = 2*exp(x^2 + y^2) + 4*x^2*exp(x^2 + y^2)

q1 = 2*exp(x^2 + y^2) + 4*y^2*exp(x^2 + y^2)

q2 = 4*x*y*exp(x^2 + y^2)

p2 = 4*x*y*exp(x^2 + y^2)
Assignment 3
Code:

close all

A = [-4 7 -2; 1 -2 1; 2 -3 1]

B = [2; 3; -4]

C = [-4 7 -2 2; 1 -2 1 3; 2 -3 1 -4]

R1 = rank(A)

R2 = rank(C)

if(R1==R2)&&R1==3

solution=inv(A)*B

elseif (R1==R2)&&R1<3

disp("Infinitely many soulutions")

else

disp("No solutions")

end

Run:

> matrixsolution

A = -4 7 -2

1 -2 1

2 -3 1

B= 2 3 -4

C = -4 7 -2 2

1 -2 1 3

2 -3 1 -4

R1 = 3

R2 = 3

solution = -13 -6 4

>>
Assignment 2
Code:

A=[0 1 2; 3 4 5; 6 7 8];
n = size(A);
m = min(n);
r = rank(A);
d=det(A);
if(d~=0)
B=inv(A);
else
B=0;
end
[V,D]=eig(A);
disp("size");
disp(n);
disp("min");
disp(m);
disp("rank:");
disp(r);
disp("d;terminant");
disp(d);
if~isempty(B)
disp("inverse:");
disp(B);
else
disp("inverse does not exist (singular matrix).");
end
disp("eigenvalues (diagonal of D):");
disp(diag(D));
disp("eigenvectors (columns of V)");
disp(V);

Run:
>> ass2
eigenvectors (columns of V)
size 3 3
0.1648 0.7997 0.4082
min 3
0.5058 0.1042 -0.8165
rank: 2
0.8468 -0.5913 0.4082
determinant 0

inverse: 0

eigenvalues (diagonal of D): 13.3485

-1.3485

-0.0000

You might also like