Simplify the result of inverse laplace transform of a simple second order transfunction

55 views
Skip to first unread message

Ken

unread,
Dec 31, 2015, 9:42:57 PM12/31/15
to sympy
I've just started learning Sympy. I wrote a few lines of code to perform a inverse laplace transform on a simple 2nd order transfunction:

H(s) = 1 / ((s+p1) * (s+p2)).

The result I got from Sympy is

(e^(p1*t) - e^(p2*t))*e^-t*(p1+p2) / (p1 - p2)

Is there a way to simplify this result to the one like in Maxima (e^-t*p1 + e^-t*p2) / (p1-p2) ?

Christophe Bal

unread,
Jan 1, 2016, 2:46:19 AM1/1/16
to sympy-list

Hello.

Have you triez to expand 1nd then to factorize the formula ?

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/0b4a638b-b9d8-426d-99c3-12fdaf1cc973%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ken

unread,
Jan 1, 2016, 4:44:36 PM1/1/16
to sympy
Hi thanks for your reply, but I am not sure what exactly do you mean by expand "then to factorize".

I found that if I set the transfer function to be H = k / ( (s+p1) * (s+p2) ), then the inverse laplace transform becomes:

k*e^(-p1*t) / (p1-p2) + k*e^(-p2*t) / (p1-p2)

which is what I prefer. It is weird to me that adding a constant 'k' change the form that Sympy chooses to show the result.

Christophe Bal

unread,
Jan 1, 2016, 6:58:43 PM1/1/16
to sympy-list

Can you give your code ?

Ken

unread,
Jan 1, 2016, 8:28:01 PM1/1/16
to sympy
Please see the following (if you replace the '1' in hs with 'k', the resulted form will be different).

from sympy import *

init_printing()

var('k p1 p2 t', real=True, positive=True)
var('s')

hs = 1 / ( (s + p1) * (s + p2) )

ht = inverse_laplace_transform(hs, s, t)

Ken

unread,
Jan 1, 2016, 8:41:11 PM1/1/16
to sympy
It looks like it returns the same form with either '1' or 'k'...

I don't see I did anything different before.
Reply all
Reply to author
Forward
0 new messages