# [SciPy-user] probable bug in signal.lsim with repeated poles

Ryan Krauss ryanlists@gmail....
Tue Feb 26 17:18:26 CST 2008

```I think I have discovered a bug in lsim for systems with repeated
roots in the charactersitic equation.  The attached python file
attempts to find the step response of a second order system that is
critially damped:

TF(s) =              wn**2
--------------------------------
s**2 + 2*z*wn*s + wn**2

where z = 1.

The step response of this system based on inverse Laplace transform
(see attached wxMaxima file) should be
y(t) = -t*exp(-t)-exp(-t)+1
when wn = 1.0
signal.lsim2 comes up with the correct numeric answer (see good.png).
Using signal.lsim, no error is thrown, but the answer is quite strange

I assume this has something to do with a repeated eigenvalue in the A matrix:

In [69]: sys.A
Out[69]:
array([[-2., -1.],
[ 1.,  0.]])

In [70]: eig(sys.A)
Out[70]:
(array([-1., -1.]),
array([[-0.70710678, -0.70710678],
[ 0.70710678,  0.70710678]]))

It would be fine with me if lsim threw an error after checking for
repeated eigenvalues.  My code catches any errors thrown by lsim and
tries to run lsim2 in an except clause.  But giving a bad answer with
no errors messed me up.

Any thoughts?

Ryan
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: repeated_root_problem.py
Url: http://projects.scipy.org/pipermail/scipy-user/attachments/20080226/93dfcd56/attachment-0001.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: good.png
Type: image/png
Size: 38207 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20080226/93dfcd56/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Type: image/png
Size: 26812 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20080226/93dfcd56/attachment-0003.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repeated_root_step_response.wxm
Type: application/octet-stream
Size: 599 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20080226/93dfcd56/attachment-0001.obj
```