Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Computational Methods For Mechanical

Engineers

Assignment on Differential Equations

Sem 1st
ME – IC Engine and Automobile

Name Roll No Enrollment no


Gohil Jayrajsinh A. 711115 180280711006
Jay Prajapati B. 711105 180280711015
Jay Panchal 711103 180280711013
Jay Prajapati P 711107 180280711016
Kirad Saurabh 711104 180280711009
Chapter 1 First Order Differential Equations

1.1 Basic Concepts : Modeling


If we want to solve an engineering problem (usually of a physical nature), we first have to
formulate the problem as a mathematical expression in terms of variables, functions, and
equations. Such an expression is known as a mathematical model of the given problem. The
process of setting up a model, solving it mathematically, and interpreting the result in
physical or other terms is called mathematical modeling or, briefly, modelling
.
Now many physical concepts, such as velocity and acceleration, are derivatives. Hence a
model is very often an equation containing derivatives of an unknown function. Such a model
is called a differential equation. Of course, we then want to find a solution (a function that
satisfies the equation), explore its properties, graph it, find values of it, and interpret it in
physical terms so that we can understand the behavior of the physical system in our given
problem.

Fig 1.1 Modelling


An ordinary differential equation (ODE) is an equation that contains one or several
derivatives of an unknown function, which we usually call y(x) (or sometimes y(t) if the
independent variable is time t). The equation may also contain y itself, known functions
of x (or t), and constants. For example,

The term ordinary distinguishes them from partial differential equations (PDEs), which
involve partial derivatives of an unknown function of two or more variables. For instance, a
PDE with unknown function u of two variables x and y is

An ODE is said to be of order n if the nth derivative of the unknown function y is the highest
derivative of y in the equation. The concept of order gives a useful classification into ODEs
of first order, second order, and so on.

In this chapter we shall consider first-order ODEs. Such equations contain only the first
derivative and may contain y and any given functions of x. Hence we can write them as
F(x,y,y')= 0

Or

y' = f(x,y)

Concept of Solution

A function
y = h(x)
is called a solution of a given ODE on some open interval a<x<b if h(x) is defined and
differentiable throughout the interval and is such that the equation becomes an identity if y
and y' are replaced with h and , respectively. The curve (the graph) of
h is called a solution curve.
Initial value problems and Boundry value problems
In most cases the unique solution of a given problem, hence a particular solution, is obtained
from a general solution by an initial condition y(x0)=y0 with given values x0 and y0 , that is
used to determine a value of the arbitrary constant c. Geometrically this condition means that
the solution curve should pass through the point ( x0, y0 ) in the xy-plane. An ODE, together
with an initial condition, is called an initial value problem. Thus, if the ODE is explicit
y' = f(x,y) , the initial value problem is of the form

y' = f(x,y) , y(x0)=y0


And if the boundry conditions are given the problem is boundry value problem.

Geometric Meaning of y' = f(x,y)


A first order ODE,
y' = f(x,y)

has a simple geometric interpretation. From calculus you know that the derivative y'(x) of
y(x) is the slope of y(x) . Hence a solution curve of eq. that passes through a point ( x0, y0 )
must have, at that point, the slope y'(x0) equal to the value of f at that point; that is,

y'(x0) = f( x0, y0 )
Using this fact, we can develop graphic or numeric methods for obtaining approximate
solutions of ODEs. This will lead to a better conceptual understanding of an ODE .
Moreover, such methods are of practical importance since many ODEs have complicated
solution formulas or no solution formulas at all, whereby numeric methods are needed.

1.2 Methods for solving First Order ODEs


(1) Separable ODEs
Many practically useful ODEs can be reduced to the form

by purely algebraic manipulations. Then we can integrate on both sides with respect to x,
obtaining
Thus
If f and g are continuous functions, the integrals in eq. exist, and by evaluating them we
obtain a general solution of ode. This method of solving ODEs is called the method of
separating variables, and first equation is called a separable equation, because in the last
equation the variables are now separated: x appears only on the right and y only on the left.

(2) Exact Differential Equations:


We recall from calculus that if a function u(x,y) has continuous partial derivatives, its
differential (also called its total differential) is

From this it follows that if u(x,y) = c = const. Then du = 0 .


A first order ODE written as,

....(1)
is called an exact differential equation if the differential form M(x,y)dx + N(x,y)dy
is exact, that is, this form is the differential

....(2)
of some function u(x,y) . Then (1) can be written
du = 0
By integration we immediately obtain the general solution of (1) in the form
u(x,y) = c .....(3)
Comparing (1) and (2), we see that (1) is an exact differential equation if there is some
function u(x,y) such that

...(4)
From this we can derive a formula for checking whether (1) is exact or not, as follows.
Let M and N be continuous and have continuous first partial derivatives in a region in
the xy-plane whose boundary is a closed curve without self-intersections. Then by partial
differentiation of (4)
By the assumption of continuity the two second partial derivaties are equal. Thus

This condition is not only necessary but also sufficient for (1) to be an exact differential
equation. If (1) is exact, the function u(x,y) can be found by inspection or in the following
systematic way. From (4a) we have by integration with respect to x

in this integration, y is to be regarded as a constant, and k(y) plays the role of a “constant”
of integration. Formula (6) was obtained from (4a). Instead of (4a) we may equally well use
(4b). Then, instead of (6), we first have by integration with respect to y

Integrating Factors
Consider the equation w = 0. Even if w is not exact, there may be a function I(x, y) such that
Iw is exact. So w = 0 can be solved by multiplying both sides by I. The function I is called an
integrating factor for the equation w = 0.

(3) Linear ODEs, Bernoulli Equation:


Linear ODEs or ODEs that can be transformed to linear form are models of various
phenomena, for instance, in physics, biology, population dynamics, and ecology, as we
shall see. A first-order ODE is said to be linear if it can be brought into the form
by algebra, and nonlinear if it cannot be brought into this form. The defining feature of the
linear ODE (1) is that it is linear in both the unknown function y and its derivative y'= dy/dx
whereas p and r may be any given functions of x. If in an application the independent variable
is time, we write t instead of x. So these type of ODEs can be solved by multiplying them
with the integrating factors. In this case integrating factor will be

Bernoulli Equation
The Bernoulli equation is given by

Let z = y1-n Then

Giving us

Which is linear in z.

(4) Substitution to Reduce Second Order Equations to First Order :


A second order ode has the form

F(y'', y', y, x) = 0.
If it is independent of y, namely, F(y'', y', x) = 0, then it is really just a first order equation for
y' as we saw in earlier examples.

Consider now the case where it is independent of x, namely, F(y'', y', y,) = 0.
Substitute v = dy/dx for x, i.e., eliminate x between the equations F(y'', y', y,) = 0 and v =
dy/dx .
This is a first order equation in v and y.

(5) Numerical Sollution by Euler’s Method :


Although it is not always possible to find an analytical solution of y' = f(x,y) for y = y(x), it is
always possible to determine a unique numerical solution given an initial value y(x0) = y0,
and provided f (x, y) is a well-behaved function. The differential equation gives us the slope f
(x0, y0) of the tangent line to the solution curve y = y(x) at the point (x0, y0). With a small
step size Δx = x1 – x0, the initial condition (x0, y0) can be marched forward to (x1, y1) along
the tangent line using Euler’s method
y1 = y0 + Δx f(x0, y0).

This solution (x1, y1) then becomes the new initial condition and is marched forward
to (x2, y2) along a newly determined tangent line with slope given by f(x1, y1).
For small enough Δx, the numerical solution converges to the exact solution.

Fig 1.2 Euler’s method


1.3 Orthogonal Trajectories:

An important type of problem in physics or geometry is to find a family of curves that


intersects a given family of curves at right angles. The new curves are called orthogonal
trajectories of the given curves (and conversely). Examples are curves of equal temperature
(isotherms) and curves of heat flow, curves of equal altitude (contour lines) on a map and
curves of steepest descent on that map, curves of equal potential (equipotential curves, curves
of equal voltages) and curves of electric force . Here the angle of intersection between two
curves is defined to be the angle between the tangents of the curves at the intersection point.
Orthogonal is another word for perpendicular.

In many cases orthogonal trajectories can be found using ODEs. In general, if we consider
G(x,y,c) = 0 to be a given family of curves in the xy-plane, then each value of c gives a
particular curve. Since c is one parameter, such a family is called a one parameter family of
curves.
In detail, let us explain this method by a family of ellipses

...(1)
and illustrated in Fig 1.3. We assume that this family of ellipses represents electric
equipotential curves between the two black ellipses (equipotential surfaces between two
elliptic cylinders in space, of which Fig.1.3 shows a cross-section). We seek the orthogonal
trajectories, the curves of electric force. Equation (1) is a one-parameter family with
parameter c. Each value of c corresponds to one of these ellipses.

Step 1. Find an ODE for which the given family is a general solution. Of course, this
ODE must no longer contain the parameter c. Differentiating (1), we have x + 2yy' = 0
Hence the ODE of the given curves is

....(2)
Step 2. Find an ODE for the orthogonal trajectories .This ODE is

...(3)
Fig 1.3 Electrostatic field between two ellipses (elliptic cylinders in space):
Elliptic equipotential curves (equipotential surfaces) and orthogonal
trajectories (parabolas)

with the same f as in (2). Why? Well, a given curve passing through a point (x0 , y0) has
slope f(x0 , y0) at that point, by (2). The trajectory through (x0 , y0) has slope -1/f(x0 , y0)
by (3). The product of these slopes is -1, as we see. From calculus it is known that this
is the condition for orthogonality (perpendicularity) of two straight lines (the tangents at
(x0 , y0)), hence of the curve and its orthogonal trajectory at (x0 , y0) .

Step 3. Solve (3) by separating variables, integrating, and taking exponents:

This is the family of orthogonal trajectories, the quadratic parabolas along which electrons
or other charged particles (of very small mass) would move in the electric field between
the black ellipses (elliptic cylinders).
Example (1)
dy/dx= 6y2x y(1)=1/25
y−2dy=6xdx
∫y−2dy=∫6xdx
−1y=3x2+c
−1/1/25=3(1)2+c c=−28
−1y=3x2−28
y(x)=1/28−3x2

Example (2)

y′=3x2+4x−4/2y−4 y(1)=3

(2y−4)dy=(3x2+4x−4)dx

∫(2y−4)dy=∫(3x2+4x−4)dx

y2−4y=x3+2x2−4x+c

(3)2−4(3)=(1)3+2(1)2−4(1)+c c=−2

y2−4y=x3+2x2−4x−2

y2−4y−(x3+2x2−4x−2)=0
Example (3)

y′=xy3/√1+x2 y(0)=−1

y−3dy=x(1+x2)−1/2dx

∫y−3dy=∫x(1+x2)−12dx

−1/2y2=√1+x2+c

−1/2=√1+c c=−3/2

−1/2y2=√1+x2−32

Exmple (4)

2xy−9x2+(2y+x2+1)dy/dx=0, y(0)=−3

M=2xy−9x2 My=2x

N=2y+x2+1 Nx=2x

f=∫Mdx OR f=∫Ndy

F(x,y)=∫2xy−9x2dx=

x2y−3x3+h(y)

Fy=x2+h′(y)=

2y+x2+1=N

h′(y)=2y+1

h(y)=∫2y+1dy=y2+y+k

F(x,y)=x2y−3x3+y2+y+k=c
y2+(x2+1)y−3x3+k=c

y2+(x2+1)y−3x3=c−k

y2+(x2+1)y−3x3=c

(−3)2+(0+1)(−3)−3(0)3=c ⇒c=6

y2+(x2+1)y−3x3−6=0

Example (5)

2xy2+4=2(3−x2y)y’ y(−1)=8

2xy2+4−2(3−x2y)y′=0

2xy2+4+2(x2y−3)y′=0

M=2xy2+4 My=4xy

N=2x2y−6 Nx=4xy

F(x,y)=∫2x2y−6dy=x2y2−6y+h(x)

Fx=2xy2+h′(x) =2xy2+4=M

h′(x)=4⇒h(x)=4x

F(x,y)=x2y2−6y+4x

x2y2−6y+4x=c

64−48−4=c c=12

x2y2−6y+4x−12=0
Example (6)

3y3e3xy−1+(2ye3xy+3xy2e3xy)y′=0 y(0)=1
M=3y3e3xy−1 My=9y2e3xy+9xy3e3xy

N=2ye3xy+3xy2e3xy Nx=9y2e3xy+9xy3e3xy

F(x,y)=∫3y3e3xy−1dx=y2e3xy−x+h(y)

Fy=2ye3xy+3xy2e3xy+h′(y)=2ye3xy+3xy2e3xy=N

h′(y)=0⇒h(y)=0

h(y)=0

F(x,y)=y2e3xy−x

y2e3xy−x=c

1=c

y2e3xy−x=1

Example(7)

y′+4xy=x3y2 y(2)=−1,x>0

y−2y′+4xy−1=x3

v=y−1v′=−y−2y

−v′+4xv=x3

v′−4xv=−x3 ⇒μ(x)=e∫−4xdx=e−4ln|x|=x−4

∫(x−4v)′dx=∫−x−1dx

x−4v=−ln|x|+c ⇒v(x)=cx4−x4lnx
y−1=x4(c−lnx)

−1)−1=c24−24ln2 ⇒c=ln2−1/16

Example(8)

y′=e−y(2x−4) y(5)=0

eydy=(2x−4)dx

∫eydy=∫(2x−4)dx

ey=x2−4x+c

1=25−20+c c=−41.ey=x2−4x−4

y(x)=ln(x2−4x−4)

Example (9)

xyy′+4x2+y2=0y(2)=−7,x>0

y/xy′=−4−y2/x2=−4−(y/x)2

v(v+xv′)=−4−v2

vxv′=−4−2v2

xv′=−4+2v2 /v

v/4+2v2dv=−1/xdx

1/4ln(4+2v2)=−ln(x)+c
ln(4+2v2)14=ln(x)−1+c

(4+2v2)14=eln(x)−1+c=eceln(x)−1=c/x

4+2v2=c4/ x4=c/x4

v2=1/2(c/x4−4)

y2x2=1/2(c−4x4 / x4)

y2=1/2x2(c−4x4/x4)=c−4x4/2x2

49=c−4(16)/2(4) ⇒c=456

y2=228−2x4/x2

Example(10)

Dr/dθ=r2/θ r(1)=2

1/r2dr=1/θdθ

∫/1r2dr=∫1/θdθ

−1/r=ln|θ|+c

−1/2=ln(1)+c c=−1/2

−1/r=ln|θ|−1/2

r=1/1/2−ln|θ|
1/2−ln|θ|=0

ln|θ|=1/2

|θ|=e1/2

MATLAB PROGRAMS
EXAMPLE (1)

dy1/ dt = y2 y1(0) = 0

dy2 dt =1000(1- y12 )y2- y1 y2 (0) =1

function dydt = osc(t,y)

dydt = zeros(2,1);

dydt(1) = y(2);

dydt(2) = 1000*(1 - y(1)^2)*y(2) - y(1);

end

EXAMPLE(2)

Xdy/dx+2y=x3

clc;clear all;clf

ode1=@(x,y)(x^3-2*y)/x

[x,y]=ode45(ode1,[1:0.01:3],4.2);
plot(x,y,'Linewidth',2) xlabel('x'),ylabel('y'),grid on

title('Solution to ODE dy/dx = (x^3-2y)/x')

Fig 1.4 Solution to ODE dy/dx = (x^3-2y)/x'


Chapter 2:- Second Order Differential
Equations

2.1 Basic Concepts : Modeling

If we want to solve an engineering problem (usually of a physical nature), we


first have to formulate the problem as a mathematical expression in terms of
variables, functions, and equations. Such an expression is known as a
mathematical model of the given problem. The process of setting up a model,
solving it mathematically, and interpreting the result in physical or other terms
is called mathematical modeling or, briefly, modelling
.
Now many physical concepts, such as velocity and acceleration, are derivatives.
Hence a model is very often an equation containing derivatives of an unknown
function. Such a model is called a differential equation. Of course, we then
want to find a solution (a function that satisfies the equation), explore its
properties, graph it, find values of it, and interpret it in physical terms so that we
can understand the behavior of the physical system in our given problem.

Fig 2.1 Modelling


2.2 A second order ordinary differential equation has the
general form

y’’ = f (t, y, y′)


where f is some given function.

 This equation is said to be linear if f is linear in y and y':


Y” = g(t) − p(t) y’ − q(t) y
Otherwise the equation is said to be nonlinear.

 A second order linear equation often appears as


P(t) y”+ Q(t) y’+ R(t) y = G(t)

 If G(t) = 0 for all t, then the equation is called homogeneous.


Otherwise the equation is nonhomogeneous .

 The focus of this chapter is thus on homogeneous equations;


and in particular, those with constant coefficients:
ay’’+ by+ cy = 0

 Initial conditions typically take the form


y (t0) = y , y’(t0) = y′

 Thus solution passes through (t0, y0), and slope of solution at


(t0, y0) is equal to y0'.
2.3 Homogeneous Equations with Constant Coefficients :-

y'' + a y' + b y = 0
where a and b are real constants.

 If y

be the solution of the differential equation, m must be a solution of the


quadratic equation

characteristic equation

Since the characteristic equation is quadratic, we have two roots:

Thus, there are three possible situations for the roots of m1 and m2 of the
characteristic equation:

Case I :

m1 and m2 are distinct real roots

Case II:

0 m1 = m2 , a real double root

Case III:

m1 and m2 are two complex conjugate roots


We now discuss each case in the following:

Case I :-

Two Distinct Real Roots, m1 and m2

Since and are linearly independent, we have the


general solution

Case II:-

Real Double Roots

Since m1=m2= , y1(x) = should be the first solution of the differential


equation.

The second linearly independent solution can be obtained by the procedure of


reduction of order:

y2 = x

Thus, the general solution for this case is

y(x) = (c1+c2x)

Case III:-

Complex Conjugate Roots m1 and m2 ( )


Where and

Thus, Y1 = and Y2 = are solutions (which are complex


functions) of the differential equation, i.e.

y = C1Y1+C2Y2

therefore have the following general solution:

y= (Acos

where A and B are arbitrary constants.

2.3 Existence and Uniqueness of Solutions

 Second Order Differential Equations

Consider the initial value problem (IVP):

y'' + p(x) y' + q(x) y = 0 ……..(1)

with y(x0) =k0 , y'(x0)= k1.. ……(2)

Note that (1) is a 2nd-order, linear homogeneous differential equation.


Theorem-Existence and Uniqueness Theorem

If p(x) and q(x) are continuous functions on an open interval I and


x0 is in I, then the initial value problem, (1) and (2), has a unique
solution y(x) on the interval.

Theorem-Existence of a General Solution

If p(x) and q(x) are continuous on an open interval ,


Then y”+p(x)y’+q(x)=0 has a general solution.

Theorem-General Solution

Suppose that y”+p(x)y’+q(x)=0 has continuous coefficients p(x) and q(x) on an


open interval . Then every solution Y(x) of this equation on is of the form

Y(x)=C1y1(x)+C2y2(x)

2.4 Nonhomogeneous Linear Differential equations

 General Concepts

A general solution of the nonhomogeneous linear differential equation

y(n) + pn-1(x) y(n-1) + ... + p1(x) y' + p0(x) y = r(x)

on some interval I is a solution of the form

y(x) = yh(x) + yp(x)

where yh(x) = c1 y1(x) + ... + cn yn(x) is a solution of the homogeneous


equation

y(n) + pn-1(x) y(n-1) + ... + p1(x) y' + p0(x) y = 0


and yp(x) is a particular solution of the nonhomogeneous equation.

y”+p(x)y’+q(x)= r(x)…………………..(1)

y”+p(x)y’+q(x)= 0 …………………..(2)

Relations between solutions of (1) and (2):

 The difference of two solutions of (1) on some open interval I is a


solution of (2) on I.

 The sum of a solution of (1) on I and a solution of (2) on I is a solu-tion


of (1) on I.

 we have the following rules for the method of undetermined


coefficients:

(A) Basic Rule: If r(x) in the nonhomogeneous differential equation is


one of the functions in the first column in the following table, choose
the corresponding function yp in the second column and de-termine its
undetermined coefficients by substituting yp and its derivatives into
the nonhomogeneous equation.

(B) Modification Rule: If any term of the suggested solution yp(x) is


the solution of the corresponding homogeneous equation, multi-ply yp
by x repeatedly until no term of the product xkyp is a solu-tion of the
homogeneous equation. Then use the product xkyp to solve the
nonhomogeneous equation.

(C) Sum Rule: If r(x) is sum of functions listed in several lines of the
first column of the following table, then choose for yp the sum of the
functions in the corresponding lines of the second column.
Table for Choosing the Particular Solution

r(x) Yp(x)
Pn(x) a0 + a1 x + ... + an
Pn(x) (a0 + a1 x + ... + an )
Pn(x) sinbx (a0 + a1 x + ... + an ) sinbx
Pn(x) cosbx (a0 + a1 x + ... + an ) cosbx

where Pn(x) are polynomials in x of degree n

2.5 Method of Variation of Parameters

In this section, we shall consider a procedure for finding a par-ticular solution of


any nonhomogeneous second order linear dif-ferential equation

y”+p(x)y’+q(x)= r(x)

where p(x), q(x) and r(x) are continuous on an open interval I.

Assume that the general solution of the corresponding homoge-neous equation

y”+p(x)y’+q(x)= 0

is given yh = c1 y1 + c2 y2

where, y1 and y2 are linearly independent known functions, c1 and c2 are


arbitrary constants.

Suppose that the particular solution of the nonhomogeneous equation is of the


form

yp = u(x) y1(x) + v(x) y2(x)

This replacement of constants or parameters by variables gives the method


name "Variation of Parameters".
Notice that the assumed particular solution contains two un-known functions u
and v. The requirement that the particular so-lution satisfies the non-
homogeneous differential equation im-poses only one condition on u and v.

It seems plausible we can impose a second arbitrary condition. By


differentiating yp, we have

yp' = u' y1 + u y1' + v' y2 + v y2'

To simplify this expression, it is convenient to set

(Condition 1)

This reduces the expression for yp' to

yp' = u y1' + v y2'

Differentiating once again, we have

yp'' = u' y1' + u y1'' + v' y2' + v y2''

Putting yp'', yp' and yp into the nonhomogeneous equation and collecting terms,
we have

u (y1'' + p y1' + q y1) + v (y2'' + p y2' + q y2) + u' y1' + v' y2' = r

Since y1 and y2 are the solutions of the homogeneous equation, we have

u' y1' + v' y2' = r

(Condition 2)

This gives a second equation relating u' and v', and we have the simultaneous
equations

y1 u' + y2 v' = 0
y1' u' + y2' v' = r
which has the solution

u’= =-

v’ = =

where W = y1 y2' - y1' y2 =0 is the Wronskian of y1 and y2.

After integration, we have

u=- v=

Thus, the particular solution yp is

yp(x)= -
Examples

Example : Obtain the complementary function of eqation.


Y” – 7y’ + 6y = x^4.
Solution :
(D^2 – 7D + 6)y = x^4
Auxiliary eq : m^2 – 7m +6 = 0
m = 1, 6
the complementary function is
y = c1e^x + c2e^6x.

Example : Find the particular integral of the equation


Y” + 16y = cos3x.
Solution :
(D^2 +16)y = cos 3x
PI = (1/D^2 + 16)cos 3x
= cos 3x/7
Example: Find the general solution of y′′ − 5y′ = 0.

There is no need to “guess” an answer here. We actually know a way


to solve the equation already. Observe that if
we
let u= y′
then u′ = y‘’
Substitute them into the equation and we get a new equation:
u′ − 5u= 0
.
This is a first order linear equation with
p(t) = −5 and g(t) = 0. (!) The integrating factor is μ=e−5t.
U(t) = Ce^5t
The actual solution y is given by the relation u= y′, and can be found
by integration:
Y(t) = C1e^5t + C2.

The method used in the above example can be usedtosolve any second
order linear equation of the form y′′ + p(t) y′ = g(t),regardless whether
its coefficients are constant or nonconstant, or it is a homogeneous
equation or nonhomogeneous.

Example : Obtain the general solution of eqation of


Y” – 10y’ + 25y = 0.
Solution:
(D^2 – 10D + 25)y = 0
m^2 – 10m + 25 = 0
the roots are m = 5 , 5
general solution of the equation is
(c1 + c2x)e^5x

Example : Obtain the complementary function of the equation


Y” – 6y’ + 10y = e^3x.
Solution :
(D^2 – 6D + 10)y = e^3x
Auxiliary equation is
m^2 – 6m + 10 = 0
m=3+i or m=3–i
The comp;ementary function is given by
xy = e^3x(c1cosx + c2sinx)

Example : Solve the differential equation


Y” + 5y’ + 6y = e^-4x.
Solution:
(D^2 + 5D +6)y = e^-4x
The auxiliary equation is
m^2 + 5m + 6 = 0
(m + 3)(m + 2) = 0
The roots are m = -3 , -2
Complementary function
C1e^-3x + c2e^-2x.
Particular integral = (1 / D^2 + 5D + 6)e^-4x
Put D = -4
Hence, (e^-4x) / 2
General solution is
Y= c1e^-3x + c2e^-2x + (e^-4x/2).

Example : Solve (3D^2 – D - 10)y = 6e^2x.


Solution :
(3D^2 - D – 10)y = 6e^2x
Auxiliary equation is
3m^2 – 1m – 10 = 0
Roots are m= 2 , -5/3.
C.F. = C1e^2x + C2e^-5/3x.
Particular integral = (1/3D^2 – D – 10)6e^2x
= (1/(D-2) (3D + 5 ) )6e^2x
= 6/D – 2[ (1/3D +5)e^2x ]
= (6/(D-2) 11)e^2x
= 6/11xe^2x
The general solution is
y = c1e^2x + c2e^-5/3x + 6/11xe^2x.
Example : Solve (D^2 – 12D + 36)y = e^6x.
Solution :
Given (D^2 – 12D + 36)y = e^6x
Auxiliary equation is
m^2 – 12m + 36 = 0
roots are m = 6,6
CF = (c1 + c2x)e^6x
PI = (1/D^2 – 12D + 36)e^6x
= [1/(D – 6)^2]e^6x
= (x^2 /2)e^6x.
The general solution is y= CF+ PI
= (c1 + c2x)e^6x + (x^2/2)e^6x

Example : Find the general solution of the equation


Y” – 5y’ + 6y = sin 3x.
Solution :
m^2 - 5m +6 = 0
the roots are m= 3,2
CF = C1e^3x + C2e^2x
PI = 1/(D^2 – 5D + 6) sin 3x
Put D = -3
= 1/(-5D – 3)sin 3x
= - (5D - 3 )/(5D+3)(5D-3) .sin3x
Put D^2 = -9
= 1/-234 (3-5D).sin3x
=-1/234[3sin3x- 5Dsin3x]
PI= 15cos3x / 234 – 3sin3x/234
General solution is
CF + PI = C1e^3x + C2e^2x + 15cos3x / 234 – 3sin3x/234

Example :solve the equation y” + 16y = sin 4x


Solution:
(D^2 + 16)y = sin 4x
Auxiliary equation m^2 + 16 = 0
m = 4i or m = -4i
CF = c1cos 4x + c2 sin 4x
PI = 1/ (D^2 + 16)sin 4x
= x/2 . 4 sin 4x
=-x/8cos 4x
General solution is CF + PI
= c1cos 4x + c2 sin 4x - x/8cos 4x
Second-Order ODE with Initial Conditions
Solve this second-order differential equation with two initial
conditions.

Define the equation and conditions. The second initial condition


involves the first derivative of y. Represent the derivative by creating
the symbolic function Dy = diff(y) and then define the condition
using Dy(0)==0.

syms y(x)
Dy = diff(y);

ode = diff(y,x,2) == cos(2*x)-y;


cond1 = y(0) == 1;
cond2 = Dy(0) == 0;

Solve ode for y. Simplify the solution using the simplify function.

conds = [cond1 cond2];


ySol(x) = dsolve(ode,conds);
ySol = simplify(ySol)

ySol(x) =
1 - (8*sin(x/2)^4
Suppose we wish to solve the following boundary value problem.

Consider the equation

d2ydx2+y=0.

subject to y'(0)=1 and y(π)=0.

The exact solution is y=sin(x).

To solve this numerically, we first need to reduce the second-order


equation to a system of first-order equations,

dydx=z,dzdx=−y.

with z(0)=1 and y(π)=0.

Example code to solve this is given by

% Function to solve d^2ydx^2+y = 0.


function SimpleBVP()

solinit = bvpinit([0,pi],[0,0]);

sol = bvp4c(@deriv,@bcs,solinit);

plot(sol.x,sol.y(1,:),'b-x');
function dYdx = deriv(x,Y)

dYdx(1) = Y(2);
dYdx(2) = -Y(1);

% boundary conditions y'(a)=1, y(b)=0.


function res = bcs(ya,yb)
res = [ ya(2) - 1
yb(1)];

You might also like