MATLAB: Inverse Laplace contains a complex number

Extended Symbolic Math Toolboxinverse laplaceSymbolic Math Toolbox

I am using ilaplace to study circuits. Recently I drew a schematic the inverse Laplace of which (in the time domain) has a complex number. This is new to me. Is there a way to ensure that I don't get complex numbers with an inverse Laplace? One of the terms is:
0.0876468*exp(-255.018*t)*(cos(5101.72*t)*1.0i + sin(5101.72*t))

Best Answer

Hi Karl
You show one of the terms, and I assume you have another one that is the complex conjugate that one so that the entire result is real. Here is a simple example of what is probably going on.
syms s a
F = 2*s/(s^2+a^2);
f = ilaplace(F)
f = 2*cos(a*t)
G = 1/(s+i*a) + 1/(s-i*a) % same as F, in partial fractions
g = ilaplace(G)
g = exp(-a*t*1i) + exp(a*t*1i)
( s^2 + a^2 ) has two complex roots, and ilaplace does not recombine the resulting complex expressions in G. However,
g1 = simplify(g)
g1 = 2*cos(a*t)
You can also try simplifying before doing ilaplace
G2 = simplify(G)
G2 = (2*s)/(a^2 + s^2) % same as F
g2 = ilaplace(G2)
g2 = 2*cos(a*t)