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

# Introduction to Laplace transform

Let f be an arbitrary (complex-valued or real-valued) function defined on the semi-infinite interval $$[0, \infty ) ;$$ then the integral

$f^L (\lambda ) = \left( {\cal L} \,f \right) (\lambda ) = \int_0^{\infty} f(t)\,e^{-\lambda t} \,{\text d} t$
is said to be the Laplace transform of f provided that the above integral converges for some value $$\lambda = s$$ of a parameter λ. Therefore, the Laplace transform of a function (if it exists) depends on a parameter λ, which could be either a real number or a complex number. Saying that a function f(t) has a Laplace transform fL means that for some λ = s, the limit
$f^L (\lambda ) = \lim_{N\to \infty} \, \int_0^{N} f(t)\,e^{-\lambda t} \,{\text d} t$
exists. From definition of integral, it follows that the Laplace transform does not depend on the values of an integrated function at a discrete number of points. Therefore, the Laplace transform can map different functions into the same output. Since application of the Laplace transformation to differential equations requires also the inverse Laplace transform, we need a class of functions that is in bijection relation with its Laplace transforms. The integral that defines the Laplace transform does not have to converge. For example, neither $${\cal L} \left[ 1/t \right]$$ nor $${\cal L} \left[ e^{t^2} \right]$$ exist. There are known some sufficient conditions guaranteeing the existence of $${\cal L} \left[ f(t) \right] .$$
Theorem: If a function f is absolutely integrable over any finite interval from $$[0, \infty ) ;$$ and the Laplace integral $$\int_0^{\infty} f(t)\,e^{-\lambda t} \,{\text d} t$$ converges for some complex number $$\lambda = s ,$$ then it converges in the half-plane $$\mbox{Re}\,\lambda > \mbox{Re}\, s ,$$ i.e., in $$\left\{ \lambda \in \mathbb{C} \, : \, \Re\, \lambda > \Re\, s \right\} .$$

Theorem: The Laplace transform is a linear operator.

Definition: A function f is said to be piecewise continuous or intermittent on a finite interval [a,b] if the interval can be divided into finitely many subintervals so that f(t) is continuous on each subinterval and approaches a finite limit at the end points of each subinterval from the interior.
Definition: The Heaviside function H(t) is the unit step function:
$H(t) = \begin{cases} 1, & \quad t > 0 , \\ 1/2, & \quad t=0, \\ 0, & \quad t < 0. \end{cases}$
The unit step function u(t) is assumed to be zero at t = 0. ■
Definition: A function $$f(t), \ t \in [0, \infty )$$ is said to be a function-original if it has a finite number of points of discontinuity (finite jumps) on every finite subinterval of $$[0, \infty )$$ and it grows not faster than an exponential, that is
$| f(t) | \le M\, e^{ct} \qquad \mbox{for} \quad t > T,$
with some constants c, M, and T. Moreover, we assume that at points of discontinuity the values of a function-original are equal to the corresponding mean values:
$f(t) = \frac{1}{2} \left[ f(t+0) + f(t-0) \right] = \lim_{\varepsilon \to 0, \ \varepsilon \ge 0} \, \frac{1}{2} \left[ f(t+\varepsilon ) + f(t-\varepsilon ) \right] .$
The Laplace transform of such a function is called the image.
Definition: We say that a function f is of exponential order if for some constants c, M, and T the inequality $$| f(t) | \le M\, e^{ct}$$ holds. We abbreviate this as $$f = O\left( e^{ct} \right)$$ or $$f \in O\left( e^{ct} \right) .$$ A function f is said to be of exponential order α, or eo(α) for abbreviation, if $$f = O\left( e^{ct} \right)$$ for any real number c > α, but not when c < α. ■
Theorem: The Laplace transform exists for a function of exponential order.
Theorem: The Laplace transform establishes a one-to-one correspondence between functions-originals and their images. ■

Although Mathematica has a built-in function HeavisideTheta (which is 1 for t > 0 and 0 for t < 0), it is convenient to define the Heaviside function directly:

HVS[t_] := Piecewise[{{0, t<0}, {1, t>0}, {1/2, t==0}}]
HVS[t_] := Piecewise[{{1, t>0}, {1/2, t==0}, {0, True}}]
However, Mathematica has UnitStep function that can also be used to redefine the Heaviside function:
Unprotect[UnitStep];
UnitStep[0] = 1/2;
Protect{UnitStep]

# Examples

Example. The Laplace transform of the unit function and the Heaviside function is the same and equals
${\cal L} \left[ 1 \right] = {\cal L} \left[ H(t) \right] = \int_0^{\infty} \,e^{-\lambda\,t} \,{\text d} t = \frac{1}{\lambda} .$
Example. We find the Laplace transform of the power function:
${\cal L} \left[ t^p \right] = \int_0^{\infty} t^p \,e^{-\lambda\,t} \,{\text d} t = \frac{1}{\lambda^{p+1}} \,\int_0^{\infty} \tau^p \,e^{-\tau} \,{\text d} \tau \frac{\Gamma (p+1)}{\lambda^{p+1}} ,$
where $$\Gamma (\nu ) = \int_0^{\infty} t^{\nu -1} \, e^{-t} \, {\text d} t$$ is the Gamma-function of Euler.
Example. The Laplace transform of the exponential function is
${\cal L} \left[ e^{at} \right] = \int_0^{\infty} e^{at} \,e^{-\lambda\,t} \,{\text d} t = \frac{1}{\lambda -a} .$
Example. To find the Laplace transform of the trigonometric functions, we recall that they are real and imaginary parts of pure imaginary exponential functions:
$\sin (at) = \Im\, e^{{\bf j} at} \qquad\mbox{and} \qquad \cos (at) = \Re\, e^{{\bf j} at} ,$
where j is the unit vector in positive vertical direction on the complex plane, so j2 = -1. Then using the previous example formula, we get
${\cal L} \left[ e^{{\bf j}at} \right] = \int_0^{\infty} e^{{\bf j}at} \,e^{-\lambda\,t} \,{\text d} t = = \frac{1}{\lambda -{\bf j}a} = \frac{\lambda +{\bf j}a}{\left( \lambda -{\bf j}a \right) \left( \lambda +{\bf j}a \right)} = \frac{\lambda +{\bf j}a}{\lambda^2 + a^2}.$
Extracting real and imaginary parts, we obtain
$\sin (at) = \Im\, e^{{\bf j} at} = \Im \, \frac{\lambda +{\bf j}a}{\lambda^2 + a^2} = \frac{a}{\lambda^2 + a^2} \qquad\mbox{and} \qquad \cos (at) = \Re\, e^{{\bf j} at} = \Re \, \frac{\lambda +{\bf j}a}{\lambda^2 + a^2} = \frac{\lambda}{\lambda^2 + a^2} .$
LaplaceTransform[t^4 Sin[t], t, lambda]
LaplaceTransform[HeavisideTheta[t - 1] t, t, lambda]
LaplaceTransform[DiracDelta[t], t, lambda]
LaplaceTransform[f''[t], t, lambda]
Out[4]= -lambda f[0] + lambda^2 LaplaceTransform[f[t], t, lambda] - Derivative[1][f][0]

LaplaceTransform[If[t > Pi, Cos[t], t], t, s]
Out[4]= (E^(-\[Pi] s) (-1 + E^(\[Pi] s) - \[Pi] s - s^3/(1 + s^2)))/s^2
LaplaceTransform[UnitStep[2 Sin[t]], t, lambda]
Out[5]= E^(\[Pi] lambda)/((1 + E^(\[Pi] lambda)) lambda)
LaplaceTransform[ArcTan[t/a], t, s, Assumptions -> a > 0]
Out[5]= (2 CosIntegral[a s] Sin[a s] + Cos[a s] (\[Pi] - 2 SinIntegral[a s]))/(2 s)
LaplaceTransform[y''[t] + 4 y[t] == 0, t, lambda]
Out[4]= 4 LaplaceTransform[y[t], t, lambda] + lambda^2 LaplaceTransform[y[t], t, lambda] - lambda y[0] - Derivative[1][y][0] == 0
% /. {y[0] -> 1, y'[0] -> 2}
Out[5]= -2 - lambda + 4 LaplaceTransform[y[t], t, lambda] + lambda^2 LaplaceTransform[y[t], t, lambda] == 0
Solve[%, LaplaceTransform[y[t], t, lambda]]
Out[6]= {{LaplaceTransform[y[t], t, lambda] -> (2 + lambda)/(4 + lambda^2)}}
InverseLaplaceTransform[%, lambda, t]
Out[7]= {{y[t] -> Cos[2 t] + Sin[2 t]}}

Now we give an example of application of the inverse Laplace transform.
InverseLaplaceTransform[4/s/(4 + s^2), s, t]
Out[8]= 4 (1/4 - 1/4 Cos[2 t])
Simplify[%]
Out[9]= 2 Sin[t]^2
Apart[4/s/(4 + s^2), s]
Out[10]= 1/s - s/(4 + s^2)
LaplaceTransform[2 Sin[t]^2, t, lambda]
Out[11]= 4/(lambda (4 + lambda^2))