ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 28 Jul 2014 08:41:10 -0500Symbolic integer arithmetichttps://ask.sagemath.org/question/23610/symbolic-integer-arithmetic/It's not that hard to find a closed expression for the remainder of the polynomial $x^n$ modulo $x^2-5x-2$. But I don't seem to manage it in SAGE.
n=var('n')
R=PolynomialRing(RationalField(),'x');R
x=R.gen();x
mp=x^2-5*x-2
S=R.quotient(mp,'a')
a=S.gen();a^2
a^5
works as expected, but replacing the last line with a^n gives an error (non-integral exponents not supported). I understand a general variable is not a SAGE integer, but how DO I make clear n is supposed to be an integer?
In the same way, it's not that hard to calculate the symbolic n-the power of a small, say 2x2, matrix, but the straightforward aproach of simplifying A^n gives the same error (non-integral exponents not supported).
I checked wolfram alpha for the symbolic power of a matrix, and immediately got the expected answer for [[1,2],[3,4]]^n .
![Wolfram alpha answer](http://www4b.wolframalpha.com/Calculate/MSP/MSP16951af85fib66538dhg0000648f487198eeg2e8?MSPStoreType=image/gif&s=54&w=1188.&h=58.)
Dirk DanckaertMon, 28 Jul 2014 08:41:10 -0500https://ask.sagemath.org/question/23610/