1 | initial version |
Hello,
The problem with your code is that the substitution does a too naive substitution
sage: R = LaurentPolynomialRing(CC, 'x')
sage: x = R.gens()[0]
sage: m = matrix([[x]])
sage: mm = m.subs({x: 2})
sage: mm.base_ring()
Univariate Laurent Polynomial Ring in x over Complex Field with 53 bits of precision
In order to get eigenvalues, you need to say explicitely that the matrix is now defined over complex numbers
sage: mm.change_ring(CC).eigenvalues()
... UserWarning ...
[2.00000000000000]
Perhaps the behavior of the method .subs should be different to agree with
sage: x.subs({x:2}).parent()
Complex Field with 53 bits of precision
Vincent
2 | No.2 Revision |
Hello,
The problem with your code is that the substitution does a too naive substitution
sage: R = LaurentPolynomialRing(CC, 'x')
sage: x = R.gens()[0]
sage: m = matrix([[x]])
sage: mm = m.subs({x: 2})
sage: mm.base_ring()
Univariate Laurent Polynomial Ring in x over Complex Field with 53 bits of precision
In order to get eigenvalues, you need to say explicitely that the matrix is now defined over complex numbers
sage: mm.change_ring(CC).eigenvalues()
... UserWarning ...
[2.00000000000000]
Perhaps EDIT: as mentioned in the behavior of comment, the method .subs should be different above solution does not work. This is because there is no way to agree withinitialize a complex number from a power series, even if it is constant
sage: x.subs({x:2}).parent()
Complex Field with 53 bits of precision
a = R(CC(2,1))
sage: CC(a)
Traceback (most recent call last):
...
TypeError: unable to coerce to a ComplexNumber: <type 'sage.rings.power_series_poly.PowerSeries_poly'>
In the case the constant is real it works by some strange magic.
Vincent