Maple/Laplace Transforms

From PrattWiki
Revision as of 03:09, 16 March 2009 by DukeEgr93 (talk | contribs)
Jump to navigation Jump to search

Maple does not know how to do Laplace transforms ``out of the box, but like so many entities, it can be taught. The inttrans package for Maple contains algorithms for performing many useful functions, including forward and inverse Laplace transforms. To load it, simply type

with(inttrans)

into your worksheet. The list of new commands will show up. If you want to load the commands without seeing them, simply put a colon at the end of the

with(inttrans)

line. This is generally true for Maple - the colon at the end will suppress display of the result. Note also that Maple does understand the unit step function natively - it calls it Heaviside(t).

Basic Laplace and Inverse Laplace Transforms

The forward and inverse Laplace transform commands are simply laplace and invlaplace. They take three arguments - the item to be transformed, the original variable, and the transformed variable. For Laplace transforms, the second and third arguments will typically be t and s, respectively. Conversely, for invlaplace, the second and third arguments will be s and t, respectively.

For example, to get the Laplace Transform of what Dr. G refers to as the Mother Of All Transforms, that is,

\( \mathcal{L}\left\{ e^{-at}\left(A\cos(\omega t)+B\sin(\omega t)\right) \right\} \)

you could add:

MOAT:=exp(-a*t)*(A*cos(omega*t)+B*sin(omega*t));
MOATLAP:=laplace(MOAT, t, s)

which returns:

\( {\it MOATLAP} := {\frac {As+Aa+B\omega}{ \left( s+a \right) ^{2}+{\omega}^{2}}} \)

To find the inverse Laplace of:

\( \mathcal{H}(s)=\frac{e^{-s}}{\left(s+a\right)^2}-\frac{s}{s+a} \)

you could type:

H:=exp(-s)/(s+a)^2-s/(s+a);
h:=invlaplace(H, s, t)

again being careful to note when Maple automatically adds subscripts, superscripts, and fractional parts for you. Maple returns:

\( h:={\it Heaviside} \left( t-1 \right) \left( t-1 \right) {e^{-a \left( t -1 \right) }}-{\it Dirac} \left( t \right) +a{e^{-at}} \)

which has two new functions in it - Heaviside and Dirac. Heaviside is Maple's unit step function and Direc is Maple's Dirac delta function - i.e. the impulse. The expression above, then, could also be written as:

\( h:=(t-1)e^{-a(t-1)}u(t-1)-\delta(t)+ae^{-at}u(t)\,\! \)

where the final u(t) is implied due to Maple's using the unilateral Laplace transform. Notice the time shift in the first term of the result - this is a function of the exponential in the Laplace version.

It is critical to note that Maple performs the unilateral Laplace transform. To prove this, note that the following three lines:

X1 := laplace(Heaviside(t-2), t, s);
X2 := laplace(Heaviside(t),   t, s);
X3 := laplace(Heaviside(t+2), t, s);

will yield

\( \begin{align} {\it X1}&:={\frac {{e^{-2\,s}}}{s}}\\ {\it X2}&:={\frac {1}{s}}\\ {\it X3}&:={\frac {1}{s}} \end{align} \)

and notice that the results of the latter two commands are the same. The step function u(t+2) is one starting at time t=-2, but the unilateral Laplace transform only looks at the signal starting at time 0, so it might as well be u(t).

For more proof - and more insight to the unilateral Laplace transform - note that the following code:

x1:=invlaplace(laplace(Heaviside(t-2), t, s), s, tau);
x2:=invlaplace(laplace(Heaviside(t),   t, s), s, tau);
x3:=invlaplace(laplace(Heaviside(t+2), t, s), s, tau)

yields:

\( \begin{align} {\it x1}&:={\it Heaviside} \left( \tau-2 \right)\\ {\it x2}&:=1\\ {\it x3}&:=1 \end{align} \)

where \(\tau\) here is being used to clearly indicate the different between the original time variable and the time variable used by the inverse transform.