Preface


This tutorial was made solely for the purpose of education and it was designed for students taking Applied Math 0330. It is primarily for students who have very little experience or have never used Mathematica before and would like to learn more of the basics for this computer algebra system. As a friendly reminder, don't forget to clear variables in use and/or the kernel.

Finally, the commands in this tutorial are all written in bold black font, while Mathematica output is in normal font. This means that you can copy and paste all commands into Mathematica, change the parameters and run them. You, as the user, are free to use the scripts for your needs to learn the Mathematica program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately.

Return to computing page for the first course APMA0330
Return to computing page for the second course APMA0340
Return to Mathematica tutorial for the second course APMA0330
Return to Mathematica tutorial for the first course APMA0340
Return to the main page for the course APMA0340
Return to the main page for the course APMA0330
Return to Part VI of the course APMA0330

ODEs with discontinuous input


We demonstrate advantages of the Laplace transform in solving differential equations with discontinuous inputs.

LaplaceTransform[
y''[t] + 5 y'[t] + 6 y[t] == UnitStep[t - 2 ], t, lambda]
Out[15]= 6 LaplaceTransform[y[t], t, lambda] +
lambda^2 LaplaceTransform[y[t], t, lambda] +
5 (lambda LaplaceTransform[y[t], t, lambda] - y[0]) - lambda y[0] -
Derivative[1][y][0] == E^(-2 lambda)/lambda
% /. {y[0] -> -1, y'[0] -> 5}
Out[16]= -5 + lambda + 6 LaplaceTransform[y[t], t, lambda] +
lambda^2 LaplaceTransform[y[t], t, lambda] +
5 (1 + lambda LaplaceTransform[y[t], t,
lambda]) == E^(-2 lambda)/lambda
Solve[%, LaplaceTransform[y[t], t, lambda]]
Out[17]= {{LaplaceTransform[y[t], t, lambda] -> -((
E^(-2 lambda) (-1 + E^(2 lambda) lambda^2))/(
lambda (6 + 5 lambda + lambda^2)))}}
InverseLaplaceTransform[%, lambda, t]
Out[18]= {{y[t] -> -(1/6) E^(-3 t) (18 -
12 E^t + (-2 E^6 - E^(3 t) + 3 E^(4 + t)) HeavisideTheta[-2 + t])}}
Plot[HeavisideTheta[t - 2], {t, 0, 6}] (* plot the unit function with discontinuities *)
L[t_, y_] := y''[t] - 5 y'[t] + 6 y[t] + HeavisideTheta[t - 1]
LaplaceTransform[L[t, y] == DiracDelta[t - 2], t, s]
Out[15]= E^-s/s + 6 LaplaceTransform[y[t], t, s] +
s^2 LaplaceTransform[y[t], t, s] -
5 (s LaplaceTransform[y[t], t, s] - y[0]) - s y[0] -
Derivative[1][y][0] == E^(-2 s)
% /. {y[0] -> -1, y'[0] -> 5}
Out[16]= -5 + E^-s/s + s + 6 LaplaceTransform[y[t], t, s] +
s^2 LaplaceTransform[y[t], t, s] -
5 (1 + s LaplaceTransform[y[t], t, s]) == E^(-2 s)
Solve[%, LaplaceTransform[y[t], t, s]]
Out[17]= {{LaplaceTransform[y[t], t, s] -> -((
E^(-2 s) (E^s - s - 10 E^(2 s) s + E^(2 s) s^2))/(
s (6 - 5 s + s^2)))}}
InverseLaplaceTransform[%, s, t]
Out[18]= {{y[t] -> -(1/( 6 E^6))(-6 E^(6 + 2 t) (-8 + 7 E^t) -
6 E^(2 t) (-E^2 + E^t) HeavisideTheta[-2 + t] +
E^3 (E - E^t)^2 (E + 2 E^t) HeavisideTheta[-1 + t])}}
v[t_] = y[t] /. %
Plot[v[t], {t, 0, 2}]

 

 

Definition of Laplace Transform

Heaviside Function

Laplace Transform of Discontinuous Functions

Table of Laplace transforms

Inverse Laplace Transform

Convolution Integral

Residue method

Solving IVPs with Laplace transform

Nonhomogeneous ODEs

ODEs with discontinuous input

Nonconstant Coefficient IVP’s

 

Return to Mathematica page

Return to the main page (APMA0330)
Return to the Part 1 (Plotting)
Return to the Part 2 (First Order ODEs)
Return to the Part 3 (Numerical Methods)
Return to the Part 4 (Second and Higher Order ODEs)
Return to the Part 5 (Series and Recurrences)
Return to the Part 6 (Laplace Transform)
Return to the Part 7 (Boundary Value Problems)