0% found this document useful (0 votes)
36 views

Method of Variation of Parameters Experiment-6

Here are the solutions to the exercise problems using the method of variation of parameters: 1. y = (1/16)sin(2x) + (1/4)cos(2x) + (1/2)x 2. y = (1/2)x^2
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Method of Variation of Parameters Experiment-6

Here are the solutions to the exercise problems using the method of variation of parameters: 1. y = (1/16)sin(2x) + (1/4)cos(2x) + (1/2)x 2. y = (1/2)x^2
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Method of Variation of Parameters

Experiment-6
Title: Solution of differential Equations by the
method of variation of parameters

Aim: To find solution of an ordinary differential


equations using method of variation of parameters
Solution by method of variation of parameters:
Method of variation of parameters enables to find solution of any linear non
homogeneous differential equation of second order, provided its complimentary
function (C.F.) is given / known. The particular integral of the non-homogeneous
equation is obtained by varying the parameters, i.e. by replacing the arbitrary constants
in the C.F. by variable functions.
Consider a linear non-homogeneous second order differential equation with constant
coefficients

d2y dy
p  qy  f ( x) , where p, q are constants.
dx 2 dx
Let the complimentary function be of the form yc  C1 y1 ( x)  C2 y 2 ( x) , where C1 , C2

are arbitrary constants. This is the solution of the homogeneous equation

d2y dy
p  qy  0 .
dx 2 dx
In the method of variation of parameters, the arbitrary constants C1 , C2 are replaced with two unknown
functions u (x) and v (x ) .
Let us assume that the particular integral is of the form y p  u ( x) y1 ( x)  v( x) y 2 ( x)
y 2 ( x) f ( x) y1 ( x) f ( x)
where u ( x)    dx and v( x)   dx .

y1 y 2' y1' y 2  y1 y 2' y1' y 2
On putting the values of u (x) and v (x ) in (14), we get the particular integral y p .
Hence the required solution y ( x)  y c  y p .
MATLAB CODE
% Prog ra m for solvin g d iffe re n tia l e q ua tion of the form
% a y"+ by'+ cy= f(x), for a , b a n d c a s con sta n ts.
cle a r a ll
close a ll
clc
sym s A B x m
p = in p u t('E nte r th e coe fficie nts a , b, c');
f= in p u t('E n te r th e R H S fu nction f(x)');
a = p (1 ); b = p (2); c= p (3 );
d isc= b ^ 2 -4*a *c;
m = su b s(solve ('a *m ^ 2 + b *m + c') );
if(d isc> 0 )
C F = A*exp (m (1 )*x)+ B*e xp (m (2 )*x);
u = exp (m (1)*x); v= e xp (m (2 )*x);
e lse if (disc= = 0 )
C F = (A+ B*x)*exp(m (1 )*x);
u = e xp (m (1 )*x); v= x*exp (m (1)*x);
e lse
a lfa = re a l(m (1 ));
be ta = im a g (m (1));
C F = e xp (a lfa *x)*(A*cos(be ta *x)+ B*sin (b e ta *x));
u = e xp (a lfa *x)*cos(b e ta *x); v= exp (a lfa *x)*sin (b eta *x);
end
% Method of variation of parameters.
f1=f/a;
jac=u*diff(v,x)-diff(u,x)*v; % Jacobian of u and v
P=int(-v*f1/jac,x);
Q=int(u*f1/jac,x);
PI=P*u+Q*v;
y_ gen=CF+PI;
dy_ gen=diff(y_ gen);
cond=input('Enter the initial conditions x0, y(x0) and Dy(x0)');
eq1=(subs(y_ gen,x,cond(1))-cond(2));
eq2=(subs(dy_ gen,x,cond(1))-cond(3));
[A B]=solve(eq1,eq2);
y=subs(CF+PI)
d2y dy
Example 1: Solve the equation 5  6 y  sin 3x , y (0)  0 , y (0)  1 .
dx 2 dx

MATLAB input
Enter the coefficients a,b,c [1 -5 6]
Enter the RHS function f(x) sin(3*x)
Enter the initial conditions x0, y(x0) and Dy(x0) [0 0 1]

MATLAB output
y=
(5*cos(3*x))/78 - (16*exp(2*x))/13 + (7*exp(3*x))/6 - sin(3*x)/78
d2y w( x )
Example 2: Consider the problem of suspension cable 
dx 2 TH
 dy 
with the conditions y (0)  0 ,    0.
 dx  x 0
MATLAB code

% Program for differential equation of a suspension cable


clear all
close all
clc
syms A B x m
W =input('E nter the external load: ');
T=input('E nter the horizontal tension: ');
f=W /T;
a=1;b=0;c=0;
disc=b^2-4*a*c;
m=subs(solve('a*m^2+b*m+c') );
if(disc>0)
CF= A*exp(m(1)*x)+B*exp(m(2)*x);
u=exp(m(1)*x);v=exp(m(2)*x);
elseif (disc==0)
CF=(A+B*x)*exp(m(1)*x);
u=exp(m(1)*x);v=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));
u=exp(alfa*x)*cos(beta*x);v=exp(alfa*x)*sin(beta*x);
end
% Method of variation of parameters.
f1=f/a;
jac=u*diff(v,x)-diff(u,x)*v; % Jacobian of u and v
P=int(-v*f1/jac,x);
Q=int(u*f1/jac,x);
PI=P*u+Q*v;
y_ gen=CF+PI;
dy_ gen=diff(y_ gen);
cond=[0 0 0];
eq1=(subs(y_ gen,x,cond(1))-cond(2));
eq2=(subs(dy_ gen,x,cond(1))-cond(3));
A=solve(eq1);
B=solve(eq2);
y=subs(CF+PI)
MATLAB input
Enter the external load: 1
Enter the horizontal tension: 1

MATLAB output
y=
x^2/2
-------------------------------------------------------------------------------------------------------------
MATLAB input
Enter the external load: x
Enter the horizontal tension: 1

MATLAB output
y=
x^3/6

Exercise problems:
d2y dy 1
1. Solve the equation 2
4 4 y  sin 2 x , y ( 0 )  , y (0)  4 .
dx dx 8
d 2 y dy
2. Solve the equation 2
  6 y  x , y (0)  0 , y (0)  1 .
dx dx

You might also like