ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 19 Dec 2017 23:16:06 +0100truncated exponential series over ring of matrices over symbolic ringhttps://ask.sagemath.org/question/40236/truncated-exponential-series-over-ring-of-matrices-over-symbolic-ring/I want to do the following:
R.<z>=PowerSeriesRing(SR)
i,n,z=var('i,n,z')
f,g=function('f,g')
F=sum(f(i)*z^i,i,1,n)
G=sum(g(i)*z^i,i,1,n)
gamma=matrix([[0,F],[G,0]])
I then want to define a function as the first several terms of the exponential series exp(gamma). Something like
Gamma=sum(gamma^i/factorial(i),i,0,n)
This will return an error like: 'too many values to unpack'
I only want to work with this function formally until I need to specify a value of n and eventually solve for the value f(i), g(i) in terms of some other parameters (yet to be defined in this code). What are some ways to clean this up so I can work with the truncated power series with matrix coefficients?
A possibly simpler but related question is how does one build a function that will sum several powers of a matrix? Tue, 19 Dec 2017 22:33:44 +0100https://ask.sagemath.org/question/40236/truncated-exponential-series-over-ring-of-matrices-over-symbolic-ring/Answer by tmonteil for <p>I want to do the following:</p>
<pre><code>R.<z>=PowerSeriesRing(SR)
i,n,z=var('i,n,z')
f,g=function('f,g')
F=sum(f(i)*z^i,i,1,n)
G=sum(g(i)*z^i,i,1,n)
gamma=matrix([[0,F],[G,0]])
</code></pre>
<p>I then want to define a function as the first several terms of the exponential series exp(gamma). Something like</p>
<pre><code>Gamma=sum(gamma^i/factorial(i),i,0,n)
</code></pre>
<p>This will return an error like: 'too many values to unpack'</p>
<p>I only want to work with this function formally until I need to specify a value of n and eventually solve for the value f(i), g(i) in terms of some other parameters (yet to be defined in this code). What are some ways to clean this up so I can work with the truncated power series with matrix coefficients?</p>
<p>A possibly simpler but related question is how does one build a function that will sum several powers of a matrix? </p>
https://ask.sagemath.org/question/40236/truncated-exponential-series-over-ring-of-matrices-over-symbolic-ring/?answer=40237#post-id-40237I am not sure about your request, is the following sufficient for you ?
sage: Gamma = lambda n: sum(gamma^i/factorial(i) for i in range(n))
sage: Gamma(2)
[ 1 sum(z^i*f(i), i, 1, n)]
[sum(z^i*g(i), i, 1, n) 1]
sage: Gamma(3)
[1/2*sum(z^i*f(i), i, 1, n)*sum(z^i*g(i), i, 1, n) + 1 sum(z^i*f(i), i, 1, n)]
[ sum(z^i*g(i), i, 1, n) 1/2*sum(z^i*f(i), i, 1, n)*sum(z^i*g(i), i, 1, n) + 1]Tue, 19 Dec 2017 23:16:06 +0100https://ask.sagemath.org/question/40236/truncated-exponential-series-over-ring-of-matrices-over-symbolic-ring/?answer=40237#post-id-40237