Professional Documents
Culture Documents
TitlePage Engineeering Mathematics-II LAB[1] 2 (3)
TitlePage Engineeering Mathematics-II LAB[1] 2 (3)
Lab Report
B. Tech- II Sem
Winter: 2023-24
Engineering Mathematics-II(Lab)
(C1UC222B)
23SCSE1180379
Adm No:.................
S.No. List of Experiments
1. Revision of the Scilab: Overview, Basic syntax, Mathematical Operators, Predefined constants,
Built in functions. Conditional Statements, Loops, Matrix, and Its applications.
2. Write a SCILAB –CODE for Basic Vector Calculations, Finding Norm, Angle between two
Vectors, Unit Vector.
3. Write a SCILAB –CODE to Find Divergence using Scilab and verifying Divergence Theorem.
4. Write a SCILAB –CODE to Find Curl using Scilab and Verifying Stokes Theorem.
7. Write a SCILAB –CODE to find Matrix associated with linear Transformations and their
corresponding operations.
8. Write a SCILAB –CODE to check Orthogonal and Orthonormal Vectors, Gramm Schmidt
Orthogonalization process.
9. Write a SCILAB –CODE to Plot Direction fields of first order differential equations.
10. Write a SCILAB –CODE to Solve Linear ODE with different initial conditions using Scilab.
11. Write a SCILAB –CODE to Solve Linear simultaneous differential equations with initial
conditions using Scilab.
12. Write a SCILAB –CODE to Solve PDE with boundary conditions using scilab.
S. Experiment Date Signature
No. (Performed) (with date)
1. Revision of the Scilab: Overview, Basic syntax,
Mathematical Operators, Predefined constants, Built in
functions. Conditional Statements, Loops, Matrix, and Its
applications.
EXPERIMENT-1
Objective:
Out-put-
1. 2. 3.
Out-put-
4.
5.
6.
7.
(iii) Find the addition of matrices A and B where:
Source code-
A = [1, 3, 6;
5, 0, 2;
7, 4, 1];
B = [0, 5, 1;
2, 1, 7;
21, 41, 23];
sumMatrix = A + B;
disp(sumMatrix)
Out-put-
1. 8. 7.
7. 1. 9.
28. 45. 24.
1. Write a SCILAB code to check whether the given number is even or odd by
using if- else statement
Source code-
n = 7;
if modulo(n, 2) == 0 then
disp(n , " is even");
else
disp(n , " is odd");
end
Out-put-
7.
" is odd"
2. Write a SCILAB code to print the sum of first N natural numbers using for-loop.
Source code-
n = 10;
sum = 0;
for i = 1:n
sum = sum + i;
end
disp("The sum of first " + string(n) + " natural numbers is " + string(sum));
Out-put-
Source Code-
n=5
i = 1;
while i <= 10
disp(string(n) + " * " + string(i) + " = " + string(n*i));
i = i + 1;
end
Out-put-
"5 * 1 = 5"
"5 * 2 = 10"
"5 * 3 = 15"
"5 * 4 = 20"
"5 * 5 = 25"
"5 * 6 = 30"
"5 * 7 = 35
"5 * 8 = 40"
"5 * 9 = 45"
"5 * 10 = 50"
4 Write a SCILAB code to find the Volume and total surface area of cylinder by using
function (where r=2, h=6).
Source code-
PI = 3.14159;
r = 2;
h = 6;
vol = PI * r^2 * h;
disp("Volume of Cylinder = " + string(vol));
tsurf_ar = (2 * PI * r * h) + (2 * PI * r^2);
disp("Total Surface Area of Cylinder = " + string(tsurf_ar));
cursurf_ar = 2 * PI * r * h;
disp("Curved Surface Area of Cylinder = " + string(cursurf_ar));
Out-put-
EXPERIMENT-2
Objective:
Write a SCILAB –CODE for Basic Vector Calculations, Finding Norm, Angle between two
Vectors, Unit Vector.
1. Create two-row vectors a and b such that the following operations are defined and
hence find: (i) 2a-3b, (ii)2(transpose a)-3(transpose b)
Code-
a = [1, 2, 3, 4, 5];
b = [6, 7, 8, 9, 10];
output-
"Result of 2a - 3b:"
-16.
-17.
-18.
-19.
-20.
(i) (0,0),(1,1) (ii) (1,2), (0,1) (iii) (0,1,0), (1,2,1) (iv) (1,2,3), (2,3,4)
Code-
Out-put-
(i) (1,2) (ii) (2,5) (iii) (0,7) (iv) (1,2,3) (v) (-1,0,1) (vi) (0,1,-1)
Code-
function draw2dArrows(vectors)
Output-
4. Draw the multiple arrows for the following vectors:
Code-
x2 = [0, 5];
y2 = [0, 2];
z2 = [0, 2];
Out-put-
(i)- (ii)-
AMAN KUMAR
23SCSE1180379
EXPERIMENT-3
Objective:
Write a SCILAB –CODE to Plot scalar and vector point function and their gradient and
Divergence.
CODE-
// Define the function
function z=f(x, y)
z = x .* exp(-(x.^2 + y.^2));
endfunction
// Generate meshgrid
[X, Y] = meshgrid(x, y);
// Compute Z values
Z = f(X, Y);
// Compute gradient
[DX, DY] = gradf(X, Y);
CODE-
OUT-PUT-
3. Plot Vector field and Divergence of function
CODE-
function [u, v]=vectorField(x, y)
r = sqrt(x.^2 + y.^2);
u = -x ./ (r.^3);
v = -y ./ (r.^3);
endfunction
OUT-PUT-
4. Plot Vector field and Divergence of function
Code-
x = -5:0.2:5;
y = -5:0.2:5;
// Calculate divergence
divF = derivative(sin(Y)) + derivative(cos(X));
Objective:
1.Check whether the vectors V1= (2,-5,3), V2=(1,-3,2),V3=(2,-4,-1), V4=(1,-5,7) are linearly
dependent or independent. INPUT:
M = [2, -5, 3;
1, -3, 2;
2, -4, -1;
1, -5, 7];
if rank(M) == size(M, 1) then
disp("The vectors are linearly independent.");
else
disp(“The vectors are linearly dependent.”);
end
Aridaman Singh 23SCSE1410165
OUTPUT:
v1 = [1,0,1];
v2 = [1, 0, 1];
v3 = [0, 1, 1];
A = [v1; v2; v3];
r = rank(A)
if (r == size(A, 1)) then
disp("The vectors are linearly independent.");
else
disp("The vectors are linearly dependent.");
end
OUTPUT:
"The vectors are linearly dependent."
EXPERIMENT-7
Objective:
Write a SCILAB –CODE to find Matrix associated with linear Transformations
and their corresponding operations.
(A)
Where basis of domain are {(1, 2), (3,5)}and basis of co-domain {(1,3), (2,7)}
Source Code-
domain_basis = [1, 3; 2, 5];
codomain_basis = [1, 2; 3, 7];
function [result]=T(x, y)
result = [x - y; x + y];
endfunction
transformation_matrix = [];
for i = 1:2
transformed_vector = T(domain_basis(1,i), domain_basis(2,i));
coefficients = codomain_basis \ transformed_vector;
transformation_matrix = [transformation_matrix, coefficients];
end
disp(transformation_matrix); Aridaman Singh 23SCSE1410165
Out-Put-
-13. -30.
6. 14.
(B)
Source Code-
transformation_matrix = [];
for i = 1:3
transformed_vector = T(domain_basis(1,i), domain_basis(2,i),
domain_basis(3,i));
coefficients = codomain_basis \ transformed_vector;
transformation_matrix = [transformation_matrix, coefficients];
end
disp(transformation_matrix); Aridaman Singh 23SCSE1410165
Out-Put-
0.3333333 0. 9.3333333
EXPERIMENT-8
Objective:
Write a SCILAB –CODE to check Orthogonal and Orthonormal Vectors, Gramm Schmidt
Orthogonalization process.
Sorce Code-
function Q=gram_schmidt(V)
[m, n] = size(V);
Q = zeros(m, n);
for j = 1:n
v = V(:,j);
for i = 1:j-1
rij = Q(:,i)'*V(:,j);
v = v - rij*Q(:,i);
end
rjj = norm(v);
Q(:,j) = v / rjj;
end
endfunction