Title: td04ad (convert tf to ss) returns incorrect poles · Issue #222 · python-control/Slycot · GitHub
Open Graph Title: td04ad (convert tf to ss) returns incorrect poles · Issue #222 · python-control/Slycot
X Title: td04ad (convert tf to ss) returns incorrect poles · Issue #222 · python-control/Slycot
Description: A bug was reported in python-control issue #935 in which tf2ss returns the incorrect poles. It looks like the underlying problem is in td04ad. The following code illustrates the bug: from numpy import array, roots, sort from numpy.linalg...
Open Graph Description: A bug was reported in python-control issue #935 in which tf2ss returns the incorrect poles. It looks like the underlying problem is in td04ad. The following code illustrates the bug: from numpy imp...
X Description: A bug was reported in python-control issue #935 in which tf2ss returns the incorrect poles. It looks like the underlying problem is in td04ad. The following code illustrates the bug: from numpy imp...
Opengraph URL: https://github.com/python-control/Slycot/issues/222
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"td04ad (convert tf to ss) returns incorrect poles","articleBody":"A bug was reported in python-control issue [#935](https://github.com/python-control/python-control/issues/935) in which `tf2ss` returns the incorrect poles.\r\n\r\nIt looks like the underlying problem is in `td04ad`. The following code illustrates the bug:\r\n```\r\nfrom numpy import array, roots, sort\r\nfrom numpy.linalg import eig\r\nfrom numpy.testing import assert_allclose\r\nfrom slycot import td04ad\r\nfrom scipy.signal import tf2ss\r\n\r\n# Test case #1 (works)\r\n\r\nnum = array([[[1, 1, 1, 1, 1]]])\r\nden = array([[1, 2, 1, 2, 1]])\r\ndenorder = np.array([den.size - 1])\r\n\r\nssout = td04ad('C', 1, 1, denorder, den, num, tol=0)\r\n\r\ntf_poles = sort(roots(den[0]))\r\nss_poles = sort(eig(ssout[1])[0])\r\nassert_allclose(tf_poles, ss_poles)\r\n\r\n# Test case #2 (doesn't work)\r\n\r\nnum = array([[[1.05351324e-02, 2.83623596e-01, 2.44891698e+00, 1.22011448e+01,\r\n 5.34846570e+01, 1.42092310e+02, 2.24627039e+02, 2.54305034e+02,\r\n 2.18224432e+02, 1.24102950e+02, 4.99448809e+01, 1.26651596e+01,\r\n 2.02239050e+00, 1.06681479e-01, 1.56212741e-03, 8.90622718e-06,\r\n 1.77205330e-08]]])\r\nden = array([[1.00000000e+00, 6.41551095e+02, 8.40213016e+03, 5.55121354e+04,\r\n 1.93428590e+05, 1.31800818e+05, 9.20183802e+04, 2.90211403e+04,\r\n 4.54824418e+03, 4.08636727e+02, 1.72367976e+01, 8.91452881e-02,\r\n 1.04426479e-04, 4.32051569e-08, 5.88752872e-12, 3.24913608e-16,\r\n 6.34764375e-21]])\r\ndenorder = np.array([den.size - 1])\r\n\r\n# Try scipy\r\nA, B, C, D = tf2ss(num[0, 0], den[0])\r\ntf_poles = sort(roots(den[0]))\r\nss_poles = sort(eig(A)[0])\r\nassert_allclose(tf_poles, ss_poles)\r\n\r\n# Now try slycot\r\nssout = td04ad('C', 1, 1, denorder, den, num, tol=0)\r\nss_poles = sort(eig(ssout[1])[0])\r\nassert_allclose(tf_poles, ss_poles)\r\n```\r\nFor the second system, the scipy-generated poles match, but some of the the slycot-generated poles are not the same (and one of them is unstable).\r\n\r\nIt's possible this is a numerical issue (the coefficients span 21 orders of magnitude!), but odd the SciPy gets it right and slycot doesn't. (SciPy uses an observable canonical form-based realization.)","author":{"url":"https://github.com/murrayrm","@type":"Person","name":"murrayrm"},"datePublished":"2023-10-22T20:09:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/222/Slycot/issues/222"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2d9769ff-0afe-4d5f-d9ae-ba05d942ea3b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C618:CCED3:1A78766:23AF5C7:697AA4A9 |
| html-safe-nonce | 58b2af974b839ab7df2219dc8b9e2db03ba5eb7b05798c5f1fb0fe737a5ab753 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjE4OkNDRUQzOjFBNzg3NjY6MjNBRjVDNzo2OTdBQTRBOSIsInZpc2l0b3JfaWQiOiI2MTU5NjI4NjE2MzQzMzk3NTQ2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e3846c3b35f80567c2e4ae9b11a575abd765516494f6a445fb829f54ff9bb750 |
| hovercard-subject-tag | issue:1956039142 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-control/Slycot/222/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f4172a8fc149ad86caac24dfc1a04b1eb7f27b1e432841d1fcc8b9623a693b19/python-control/Slycot/issues/222 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f4172a8fc149ad86caac24dfc1a04b1eb7f27b1e432841d1fcc8b9623a693b19/python-control/Slycot/issues/222 |
| og:image:alt | A bug was reported in python-control issue #935 in which tf2ss returns the incorrect poles. It looks like the underlying problem is in td04ad. The following code illustrates the bug: from numpy imp... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | murrayrm |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4d375b6c612de26fd037e0638eaf57e32cf9b16daf53ab68c25c04cd3b058113 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-control/Slycot git https://github.com/python-control/Slycot.git |
| octolytics-dimension-user_id | 2285872 |
| octolytics-dimension-user_login | python-control |
| octolytics-dimension-repository_id | 66001480 |
| octolytics-dimension-repository_nwo | python-control/Slycot |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 66001480 |
| octolytics-dimension-repository_network_root_nwo | python-control/Slycot |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9af1d97e0cdcced8d2b1d10d909b84c76e62924a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width