[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sqrtm test failure
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: sqrtm test failure |
Date: |
Sun, 31 Jul 2011 09:49:37 -0500 |
On 31 July 2011 05:48, Jussi Lehtola <address@hidden> wrote:
> On Sat, 30 Jul 2011 22:10:01 -0500
> Jordi Gutiérrez Hermoso <address@hidden> wrote:
>> >> isnan(sqrtm ([0 1; 0 0]))
>> > warning: sqrtm: matrix is singular, may not have a square root
>> > ans =
>> >
>> > 0 1
>> > 0 1
>>
>> I wrote that test during the code sprint, because certain kinds of
>> matrices should fail to produce a square root. Perhaps rewrite the
>> test to use "any"? Or could the output be anything? Is there a way
>> merely test that it produces a warning?
>
> What do you mean by "fail to produce a square root"?
There is no matrix S s.t. S^2 = A.
> A non-symmetric matrix can easily be seen not to have a square root,
What? Symmetry has nothing to do with it. Consider a Jordan block
j = [1 2; 0 1]
which obviously has a square root s = [1 1; 0 1].
> but taking the square root of a singular symmetric matrix should be
> supported, since the operation can be seen to be well defined via
> the SVD.
A singular matrix may or may not have a square root; it depends on the
structure of the Jordan blocks for its zero eigenvalues. [0 1; 0 0] is
the minimal example of a matrix without a square root. Topics in
Matrix Analysis by Horn and Johnson covers this in more detail
(section 6.4).
Since the Jordan form is numerically unstable, I don't think that a
numerical algorithm can reliably determine if a matrix has a square
root; the warning is best possible. Perhaps simply change the test to
j = [0 1; 0 0];
s = sqrtm(x);
assert( s^2 != j)
?
- Jordi G. H.