Solutions to Differential and Difference Equations

Verified

Added on  2020/11/09

|5
|905
|532
AI Summary
This assignment provides solutions to differential and difference equations, including MATLAB code and output for questions on solving homogeneous systems of first-order and second-order differential equations by matrix method, series solutions of ordinary differential equations, and more.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Experiment:4A
Solution of homogeneous system of first order
and second order differential equations by matrix
method
QUESTION 1:
Solve the system of differential equations y0 1 = 4y1 +
y2 , y0 2 = 3y1 + 2y2, with the initial conditions y1(0)
= 2, y2(0) = 0.
AIM:
finding solution of given differential equation with the
help of given intial conditions given
MATLAB CODE:
clc
clear all
close all
syms t c1 c2
A=input('Enter a square matrix :');
[v,d]=eig(A)
y1=c1*exp(d(1)*t)
y2=c2*exp(d(4)*t)
X=v*[y1;y2]
IC=input('Enter ICs in the
form[t0,x1(t0),x2(t0)] :');
eq1=subs(X(1),IC(1))-IC(2);
eq2=subs(X(2),IC(1))-IC(3);
[c1,c2]=solve(eq1,eq2);
X=subs(X)
Applications of Differential and Difference Equations(MAT2002)
Instructor: Dr. Aruna. KFall Semester2019-20
Department of Mathematics, School of advanced sciences

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
OUTPUT:
X =
(3*exp(5*t))/2 + exp(t)/2
(3*exp(5*t))/2 - (3*exp(t))/2
QUESTION 2 :
Solve the system of differential equation y’’1 = 2y1+y2, y’’2 =
y1+2y2, with the initial conditions y1(0) = 0,y’1(0) = 1, y2(0) =
1,y’2(0) = 0.
Document Page
AIM:
To find the functions of y1(x) and y2(x)
MATLAB CODE:
clc
clear all
close all
syms t x1(t) x2(t) Dx1(t) Dx2(t)
A=input('Enter a square matrix :');
[p,d]=eig(A);
eq1=dsolve(['D2x1=',num2str(d(1)),'*x1']);
eq2=dsolve(['D2x2=',num2str(d(4)),'*x2']);
X=[eq1;eq2]
X=p*X
OUTPUT:
X =
(2^(1/2)*(C1*exp(3^(1/2)*t) + C2*exp(-
3^(1/2)*t)))/2 - (2^(1/2)*(C2*exp(t) +
C1*exp(-t)))/2
(2^(1/2)*(C2*exp(t) + C1*exp(-t)))/2 +
(2^(1/2)*(C1*exp(3^(1/2)*t) + C2*exp(-
3^(1/2)*t)))/2
Experiment: 4B
Series solutions of ordinary differential equations
Document Page
QUESTION 1 :
Find the first five terms in the power series solution of
the differential equation y’’+ x2 * y = 0 with the initial
conditions y(0) = 1, y’(0) = 2
AIM:
To find the power series of the given differential
equations
MATLAB CODE:
clc
clear all
close all
syms x a0 a1 a2 a3 a4 a5 A B t
p=input('enter p:');
q=input('enter q:');
r=input('enter r:');
z=input('enter point:')
a = [a0 a1 a2 a3 a4 a5]
y = sum(a.*(x-z).^[0:5])
dy = diff(y)
d2y = diff(dy)
de = collect(p*d2y+q*dy+r*y,(x-z))
de=subs(de,x-z,t)
coef=coeffs(de,t);
A2=solve(coef(1),a2)
A3=solve(coef(2),a3)
A4=subs(solve(coef(3),a4),a2,A2)
A5=subs(solve(coef(4),a5),{a2,a3},{A2,A3})
y=subs(y,{a2,a3,a4,a5},{A2,A3,A4,A5})
soln=coeffs(y,[a1 a0])
gs=A*soln(1)+B*soln(2)
IC=input('Enter ICs in vector form[x y(x)
dy(x)]: ');
eq1=subs(gs,x,IC(1))-IC(2);
eq2=subs(diff(gs),x,IC(1))-IC(3);
[A B]=solve(eq1,eq2)

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
G_S=subs(gs)
OUTPUT:
G_S =
- x^5/10 - x^4/12 + 2*x + 1
1 out of 5
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]