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
Now we define the inverse Laplace transform using residue method, assuming that singular points are at most of
multiplicity 3. Although the residue method is widely used in complex analysis, it was adapted by Vladimir Dobrushkin
to embrace previously discussed methods: partial fraction decomposition and the convolution formula. It is applied to
the expression of the form: P(λ)/Q(λ). The output is a collection of
residues for each singular point.
where sum ranges over all zeroes of the equation \( Q(\lambda ) =0 , \) and the function
f must be multiplied by the Heaviside function to ensure that f(t) is identically zero for negative argument.
The residures at each null are evaluated according to the following rule.
Suppose that a function \( F(\lambda ) = \frac{P(\lambda )}{Q(\lambda )} \) is a ratio
of two irreducible polynomials (or entire functions). Let \( \lambda = \lambda_i , \ i=1,2,\ldots , N \)
be nulls of the denominator (\( N = \infty \) if Q(λ) is an entire function).
Recall that if \( Q(\lambda_i ) =0, Q' (\lambda_i ) =0, \ldots , Q^{(m_i -1)} (\lambda_i ) =0,
Q^{(m_i )} (\lambda_i \ne 0 , \) then we say that the denominator has zero at \( \lambda = \lambda_i \)
of multiplicity mi. In this case, we say that the function F(λ) has poles at
\( \lambda = \lambda_i , \quad i=1,2,\ldots , N . \) Note that the numerator is not zero at
these poles.
If \( \lambda = \lambda_i \) is a simple root (meaning that its multiplicity is 1)
of the equation \( Q(\lambda ) =0 , \) then
Note that if \( \lambda_i = \alpha + {\bf j} \beta \) is a complex null of the denominator
Q(λ) (the root of the polynomial equation with real coefficients \( Q(\lambda ) =0 \) ),
then \( \overline{\lambda_i} = \alpha - {\bf j} \beta \) is also a null of Q(λ).
In this case, we don't need to calculate the residue at the complex conjugate because we know that the output will be a complex conjugate
of the residue at \( \alpha + {\bf j} \beta .\)
Therefore, if the denominator Q(λ) has two complex conjugate roots
\( \lambda = \alpha \pm {\bf j} \beta , \) then the sum of residues at these points is just
double value of the real part of one of them:
s /. Solve[Q == 0] (* Finds the roots of Q(s)=0 *)
Out[3]= {-I, -I, I, I, 2, 2, 2}
Tally[%] (* Finds the number of repeats of each root (multiplicity)*)
Out[4]= {{-I, 2}, {I, 2}, {2, 3}}
MatrixForm[%] (* Creates solutions matrix with roots in one column and multiplicities in another *)
Out[5]=
(-i 2 )
( i 2 )
( 2 3 )
Dimensions[%] (* Measures the dimensions of the matrix (2x2),(3x2),(6x2), etc*)
Out[6]= {3, 2}
v = Part[%, 1] (* Finds the length of the matrix (v=number of rows) *)
Out[7]= 3
Here we start the Do loop to find residue for each root, where each row of the solutions matrix contains a root and its multiplicity
Do[T := Tally[s /. Solve[Q == 0]];
M := MatrixForm[T]; (* Recreates the solutions matrix for use in Do loop *)
r := Extract[Extract[Extract[M, 1], l], 1]; (* Extracts the root (r) from row of the matrix *)
m := Extract[Extract[Extract[M, 1], l], 2]; (* Extracts multiplicity (m) of root from row of the matrix *)
f = ((((s - r)^m) (E^(s*t)) (P))/Q);
F = Simplify[f]; (* Simplifies f into nicely factored form *)
d = (1/(m - 1)!) D[F, {s, If[m > 1, m - 1, 0]}]; (* it is the equation for residue *)
Res = d /. s -> r; (* Calculates residue at a particular root (r=root) *)
Print[Y = ComplexExpand[Re[Res], {I}]], {l, v}]
It takes the Euler expansion of previous line of code and extracts all
real parts of that expression. Final output will contain several terms,
that are functions of t, that will be the total residue when
added. Note that the Res function computes the residue for each root
by taking roots and multiplicities from row, where l ranges from
1 to v, the length of the solutions matrix.
Out[8]= -((17 Cos[t])/625)-6/125 t Cos[t]+(31 Sin[t])/625+7/500 t Sin[t] -((17 Cos[t])/625)-6/125 t Cos[t]+(31 Sin[t])/625+7/500 t Sin[t] (34 E^(2 t))/625-14/125 E^(2 t) t+3/50 E^(2 t) t^2
To check the answer, we type:
InverseLaplaceTransform[(2 s - 1)/((s^2 + 1)^2 (s - 2)^3), s, t]
Out[9]=
(1/1250)(68 E^(2 t) - 140 E^(2 t) t + 75 E^(2 t) t^2 - 68 Cos[t] -
120 t Cos[t] + 124 Sin[t] + 35 t Sin[t])