PROGRAM:

clc

% Matrix of size 1*3

a=[2 3 4]; b=[5 6 8];

% Square matrix of size 3*3

A=[8 -6 2; -6 7 -4; 2 -4 3];

B=[1 1 3; 1 5 1; 3 1 1];

C=[1; 2; 3]

% Addition of a matrix

disp("Addition of a Matrix :")

c=a+b

% Subtraction of a matrix

disp("Subtraction of a Matrix :")

d=a-b

% Scalar Multiplication of a matrix

disp("Scalar Multiplication of a Matrix :")

e=A*B

%ee=a*b

%eee=a.*b

% Array Multiplication of a matrix

disp("Array Multiplication of a Matrix :")

f=a.*b

g=A.*B

% Determinant of a matrix

disp("Determinant of a Matrix :")

h=det(A)

aa=det(B)

% Inverse of a matrix

disp("Inverse of a Matrix :")

%ab=inv(A)

aab=inv(B)

% adjoint of a matrix

yy=adjoint(A)

% Transpose of a matrix

yyy=B'

% Trace of a matrix

xy=trace(B)

px=trace(A)

___________________________________

PROGRAM:

clc

% Square matrix of size 3*3

A=[8 -6 2; -6 7 -4; 2 -4 3];

B=[1 1 3; 1 5 1; 3 1 1];

% Rank of a matrix

disp("Rank of a Matrix :")

Rank_of_A=rank(A)

Rank_of_B=rank(B)

________________________________________

PROGRAM:

clc

% Square matrix of size 3*3

clc

A = [8 -6 2; -6 7 -4; 2 -4 3];

disp("Matrix A:");

disp(A);

% Eigenvalues and right eigenvectors of matrix A

[V,D] = eig(A);

disp("Eigenvalues of matrix A:");

disp(D);

% Eigenvector need not be uniqie

disp("Eigenvectors of matrix A:")

disp(V);

____________________________________________

PROGRAM:

clc

% syms means a cell array of the names of all symbolic scalar variables, functions, matrix

variables, matrix functions, and arrays.

syms x y

F=x^2+2*y^2-22;

diff(F,x)

diff(F,y)

diff(F,x,y)

syms x y

disp("Partial derivatives of a f(x) = x^2+2*y^2-22 :")

f=x^2+2*y^2-22;

P=diff(f,x)

Q=diff(f,y)

subs(P+Q,{x,y},{1.5,2})

% Partial Derivative of function f(x) w.r.t variable t.

syms x t;

disp("Derivative of f(x,t) = sin(x*t) w.r.t t:");

f = sin(x*t);

ft = diff(f,t)

syms x t;

disp("Derivative of f(x,t) = cos(x*t)*sin(x*t) w.r.t t:");

f = cos(x*t)*sin(x*t);

ft = diff(f,t)

% k-Order Partial Derivative of function f(x) w.r.t variable x.

syms x n;

disp("k-Order Partial Derivative of f(x,n)=x^n wrt x:");

f = x^n;

% 2 -> repesent tow times of derivatives.

% if say 3 -> repesent three times of derivatives.

d2 = diff(f,x,2)

d5 = diff(f,x,5)

%Another way

syms x y

F = sin(x) + cos(y);

gradient(F, x)

gradient(F,[x,y])

syms x y

F = sin(x)*cos(y);

gradient(F,x)

gradient(F,[x,y])

gradient(F,[y,x])

syms x y z

F = sin(x) + cos(y)- exp(z);

gradient(F,[x,y,z])

___________

PROGRAM:

clc

%Find stationary points of a f(x,y)=(x^3)*(y^2)*(12-x-y).

syms x y

% Derivative of function f(x,y) w.r.t variable x and y

a = (x^3)*(y^2)*(12-x-y);

eqn_fx = diff(a,x)

eqn_fy = diff(a,y)

M = solve(eqn_fx,eqn_fy)

Stationary_Points = [M.x,M.y]

%Find stationary points of a f(x,y)=x^3+y^3-3x-12y+20.

syms x y

% Derivative of function f(x,y) w.r.t variable x and y

a = (x^3)+(y^3)-(3*x)-(12*y)+20;

eqn_fx = diff(a,x)

eqn_fy = diff(a,y)

M = solve(eqn_fx,eqn_fy)

Stationary_Points = [M.x,M.y]

______________________

PROGRAM:

clc

syms x y

% Function

F=exp(x)*cos(y);

T1 = taylor(F, [x, y], [0 0], 'order', 4)

% Function

F=exp(x)*cos(y);

T2 = taylor(F, [x, y], [0 pi/2], 'order', 4)

% Function

F=exp(2*x)*sin(y);

T3 = taylor(F, [x, y], [0 0], 'order', 3)

__________________

PROGRAM:

clc

%Evaluate

syms x y

firstint=int(1,x,0,2)

answer=int(firstint,y,0,2)

%Evaluate

syms x y

firstint=int(x.^2+y.^2,y,1,x^2)

answer=int(firstint,x,1,2)

%Evaluate

syms x y

firstint=int(1-6*x^2*y,x,0,2)

answer=int(firstint,y,-1,1)

%Evaluate

syms x y

firstint=int(x^2+y^2,x,0,1-y)

answer=int(firstint,y,0,1

_________________

PROGRAM:

clc

%Find the Area of the double integral

%Area between the parabola y=x^2 and straight line y=x

syms x y

firstint=int(1,y,x^2,x)

Area=int(firstint,x,0,1)

%Find the Area of the double integral

%Area of the first quadrant of the circle x^2+y^2=1

syms x y

firstint=int(1,x,0,sqrt(1-(y^2)))

Area=int(firstint,y,0,1)

%Find the Area of the double integral

% Area between the parabola y=x^2 and straight line y=1.

syms x y

firstint=int(1,y,1,x^2)

Area=int(firstint,x,1,2)

____________

PROGRAM:

clc

%Evaluate

fun = @(x,y,z) x+y.^2;

zmin = -1; %z limits

zmax = 5;

ymin = 2; %y limits

ymax = 4;

xmin = 0; % x limits

xmax = 1;

result = integral3(fun,xmin,xmax,ymin,ymax,zmin,zmax)

%Evaluate

syms x y z

firstans=int(int(int(x*y*z,z,0,3-x-y),y,0,3-x),x,0,3)

%Evaluate

fun = @(x,y,z) x.*cos(y) + x.^2.*cos(z)

xmin = -1;

xmax = 1;

ymin = @(x)-sqrt(1 - x.^2);

ymax = @(x) sqrt(1 - x.^2);

zmin = @(x,y)-sqrt(1 - x.^2 - y.^2);

zmax = @(x,y) sqrt(1 - x.^2 - y.^2);

q = integral3(fun,xmin,xmax,ymin,ymax,zmin,zmax,'Method','tiled')

%Evaluate

a = 2;

f = @(x,y,z) 10./(x.^2 + y.^2 + z.^2 + a);

format long

Result = integral3(f,-Inf,0,-100,0,-100,0)

______________

PROGRAM:

clc

% Find the volume of tetrahedron formed between coordinate planes and the

% plane using triple integration where a, b, c are constants.

intercepts = input("For the plane x/a+y/b+z/c = 1, enter values of a,b,c in the form [a b c]: ");

a = intercepts(1);

b = intercepts(2);

c = intercepts(3);

volume = @(x,y,z) ones(size(x));

xmin = 0; xmax = a;

ymin = 0; ymax = @(x) b*(1-x/a);

zmin = 0; zmax = @(x,y) c*(1-y/b-x/a);

% You can crosscheck that the volume is correct using the formula for

% volume for tetrahedron i.e. (1/3) x (Area of base triangle) x (Height)

% V = (1/3)*((1/2)*a*b)*c;

V = integral3(volume,xmin,xmax,ymin,ymax,zmin,zmax);

V = abs(V);

disp(V);

____________


Comments

Popular posts from this blog