0% found this document useful (0 votes)
18 views16 pages

Mathematics Practical Guide: Matrix & Derivatives

The document is a practical mathematics report by Atulya Singh, detailing various mathematical topics including matrices, Gauss-Jordan elimination, partial derivatives, and graphing functions. It includes MATLAB code snippets for performing matrix operations, solving linear equations, and calculating derivatives. The report also presents results from computations such as eigenvalues, eigenvectors, and stationary points of functions.

Uploaded by

A T
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)
18 views16 pages

Mathematics Practical Guide: Matrix & Derivatives

The document is a practical mathematics report by Atulya Singh, detailing various mathematical topics including matrices, Gauss-Jordan elimination, partial derivatives, and graphing functions. It includes MATLAB code snippets for performing matrix operations, solving linear equations, and calculating derivatives. The report also presents results from computations such as eigenvalues, eigenvectors, and stationary points of functions.

Uploaded by

A T
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

NAME: - Atulya Singh

ROLL NO.: -25CSU303


GROUP: - CS11
SECTION: - F
SUBJECT: - MATHEMATICS
INDEX
S. TOPIC PAGE DATE SIGNATURE
NO NO. SUBMITTED
1. MATRIX 1-4 9/11/25

2. GAUSS JORDAN 5-9 12/11/25

3. PARTIAL 10 10/11/25

4. CIRCLE 11-12 9/11/25

5. DIFFERENTIATIVES 13-14 9/11/25

6. CERTIFICATES 15-19 12/11/25


%Practical 1
% how to enter a matrix,algebra of matrices;addition, subtraction and
% different ways of matrix multiplication ,determinant, inverse,row and
% column operations, echeleon form , rank of matrix

clc;
clear all;
A = [1 2 3;4 2 1;1 3 5]

B = [2 1 1;3 4 2;2 1 2]

C = A + B %addition

D = A - B %subtraction

E = A*B %multiplication

F = A.*B %rowmultiplication

G = det(A) %determinant

H = det(B)

I = inv(A) %inverse

J = inv(B)

K = rank(A) %rank

L = rank(B)

M = rref(A) %row reduced echlor form

N = rref(B)

% extracting

row2 = A(2,:)

% extracting the second column


col2 = A(:,3)

%swapping of rows

A([1 2],:) = A([2 1],:)

%scaling a row

A(1,:) = 2 * A(1,:)

1
A =

1 2 3
4 2 1
1 3 5

B =

2 1 1
3 4 2
2 1 2

C =

3 3 4
7 6 3
3 4 7

D =

-1 1 2
1 -2 -1
-1 2 3

E =

14 12 11
16 13 10
21 18 17

F =

2 2 3
12 8 2
2 3 10

G =

-1.0000

H =

I =

2
-7.0000 1.0000 4.0000
19.0000 -2.0000 -11.0000
-10.0000 1.0000 6.0000

J =

1.2000 -0.2000 -0.4000


-0.4000 0.4000 -0.2000
-1.0000 0 1.0000

K =

L =

M =

1 0 0
0 1 0
0 0 1

N =

1 0 0
0 1 0
0 0 1

row2 =

4 2 1

col2 =

3
1
5

A =

4 2 1
1 2 3
1 3 5

3
A =

8 4 2
1 2 3
1 3 5

4
%practical 2
%Solution of linear equation: Gauss-Jordan and Gauss elimination method,
%how to find out Eigenvalues and Eigenvectors of a matrix
clc;
clear all;
A=[1 -1 1; 2 1 -3; 1 1 1]
B= [4; 0; 2]
X=inv(A)*B
X1=A\B

%Use a suitable of row operation on B to bring B to upper triangular Form


%and lower triangular Form
B= [1 -1 0; 2 3 1; 4 1 5]
C=triu(B)
D=tril(B)
E= [1 1 2 -1; 2 5 -1 -9; 2 1 -1 3; 1 -3 2 7]
F= [3; -3; -11; -5]
Y1=inv(E)*F
Y2=E\F

%Verify for matrices G and H that inv(GH)= inv(H)*inv(G)


G=[1 2 3; 2 1 3; 3 2 1]
H= [5 6 7; 6 5 7; 7 6 5]
Z1= inv(G*H)
Z2=inv(H)*inv(G)

%Gauss-Jordan Elimination Method:


% Input matrix I and vector j (Augmented matrix [I | j])
I= [2 -1 1; 3 3 9; 3 3 5]
j= [2; -1; 4]
Aug= [I j];% Augmented Matrix

[n,m] = size(Aug);

%Gauss-Jordan elimination
for i = 1:n
% Make the diagonal element 1
Aug(i, :) = Aug(i, :) / Aug(i, i);
% Make other elements in the column 0
for j = 1:n
if i ~= j
Aug(j, :) = Aug(j, :) - Aug(i, :) * Aug(j, i);
end
end
end
% Display Results
disp('The reduced row echolen form is:');
disp(Aug);
% Extract the solution vector from the augmented matrix:
solution = Aug(:, end);
disp('The solution system is:');
disp(solution);

5
% Find Sigma Values and eigenvectors:
[V,D] = eig(A)

% D is a diagonal matrix with eigenvalues


% V contains eigenvectors as a column

disp('Eigenvalues:');
disp(diag(D));
disp('Eigenvectors:');
disp(V);

A =

1 -1 1
2 1 -3
1 1 1

B =

4
0
2

X =

2
-1
1

X1 =

2
-1
1

B =

1 -1 0
2 3 1
4 1 5

C =

1 -1 0
0 3 1

6
0 0 5

D =

1 0 0
2 3 0
4 1 5

E =

1 1 2 -1
2 5 -1 -9
2 1 -1 3
1 -3 2 7

F =

3
-3
-11
-5

Y1 =

-5
2
3
0

Y2 =

-5.0000
2.0000
3.0000
-0.0000

G =

1 2 3
2 1 3
3 2 1

H =

5 6 7
6 5 7
7 6 5

7
Z1 =

0.4074 -0.3148 -0.0833


-0.5926 0.6852 -0.0833
0.1574 -0.3148 0.1667

Z2 =

0.4074 -0.3148 -0.0833


-0.5926 0.6852 -0.0833
0.1574 -0.3148 0.1667

I =

2 -1 1
3 3 9
3 3 5

j =

2
-1
4

The reduced row echolen form is:


1.0000 0 0 2.2222
0 1.0000 0 1.1944
0 0 1.0000 -1.2500

The solution system is:


2.2222
1.1944
-1.2500

V =

-0.7845 + 0.0000i -0.0845 + 0.3684i -0.0845 - 0.3684i


0.1961 + 0.0000i 0.8452 + 0.0000i 0.8452 + 0.0000i
-0.5883 + 0.0000i 0.0845 - 0.3684i 0.0845 + 0.3684i

D =

2.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i


0.0000 + 0.0000i 0.5000 + 2.1794i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.5000 - 2.1794i

Eigenvalues:

8
2.0000 + 0.0000i
0.5000 + 2.1794i
0.5000 - 2.1794i

Eigenvectors:
-0.7845 + 0.0000i -0.0845 + 0.3684i -0.0845 - 0.3684i
0.1961 + 0.0000i 0.8452 + 0.0000i 0.8452 + 0.0000i
-0.5883 + 0.0000i 0.0845 - 0.3684i 0.0845 + 0.3684i

9
%practical 3
clc;
clear all;
syms x y

% define the function

f = x^2 * y + y^3;

%first order partial derivatives

fx = diff(f,x)
fy = diff(f,y);

% second order partial derivatives


fxx = diff(fx,x);
fyy = diff(fy,y);
fxy = diff(fx,y);

% Display symbolic derivatives


disp('first order partial derivatives:');
disp(['df/dx = ', char(fxx)]);
disp(['df/dy = ', char(fyy)]);

disp('second order partial derivatives:');


disp(['d^2f/dx^2 = ', char(fxy)]);
disp(['d^2f/dy^2 = ', char(fxy)]);
disp(['d^2f/dxdy = ', char(fxy)]);

fx =

2*x*y

first order partial derivatives:


df/dx = 2*y
df/dy = 6*y
second order partial derivatives:
d^2f/dx^2 = 2*x
d^2f/dy^2 = 2*x
d^2f/dxdy = 2*x

10
%practial 4
clc;
clear all;
syms x
syms y
%f= -4+8*x^2+4*x^3;
% fplot(f)

% parabola
%x = [-1: 01: 1];
%y = x.^2
%plot (x,y,'r')

% multiple plots

%x=[-10: .01: 10];


%y1=sin(x)
%y2=cos(x)
%plot(x,y1,'r',x,y2,'g')

%sin x graph
x=[-10: .01: 10];
y=sin(x)
plot(x, y, 'r')
xlabel('x axis');
ylabel('y axis');
title('Graph of sin(x)');

r=5
theta = linspace(0, 2*pi, 100);
x = r * cos(theta);
y = r * sin(theta);
plot(x, y);
axis('equal')

11
12
%practical 5
clc;
clear;
% Define symbolic variables
syms x y;

% Define the function


%f = x^3 - 3*x*y^2;
%f x*y+9/x+3/y;
f=x.^3+y.^3-3*x-12*y+20;
% Compute first order partial derivative

fx = diff(f,x);
fy = diff(f,y);

% solve for stationary points


[solx,soly] = solve([fx == 0,fy == 0],[x,y]);

% display stationary points


disp("stationary points:");
points = [solx,soly]

%compute second order derivatives


fxx = diff(fx, x);
fyy = diff(fy, y);
fxy = diff(fx, y);

%loop through stationary points


for i = 1:length(solx)
x0 = double(solx(i));
y0 = double(soly(i));

%evaluate second order derivatives at point


D = double(subs(fxx,[x,y],[x0,y0]))*double(subs(fyy,[x,y],[x0,y0]))
-double(subs(fxy,[x,y],[x0,y0]))^2;
fxx_val = double(subs(fxx,[x,y],[x0,y0]));

fprintf('\nPoint(%.2f,%.2f):' ,x0,y0);
if D >0
if fxx_val > 0

end
end
end

stationary points:

13
points =

[-1, -2]
[ 1, -2]
[-1, 2]
[ 1, 2]

D =

72

Point(-1.00,-2.00):
D =

-72

Point(1.00,-2.00):
D =

-72

Point(-1.00,2.00):
D =

72

Point(1.00,2.00):

14

You might also like