kill(all)$

appendix:How to find :inverse laplace transform(=ilt)
peter.vlasschaert@gmail.com,31/07/2019

load packages
----------------------

load(lrats);

calculation inverse laplace transform
============================
suppose :  t  >  0

p1:f(t) = (1/(A))*'integrate(F(s)*exp(s*t),s,γ-%i*∞,γ+%i*∞);

p1a:A=2*π*%i;

f(t) : contour integration: infinite vertical line s=x+i*y (complex plane)
==========================================================
x : x= γ  ( = to right of all  singularities ( = poles of F(s)))
y :  - ∞ < y < ∞
--------------------------------------------------------------------------------------------------------
result : all poles are to right for the closed contour ( counter-clockwise,inside)
rem : zero contribution along large arc in the left hand s-plane (radius → ∞)
---------------------------------------------------------------------------------------------------------

m =residue theorema : complex variale theory
================================

p2: B= rhs(p1a);

p2a:C="all poles to right infinite complex vetical line,total =n";

p2b:C[i] ="residue of the integrand @ isolated poles by the contour";

p2a:m = subst([p2],B*sum(C[i],i,1,n));

definition : f(t)
=======

p2c:lhs(p1) =subst([p1a],rhs(p2a)/rhs(p1a));

example : cos(at)
=============
Menu : Calculus : 

1e) Maxima : Laplace Transform
-------------------------------------------------
=>  s domain ( = frequency domain),complex

assume(a>0);

p3:cos(a*t);

p3a:laplace(p3,t,s);

2e) Maxima : inverse Laplace Transform
-------------------------------------------------
=>  t domain ( = time domain),   real

p3b:ilt(p3a,s,t);

p3c:exponentialize(p3b);

other method: ilt
=============

p4:args(p3a);

p4a:p4[1];
p4b:p4[2];

1e) poles :s/(s^2+a^2)
=================

p5:gfactor(p4[2]);

p5a:solve(p4b=0,s);

p5a1:p5a[1];
p5a2:p5a[2];

result : two poles

2e) find laurent series 
=================

a)  first pole
----------------

p6:taylor(s/(s^2+a^2),  s,rhs(p5a1),4);

p6a:args(p6);

p6b:p6a[1];

s0? :coef*(s-(-ia))^(-1), maxima : 'residue' : find coef: 1/2
---------------------------------------------------------------------
term laurent series :(s-s0)^(-1)

p7:p3a;

p7a:residue(p3a,s,-rhs(p5a1));

b)  second pole
----------------------

p8:taylor(s/(s^2+a^2),  s,rhs(p5a2),6);

p8a:args(p8);

p8b:p8a[1];

s0? :coef*(s-ia))^(-1), maxima : 'residue' : find coef: 1/2
---------------------------------------------------------------------
term laurent series :(s-s0)^(-1)

p8:p3a;

p8a:residue(p3a,s,-rhs(p5a2));

3e) How to check: F(s)
-------------------------------
(s-s0)^(-1)  :taylor (first pole) +taylor(second pole)

p9:p6b+p8b;
p9a:ratsimp(p9);

4e)  laplace:  {p6b,p8b}
--------------------------------

maxima, 'ilt command for every pole'

p10a:ilt(p6b,s,t);
p10b:ilt(p8b,s,t);

p10:p10a+p10b;

use :combine

p10c:combine(p10);

use : exponentials -> trignometric

p10d:rectform(p10c);

p10e:p10c,demoivre;

check : p10d ? p3
==============

p10e:is(p10d=p3);

p11:p3a;

p11a:gfactor(p3a);

p11b:partfrac(p11a,s);

answer 'partfrac ':=> complex poles => gfactor => partfrac
============================================

rem :doesn't works
--------------------------

p11c:partfrac(p11,s);

given :
====

residue and the residuo theorem
========================

example 1:
--------------

p12a:f(z) =z^2/((z-2)*(z^2+1));

p12a:lhs(p12a)=gfactor(rhs(p12a));

p12a1:part(rhs(p12a),2);

poles :f(z)
========

p13:solve(p12a1 = 0,z);

p13a1:p13[1];
p13a2:p13[2];
p13a3:p13[3];

use :residues:z=-%i,z=%i,z=2
=======================

p14a1:residue(rhs(p12a),z,rhs(p13a1));
p14a2:residue(rhs(p12a),z,rhs(p13a2));
p14a3:residue(rhs(p12a),z,rhs(p13a3));

rt(z):=combine(realpart(z)+%i*imagpart(z));

p14b1:rt(p14a1);
p14b2:rt(p14a2);
p14b3:rt(p14a3);

example 2:
--------------

p15a:f(z) =z*exp(z*t)/((z-3)^2);

p15a1:residue(rhs(p15a),z,3);

find :coef :(z-3)^(-1) : 

p15a2:taylor(rhs(p15a),z,3,3);

p15a3:ratcoef(p15a2,(z-3)^(-1) );

p15a4:expand(p15a3);

check :result
------------------

p15a5:is(p15a1=p15a4);

contour integration (closed contour around the poles)
========================================

residue theorem
-----------------------

f(z),around enclosed : contour
-----------------------------------------
k:      number of poles
C[i] : residues of the poles

p16:'integrate(f(z),z) = 2*π*%i*sum(C[i],i,1,k);

example:
------------

p17:f(z)=exp(z)/((z-1)*(z+3)^2);

C  : closed contour (abs(z) =4),circle , enclose : ' pole , z=1,z=-3'

poles
=====

simple pole :  z=1
double pole :  z=-3

closed contour = abs(z) =2
k=2

p18a:subst([p17,k=2],p16),simpsum;

p18b:lhs(p18a)=gfactor(rhs(p18a));

pole :z=1
=======

p19a1:C[1] =residue(rhs(p17),z,1);

pole :z=-3
=======

p19a2:C[2] =residue(rhs(p17),z,-3);

final result : p18b
===========================
z=abs(4),circle enclosed both poles
use : p19a1,p19a2
===========================

p20:subst([p19a1,p19a2],p18b);

when : abs(z) = 4

p20a:lhs(p20) = ratsimp(rhs(p20));

inverse laplace transform:
====================

example (1):inverse laplace transform 
-----------------------------------------------------

p21a:f1(s) = 1/(s-a);
p21b:f(s)=subst([p21a],exp(s*t)*f1(s));

calculation : residue
----------------------------

p21c:residue(rhs(p21b),s,a);

example (2):inverse laplace transform 
-----------------------------------------------------

p22a:f2(s) =s/(s^2+a^2);
p22b:f(s)=subst([p22a],exp(s*t)*f2(s));

find poles : p22a
=============

p22c:args(p22a);

p22d:args(p22c[2]);

p22e:solve(p22d[2],s);

p22e1:p22e[1];
p22e2:p22e[2];

result : use p2c,two poles , n=2

find :f(t)
======

p23:p2c;

p23a:subst([n=2],p23),simpsum;

calculation (residues) = C[i]
-------------------------------------

p23a1:C[1] =residue(rhs(p22b),s,rhs(p22e1));
p23a2:C[2] =residue(rhs(p22b),s,rhs(p22e2));

p23a3:subst([p23a1,p23a2],p23a);

p23a4:lhs(p23a3)=rectform(rhs(p23a3));