Академический Документы
Профессиональный Документы
Культура Документы
CODING:
clc
clear all
A =[7 -2 2 ; -2 1 4 ; -2 4 1 ];
[v,d]=eig(A);
disp('Eigen Values of the Matrix A:')
eigenvalues = diag(d)
disp('Eigen Vectors of Matrix A:')
x1 = v(:,1)
x2 = v(:,2)
x3 = v(:,3)
disp('Sum of the Eigen Values of A')
sumofeigenvalues=sum(eig(A))
disp('Product of Eigen Values of A:')
product=prod(eig(A))
[v1,d1]=eig(A*A);
disp('Eigen Values of the Matrix A*A:')
eigenvalues = diag(d1)
disp('Eigen Vectors of Matrix A*A:')
x1 = v1(:,1)
x2 = v1(:,2)
x3 = v1(:,3)
[v2,d2]=eig(inv(A));
disp('Eigen Values of the Inverse of the Matrix A:')
eigenvalues = diag(d2)
disp('Eigen Vectors of the inverse of the Matrix A:')
x1 = v2(:,1)
x2 = v2(:,2)
x3 = v2(:,3)
OUTPUT:
eigenvalues = 7 5 -3
CODING:
clc
clear all
A=[7 -2 0 ; -2 6 -2 ; 0 -2 5 ] ;
disp('Given Matrix A:')
disp(A)
[P,D] =eig(A);
disp('Modal Matrix P:')
disp(P)
disp('Diagonal Matrix D:')
disp(D)
disp('Diagonalising the given Matrix A into a
Diagonal Matrix by Similarity Transformation:')
D1 = inv(P)*A*P
disp('Diagonal Matrix D and Diagonalised Matrix D1 of
the given Matrix A are same.')
OUTPUT:
Given Matrix A: 7 -2 0
-2 6 -2
0 -2 5
Diagonal Matrix D: 3 0 0
0 6 0
0 0 9
D1 = 3 0 0
0 6 0
0 0 9
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
-3 -2 -1 0 1 2 3
x
ASSIGNMENT-3:
Write a program for the Power series solution of the differential equation
CODING:
clc
clear all
syms x a0 a1 a2 a3 ;
a = [a0 a1 a2 a3 ];
disp('Given equation:(1+x^2)y"+x*y -y=0 with y(0)=2
and dy(0)=3')
y = sum(a.*x.^[0:3])
dy = diff(y);
d2y=diff(dy);
ode = collect((1+x^2)*d2y+x*dy-y,x)
c=coeffs(ode,x)
cx0=c(1);
cx1=c(2);
a0=strcat(char(subs(y,x,0)),'=2');
a1=strcat(char(subs(dy,x,0)),'=3');
[a0 a1 a2 a3 ] = solve(a0,a1,cx0,cx1)
solution=subs(y)
fplot(char(solution),[-4 4],'r--')
OUTPUT:
Given equation: ( 1+x^2)y"+x*y -y=0 with y(0)=2 and dy(0)=3
a0 =2 ; a1 =3 ; a2 =1 ; a3 =0
GRAPH:
30
25
20
15
10
-5
-4 -3 -2 -1 0 1 2 3 4
ASSIGNMENT-4:
CODING:
clear all
clc
syms A B x m
p=input('Enter the coefficients a , b , c :');
X = input( 'Enter the RHS function f(x):');
a = p(1);
b = p(2);
c = p(3);
d = b^2 - 4*a*c;
m = subs(solve('a*m^2+b*m+c'));
if(d>0)
CF=A*exp(m(1)*x) +B*exp(m(2)*x);
y1= exp(m(1)*x);
y2=exp(m(2)*x);
elseif(d == 0)
CF = (A + B *x) *exp(m(1)*x);
y1=exp(m(1)*x);
y2=x*exp(m(1)*x);
else alfa=real(m(1));
beta=imag(m(1));
CF=exp(alfa*x)*(A*cos(beta*x)+B*sin(beta*x));
y1=exp(alfa*x)*cos(beta*x);
y2= exp(alfa*x)*sin(beta*x);
end
W=y1*diff(y2,x)-y2*diff(y1,x);
u=int(-y2*X/W,x);
v=int(y1*X/W,x);
PI=u*y1+v*y2;
y=CF+PI;
dy=diff(y);
cond=input('Enter the initial conditions x0,y(x0) and
Dy(x0) : ');
eq1=(subs(y,x,cond(1))-cond(2));
eq2=(subs(dy,x,cond(1))-cond(3));
[A B]=solve(eq1, eq2);
Y=subs(CF+PI)
OUTPUT:
Enter the coefficients a , b , c : [1 -3 2]
CODING:
Clc
clear all
eqn=input('Enter the equation: ');
cond=input('Enter the conditions: ');
y=dsolve(eqn,cond,'x');
soln=['y(x)=', char(simplify(y))];
disp(soln)
ezplot(y)
GRAPH:
5
x 10 exp(-2 x) + sin(x) + 3 x exp(-2 x) +...- 2 x sin(x)
-0.5
-1
-1.5
-2
-2.5
-3
-3.5
-6 -4 -2 0 2 4 6
x
ASSIGNMENT-5 ( B ):
Solve Y"-3Y'+2Y=0 WITH Y(0)=1 AND Y'(0)=-1,using Laplace
transform
CODING:
clc
clear all
syms t s LOFY
y2 = diff(sym('y(t)'),2);
y1 = diff(sym('y(t)'), 1);
y0 = sym('y(t)');
LTY=laplace(y2 - 3*y1 +2*y0);
LTY=subs(LTY,{'laplace(y(t),t,s)','y(0)','D(y)(0)'},
{LOFY, 1,-1});
eq=collect(LTY,LOFY);
LOFY=simplify(solve(eq,LOFY))
Y=simplify(ilaplace(LOFY))
ezplot(Y)
OUTPUT:
LOFY = (s - 4)/(s^2 - 3*s + 2)
Y = - exp(t)*(2*exp(t) - 3)
GRAPH:
4
x 10 -exp(t) (2 exp(t) - 3)
-1
-2
-3
-4
-5
-6
-4 -2 0 2 4 6
t