On 2014-04-28, Nils Bruin <[email protected]> wrote:
> On Monday, April 28, 2014 12:56:48 AM UTC-7, [email protected] wrote:
>>
>> It takes less than two minutes to run 
>>
>> ./sage -c "n=121; l=range(1,n+1); x=matrix([[floor(n/lcm(i,j)) for i in l] 
>> for j in l]).eigenvalues();" 
>>
>> But with n=122 calculation seems to get stuck. 
>>
>> Well, 122=61*2, so maybe it's because of a big factor? However, n=118=59*2 
>> takes only about a minute. And n=123 takes less than one minute, so the 
>> size of the matrix is not a problem in itself. 
>>
>
> Nor is computing the characteristic polynomial. Note that `eigenvalues` 
> returns its answer in the "field of algebraic numbers". Equality testing is 
> notoriously difficult there, and since the characteristic polynomials of 
> your matrices are not square-free, you will run into some nasty 
> comparisons. The fact that the code finishes for n=121 is pretty good!
>
> sage: n=122
> sage: l=range(1,n+1); M=matrix([[floor(n/lcm(i,j)) for i in l] for j in l])
> sage: f=M.characteristic_polynomial()
> sage: x=flatten([[a.roots(QQbar,multiplicities=False)]*d for a,d in 
> factor(f)])
>
> works pretty quickly.
>
> Upon inspection, it turns out that M.eigenvalues does something like that, 
> but via a much less efficient route. The implementation can probably be 
> streamlined considerably.
>
> In reality, there's probably never a compelling reason to work with the 
> eigenvalues of a matrix as explicit algebraic numbers. Either you need 
> their embedding in CC, in which case a numerical approximation should 
> suffice, or you need their algebraic properties, in which case the 
> factorization of the characteristic polynomial over the base ring probably 
> gives you the information you need.
>
Well, one might want to simultaneosuly diagonalise a bunch of
commuting matrices with entries in ZZ, and use their eigenvalues for some exact
computation. That's what people who work with association schemes do
quite a bit.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to