AKSHAY Assignment - 03
AKSHAY Assignment - 03
Section:CSE*C
JUUG24BTECH20913
Assignment - 03
Examples:
x=sym('x')
x =
yy=sym('yy')
yy =
c=sym(2)
c =
d=sym(8)
d =
e=13
e =
13
syms y z d
y
y =
syms a b c x y
f=a*x^2+b*x+c
f =
syms a x
g=2*a/3+4*a/7-6.5*x+x/3+4*5/3-1.5
g =
a=sym(3); b=sym(5);
e=b/a+sqrt(2)
e =
1
c=3; d=5;
f=d/c+sqrt(2)
f =
3.0809
syms a b c x
s=sqrt(a*x^2+b*x+c)
s =
pretty(s)
2
sqrt(a x + b x + c)
syms x y
s=(x^2+5*x+6)/(x+2);
sa=simplify(s)
sa =
diff(sin(x))
ans =
diff(cos(x))
ans =
diff(tan(x))
ans =
diff(cot(x))
ans =
diff(sec(x))
ans =
diff(csc(x))
ans =
2
diff(log(x))
ans =
diff(exp(x))
ans =
diff(asin(x))
ans =
diff(acos(x))
ans =
diff(atan(x))
ans =
diff(acot(x))
ans =
diff(asec(x))
ans =
diff(acsc(x))
ans =
3
diff(sinh(x))
ans =
diff(cosh(x))
ans =
diff(tanh(x))
ans =
diff(sech(x))
ans =
diff(csch(x))
ans =
syms x
s=sin(x);
diff(s)
ans =
cos(x)
ans =
s1=cos(x)
s1 =
diff(s1)
ans =
syms x y t
s=exp(x^4)
s =
diff(s)
4
ans =
diff((1-4*x)^3)
ans =
R=5*y^2*cos(3*t)
R =
diff(R)
ans =
diff(R,t)
ans =
s=exp(x^4)
s =
diff(s,2)
ans =
diff(diff(s))
ans =
diff(R,t,2)
ans =
T=x*sin(x*t);
diff(T,x,3)
ans =
y =
28.2904
MATLAB Code:
5
syms x(t) y(t)
A = input('Coefficient Matrix');
[V, D]=eig(A);
Eigen_Values=diag(D)
Eigen_Values = 2×1
-0.8990
8.8990
Y=[x; y];
odes = diff(Y) == A*Y
odes(t) =
General_Solution =
if Eigen_Values<0 then
display('The system is stable')
else
display('The system is unstable')
end
odes(t) =
6
[xSol(t), ySol(t), zSol(t)] = dsolve(odes);
xSol(t) = simplify(xSol(t));
ySol(t) = simplify(ySol(t));
zSol(t) = simplify(zSol(t));
General_Solution=[xSol(t); ySol(t); zSol(t)]
General_Solution =
if Eigen_Values<0 then
display('The system is stable')
else
display('The system is unstable')
end
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve �′′+��′−��=�.
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
7
D3y = diff(y, t, 3);
% Define the differential equation
ode = D3y - D2y - 4*Dy + 4*y == 0;
% Define the initial conditions
conds = [y(0) == 1, subs(Dy, t, 0) == 2, subs(D2y, t, 0) == 1];
% Solve the ODE with the initial conditions
sol = dsolve(ode, conds);
% Display the solution
disp('The solution to the initial value problem is:');
Solve �′′′−��′′+��′−��=�..
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve (��−�+�)�=�..
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve (��+�)�=�.
syms y(t)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
8
Solution =
Solve (��−�+�)�=�(�)
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve (��+�)�=�.
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve (��+�)�=�+�+�.
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve �′′+��′+�=�+�.
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
9
Solve (��−�+�)�=�.
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve (��+�−�)�=�.
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve (��+�)�=�+� .
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve �′′+��=�.
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve �′′+��=�.
syms y(x)
equation=input('Enter the equation');
10
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve �′′−��′+��=�.
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Solve �′′−��′+��=�.
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
11
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
syms y(x)
equation=input('Enter the equation');
sol=dsolve(equation);
Solution=simplify(sol)
Solution =
Exercise Problems:
1. Obtain the solution for �2�2+4�=0, given that �=2 and �=0 when x=0 using MATLAB code.
12
% Define the symbolic variables
syms y(x)
% Define the differential equation
eqn = diff(y, x, 2) + 4*y == 0;
% Define the initial conditions
Dy = diff(y, x);
cond1 = y(0) == 2;
cond2 = Dy(0) == 0;
% Solve the differential equation with the initial conditions
sol = dsolve(eqn, cond1, cond2);
% Display the solution
disp(sol);
13
% Define the differential equation
eqn = diff(y, x, 2) - 2*diff(y, x) + 2*y == sin(x);
% Solve the differential equation
sol = dsolve(eqn);
% Display the solution
disp(sol);
14
disp(sol);
10. Obtain the solution for (2�+1)2 �2�2−2(2�+1)��−12�=6�+5 using MATLAB code.
15
16