[Scipy-tickets] [SciPy] #1785: funm gives incorrect results for non-diagonalizable inputs
SciPy Trac
scipy-tickets@scipy....
Mon Dec 10 04:24:01 CST 2012
#1785: funm gives incorrect results for non-diagonalizable inputs
----------------------------+-----------------------------------------------
Reporter: mark.dickinson | Owner: pv
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: scipy.linalg | Version: 0.11.0
Keywords: |
----------------------------+-----------------------------------------------
Comment(by mark.dickinson):
Apologies for the poor formatting. Here's a cleaned up version.
I get the following results (SciPy 0.10.1):
{{{
>>> from numpy import array, exp, cos
>>> from scipy.linalg import funm, expm, cosm
>>> a = array([[2, 1], [0, 2]])
>>> expm(a)
array([[ 7.3890561, 7.3890561],
[ 0. , 7.3890561]])
>>> funm(a, exp)
Result may be inaccurate, approximate err = 1
array([[ 7.3890561, 0. ],
[ 0. , 7.3890561]])
>>> cosm(a)
array([[-0.41614684, -0.90929743],
[ 0. , -0.41614684]])
>>> funm(a, cos)
Result may be inaccurate, approximate err = 1
array([[-0.41614684, 0. ],
[ 0. , -0.41614684]])
}}}
It's a little bit unreasonable to even *expect* funm to give accurate
results for non-diagonalizable inputs, given that you're effectively
asking it to compute numerical derivatives (e.g., for a 2-by-2 Jordan
block `[[e, 1], [0, e]]` the result should be `[[f(e), fprime(e)], [0,
f(e)]]`, and for an n-by-n Jordan block the (n-1)st derivative is needed).
I see that there's a warning there that the result may be inaccurate, but
would it be worth also adding a note to the documentation to the effect
that results for matrices that are non-diagonalizable (or nearly non-
diagonalizable) are likely to be inaccurate.
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1785#comment:1>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list