# Resolution of First- and Second-Order Linear Differential Equations with Periodic Inputs by a Computer Algebra System

Authors: M. Legua; I. Morales; L. M. Sánchez Ruiz
Journal: Mathematical Problems in Engineering
 (2008)

---

## Abstract

In signal processing, a pulse means a rapid change in the amplitude
of a signal from a baseline value to a higher or lower value, followed by a
rapid return to the baseline value. A square wave function may be viewed
as a pulse that repeats its occurrence periodically but the return to the
baseline value takes some time to happen. When these periodic functions
act as inputs in dynamic systems, the standard tool commonly used to
solve the associated initial value problem (IVP) is Laplace transform and
its inverse. We show how a computer algebra system may
also provide the solution of these IVP straight forwardly by adequately
introducing the periodic input.


---

## Body

## 1. Introduction

Linear
differential equationsL[y(t)]=f(t), where f is a known input and L is the nth-order linear differential
operator, (1.1)L=Dn+an−1(t)Dn−1+⋯+a1(t)D+a0(t),Di=didti,1≤i≤n, are easily solved when it has
got constant coefficients ai,
the roots of the homogeneous associated equation are known, and the input is an
adequate combination of exponential, cosine, sine, and polynomial functions.A different situation arises when, even the
coefficients being constants, the input is a periodic function which may fail
to be continuous or may be formed by a sequence of pulses. In this case, two
widely used methods to handle the problem are Fourier series and Laplace
transforms [1, 2]. Both methods require to
know their properties which on the other hand are highly rewarding since they
can help to solve some partial differential equations, too.The proliferation in the use of computer algebra
systems has facilitated
and fastened obtaining some of these solutions. In this note, we show how some
of them, namely DERIVE [3], may directly provide the solution of first- and
second-order differential equations in the presence of periodic inputs.


## 2. Generating Periodic Functions

Let us recall that a functionf is called periodic with period T>0, if for all x in the domain of the function f(x+T)=f(x).
Geometrically, this means that the graph of f repeats itself every T units. Periodic functions do appear in a
number of real-life situations such as alternating
currents, the motion of a pendulum, vibrations of a spring, and sound waves,
just to mention a few of them.Computer algebra systems allow an easy representation
of periodic functions since they have usually got
an implemented command which enables to find the remainder on an integer
division of two real numbers. With this goal, assume that we have a
given functionf defined in [a,b[,b>a, and is to generate
a (b−a)-periodic function, ext(f[a,b[) which repeats the values of f in successive intervals of length b−a.
Then, if DERIVE is the handy program, it will generate ext(f[a,b[) by just substituting the variable t of f(t) by a+MOD(t−a,b−a) [4]. MATHEMATICA [5] and MATLAB [6] programs enjoy similar
capabilities by means of their corresponding commands (cf. [7]).Example 2.1.
Represent theπ-periodic function f generated as a full-wave rectified sinusoid
such that (2.1)f(t)=sint,t∈[0,π[.Solution 1.
The
DERIVE program enables to introducef by writing (2.2)SUBST(SIN(t),t,MOD(t,PI)). Simplifying the above expression
and plotting the generated function, we obtain the graph that appears in Figure 1.Figure 1
Full-wave rectified sinusoid.A similar graph is obtained with MATHEMATICA by
introducing Plot(Sin(Mod(x,Pi, 0)), {x,−5,5}, PlotRange
{−1,2}), and with MATLAB
by setting, L=“sin(mod(x,pi)),” ezplot(L,[−5,5]).From now on, we will focus on DERIVE which has also
got a useful CHI(a,x,b) function that is equally to 1 in ]a,b[ and vanishes outside this
interval.Example 2.2.
Represent the2π-periodic function such that (2.3)f(t)={20,t∈[0,π[,−20,t∈[π,2π[.Solution 2.
Having
in mind the above, we just have to introduce(2.4)SUBST(20CHI(0,t,PI)−20CHI(PI,t,2PI),t,MOD(t,2PI)). Simplifying the above expression
and plotting the generated function, we obtain the graph that appears in Figure 2.Figure 2
Square wave function.Finally and for the sake of completeness, let us
recall the following result which justifies that ext(f[a,b[) is a (b−a)-periodic function which coincides with f on [a,b[.
Its easy proof follows immediately noting that if for each real number t,I(t) denotes integer part function, that is, I(t) equals the integer number n such that n≤t<n+1, then I((t−a)/(b−a))=0 for t∈[a,b[.Lemma 2.3.
Iff is a real-valued function defined over [a,b[,
then (2.5)ext(f[a,b[)=f(t−(b−a)I(t−ab−a)) is a (b−a)-periodic function defined over ℝ that coincides with f in [a,b[.


## 3. Initial Value Problems with Periodic Inputs

Let us now recall some DERIVE commands that enable to
solve first- and second-order linear differential equations. Given a linear
differential equation written in the form(3.1)y′+p(x)y=q(x), the command LINEAR1_GEN (p,q,x,y,c) provides the general solution in terms of the
symbolic constant c. The command LINEAR1 (p,q,x,y,x0,y0) simplifies to the explicit solution for the
initial condition y=y0 at x=x0,
there being other available commands for other specific kinds of differential
equations (cf. [8]).Let us also recall that DSOLVE2(p,q,r,x,c1,c2) provides the general solution of the
second-order linear differential equation (3.2)y′′+p(x)⋅y′+q(x)⋅y=r(x) in terms of the symbolic
constants c1 and c2. Analogously, (3.3)DSOLVE2_BV(p,q,r,x,x0,y0,x1,y1) is
simplified to the explicit solution for the boundary value
conditions y=y0 at x=x0,
and y=y1 at x=x1,
and DSOLVE2_IV(p,q,r,x,x0,y0,v0) to the explicit solution for the initial value
conditions y=y0 at x=x0,
and y′=v0 at x=x0.Next, we provide an example of a first- (and another
of a second-) order linear differential equation with periodic inputs and show
how the aforementioned commands can cope with periodic inputs.Example 3.1.
Considering as input the functionf of Example 2.2, solve (3.4)x′+x=f(t).Solution 3.
Let
us combine the aforementioned implemented functions with the functionf defined in Example 2.2 by  (3.5)f(t):=SUBST(20CHI(0,t,PI)−20CHI(PI,t,2PI),t,MOD(t,2PI)). The general integral is obtained
by simplifying (3.6)LINEAR1_GEN(1,f(t),t,x,c). Hence, we obtain the solution
(note that the following expression giving x is not corrupted. It is included exactly in
the way provided by the computer algebra system since it has got a long
fraction and its terms are continuously written throughout different
lines), (3.7) Making c take a finite set of values, we get the
corresponding particular solutions, for example, with the integer values
between −10 and 10, we obtain 21 particular solutions whose graphs are depicted
in Figure 3.Figure 3
Particular solutions.In what concerns second-order differential equations,
let us recall that theforced motion of a mass m attached to a vibrating spring with damping
constant α and spring constant k is modeled by (3.8)mx′′+αx′+kx=f(t), where f(t) is an external force acting upon m. When the external force is identically equal
to zero, the motion is called a free motion and it is well known that
its solution (underdamped, critically damped, or overdamped)
depends very heavily upon the nature of the characteristic roots. Next, we
solve a problem where the external force is a wave square function (see
[9, pages 336–341]).Example 3.2.
A mass of1 g is attached to the end of a spring with k=20 dyn/cm and the air resistance acts upon the
mass with a force that is 4 times its velocity at time t.
The mass has got no motion at its equilibrium position when
it is subjected to an external periodic force equal
to a square wave function of amplitude 20cm. Find the position x(t) of the mass.Solution 4.
In this case, the positionx is set by the initial value
problem (3.9)x′′+4x′+20x=f(t),x(0)=x′(0)=0, where f is the 2π-periodic depicted in Example 2.2. Thus the
position x is obtained by simplifying (3.10)DSOLVE2_IV(4,20,f(t),t,0,0,0). The solution provided by the
computer algebra system (remember that long fraction terms are continuously
written throughout different lines) is the following one, (3.11) Its graph is plotted in Figure 4.Figure 4
Position of the mass.


## 4. Conclusion

Laplace transform is an important tool classically
used to solve initial value problems in the presence of a periodic external
force. For its adequate use, properties of direct and inverse Laplace
transforms are required and they are extensively studied in many textbooks.In this paper, we have seen how DERIVE enables to
avoid this in a very simple way. This is achieved by using its standard
routines that provide the general solution of a differential equation and the
exact solution of a given initial value problem, along with the possibility of
handling periodic functions by means of its MOD command.Finally, DERIVE facilitates to plot the solution and
its evaluation at a given point if desired.



---

*Source: 654820-2008-10-16.xml*