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

Ryan Krauss ryanlists at gmail.com
Tue Feb 26 18:18:26 EST 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
(see bad.png).

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://mail.scipy.org/pipermail/scipy-user/attachments/20080226/93dfcd56/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: good.png
Type: image/png
Size: 38207 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080226/93dfcd56/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bad.png
Type: image/png
Size: 26812 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080226/93dfcd56/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repeated_root_step_response.wxm
Type: application/octet-stream
Size: 600 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080226/93dfcd56/attachment.obj>


More information about the SciPy-User mailing list