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

1 Departamento de Matemática Aplicada, Centro Politécnico Superior (CPS), Universidad de Zaragoza, 50015 Zaragoza, Spain 2 Departamento de Matemática Aplicada, Escuela Técnica Superior de Ingenieros Agrónomos (ETSIA), and (IUMPA), Universidad Politécnica de Valencia, 46022 Valencia, Spain 3 Departamento de Matemática Aplicada, Escuela Técnica Superior de Ingenierı́a del Diseño (ETSID), and Instituto Universitario de Matemática Pura y Aplicada (IUMPA), Universidad Politécnica de Valencia, 46022 Valencia, Spain


Introduction
Linear differential equations L y t f t , where f is a known input and L is the nth-order linear differential operator, are easily solved when it has got constant coefficients a i , 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.

Generating periodic functions
Let us recall that a function f 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 function f 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. Simplifying the above expression and plotting the generated function, we obtain the graph that appears in Figure 1.
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.Solution 2. Having in mind the above, we just have to introduce SUBST 20 CHI 0, t, PI − 20 CHI PI, t, 2PI , t, MOD t, 2PI .

2.4
Simplifying the above expression and plotting the generated function, we obtain the graph that appears in Figure 2.
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 is a b − a -periodic function defined over R that coincides with f in a, b .

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 y p x y q x , 3.1 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, x 0 , y 0 simplifies to the explicit solution for the initial condition y y 0 at x x 0 , 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 in terms of the symbolic constants c 1 and c 2 .Analogously, DSOLVE2 BV p, q, r, x, x 0 , y 0 , x 1 , y 1 3.3 is simplified to the explicit solution for the boundary value conditions y y 0 at x x 0 , and y y 1 at x x 1 , and DSOLVE2 IV p, q, r, x, x 0 , y 0 , v 0 to the explicit solution for the initial value conditions y y 0 at x x 0 , and y v 0 at x x 0 .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.

3.5
The general integral is obtained by simplifying LINEAR1 GEN 1, f t ,t,x,c .

3.6
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 , 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.
In what concerns second-order differential equations, let us recall that the forced motion of a mass m attached to a vibrating spring with damping constant α and spring constant k is modeled by 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 of 1 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 20 cm.Find the position x t of the mass.Solution 4. In this case, the position x is set by the initial value problem where f is the 2 π-periodic depicted in Example 2.2.Thus the position x is obtained by simplifying DSOLVE2 IV 4, 20, f t , t, 0, 0, 0 .

3.10
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.

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.

Figure 4 :
Figure 4: Position of the mass.
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 f t sin t, t ∈ 0, π .2.1 Solution 1.The DERIVE program enables to introduce f by writing SUBST SIN t , t, MOD t, PI .2.2 Example 3.1.Considering as input the function f of Example 2.2, solve f t : SUBST 20 CHI 0, t, PI − 20 CHI PI, t, 2PI , t, MOD t, 2PI .