Unexpected error for asking diagonalizability

55 views
Skip to first unread message

Kwankyu

unread,
Nov 7, 2019, 4:15:42 AM11/7/19
to sage-support
Hi,

This

m = matrix(QQ, 3, [1, 1, 1, 0, 3, 3, -2, 1, 2])
m.is_diagonalizable()

raises an error rather than giving False. The error message gives an explanation why the matrix is not diagonalizable. But I think the expected result for asking diagonalizability should be either True or False, for legitimate inputs. What do you think?


 

Dima Pasechnik

unread,
Nov 7, 2019, 4:38:13 AM11/7/19
to sage-support, bee...@ups.edu
I agree. It seems that is_diagonalizable() is the only method among
is_*() for matrices
that has this strange behavior (I checked several of them, but not all).

CC'ing to the original author...

Dima

> What do you think?
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/4c3a3e63-14d7-4e49-aadb-480b6ff46a64%40googlegroups.com.

saad khalid

unread,
Nov 7, 2019, 8:33:04 PM11/7/19
to sage-support
This functionality seems to be intended somehow? At least, it is made reference to in the documentation:
Look at the part after:
"A matrix that is not diagonalizable over the rationals, as evidenced by its Jordan form."


-Saad

On Thursday, November 7, 2019 at 4:38:13 AM UTC-5, Dima Pasechnik wrote:
On Thu, Nov 7, 2019 at 9:15 AM Kwankyu <ekwa...@gmail.com> wrote:
>
> Hi,
>
> This
>
> m = matrix(QQ, 3, [1, 1, 1, 0, 3, 3, -2, 1, 2])
> m.is_diagonalizable()
>
> raises an error rather than giving False. The error message gives an explanation why the matrix is > not diagonalizable. But I think the expected result for asking diagonalizability should be either True or False, for legitimate inputs.

I agree. It seems that is_diagonalizable() is the only method among
is_*() for matrices
that has this strange behavior (I checked several of them, but not all).

CC'ing to the original author...

Dima

> What do you think?
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-s...@googlegroups.com.

Dima Pasechnik

unread,
Nov 8, 2019, 2:51:57 AM11/8/19
to sage-support
On Fri, Nov 8, 2019 at 1:33 AM saad khalid <saad...@gmail.com> wrote:
>
> This functionality seems to be intended somehow? At least, it is made reference to in the documentation:
> http://doc.sagemath.org/html/en/reference/matrices/sage/matrix/matrix2.html
> Look at the part after:
> "A matrix that is not diagonalizable over the rationals, as evidenced by its Jordan form."

the point is that it the current design does not follow the principle
of least surprise, and
all the other *.is_... methods return True/False, whereas only this
one throws, instead of returning False.

>
>
> -Saad
>
> On Thursday, November 7, 2019 at 4:38:13 AM UTC-5, Dima Pasechnik wrote:
>>
>> On Thu, Nov 7, 2019 at 9:15 AM Kwankyu <ekwa...@gmail.com> wrote:
>> >
>> > Hi,
>> >
>> > This
>> >
>> > m = matrix(QQ, 3, [1, 1, 1, 0, 3, 3, -2, 1, 2])
>> > m.is_diagonalizable()
>> >
>> > raises an error rather than giving False. The error message gives an explanation why the matrix is > not diagonalizable. But I think the expected result for asking diagonalizability should be either True or False, for legitimate inputs.
>>
>> I agree. It seems that is_diagonalizable() is the only method among
>> is_*() for matrices
>> that has this strange behavior (I checked several of them, but not all).
>>
>> CC'ing to the original author...
>>
>> Dima
>>
>> > What do you think?
>> >
>> >
>> >
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups "sage-support" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an email to sage-s...@googlegroups.com.
>> > To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/4c3a3e63-14d7-4e49-aadb-480b6ff46a64%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/8efe0856-7376-447f-908e-6e9677d475ea%40googlegroups.com.

John Cremona

unread,
Nov 8, 2019, 4:33:51 AM11/8/19
to SAGE support
On Fri, 8 Nov 2019 at 01:33, saad khalid <saad...@gmail.com> wrote:
This functionality seems to be intended somehow? At least, it is made reference to in the documentation:
Look at the part after:
"A matrix that is not diagonalizable over the rationals, as evidenced by its Jordan form."

I think that this is certainly a bug, this method should return False for a non-diagonalizable matrix, not raise an error.  Of course there is an issue here about whether the matrix is diagonalizable over its base field or just over an extension, but that is properly documented.

It is reasonable to raise an error for matrices over RR or CC (as they are not exact) though I'm sure that many users will not like

sage: m = matrix(CC,2, 2, [0,-1,1,0])
sage: m.eigenvalues()
/local/localhome/masgaj/sage/src/bin/sage-ipython:1: UserWarning: Using generic algorithm for an inexact ring, which will probably give incorrect results due to numerical precision issues.
  #!/usr/bin/env sage-python23
[1.00000000000000*I, -1.00000000000000*I]
sage: m.is_diagonalizable()
(...)
ValueError: base field must be exact, not Complex Field with 53 bits of precision

since for such an example "obviously" the eigenvalues are distinct, but at least there is a warning.

John
 


-Saad

On Thursday, November 7, 2019 at 4:38:13 AM UTC-5, Dima Pasechnik wrote:
On Thu, Nov 7, 2019 at 9:15 AM Kwankyu <ekwa...@gmail.com> wrote:
>
> Hi,
>
> This
>
> m = matrix(QQ, 3, [1, 1, 1, 0, 3, 3, -2, 1, 2])
> m.is_diagonalizable()
>
> raises an error rather than giving False. The error message gives an explanation why the matrix is > not diagonalizable. But I think the expected result for asking diagonalizability should be either True or False, for legitimate inputs.

I agree. It seems that is_diagonalizable() is the only method among
is_*() for matrices
that has this strange behavior (I checked several of them, but not all).

CC'ing to the original author...

Dima

> What do you think?
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-s...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/4c3a3e63-14d7-4e49-aadb-480b6ff46a64%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/8efe0856-7376-447f-908e-6e9677d475ea%40googlegroups.com.

Kwankyu

unread,
Nov 11, 2019, 8:25:50 PM11/11/19
to sage-support
Thanks for the input. This is now 

Reply all
Reply to author
Forward
0 new messages