ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 26 Nov 2015 06:41:24 -0600integration of matrix-valued functionhttp://ask.sagemath.org/question/31085/integration-of-matrix-valued-function/ Hi,
I want to compute the (in)definite integral of matrix valued function, for example
var('x')
f =matrix([[x,1],[x^2,2]]);
The command
integrate(f,x,0,1)
doesn't work. I expect matrix as a result - integrated by elements
Thu, 26 Nov 2015 06:34:42 -0600http://ask.sagemath.org/question/31085/integration-of-matrix-valued-function/Answer by vdelecroix for <p>Hi,
I want to compute the (in)definite integral of matrix valued function, for example</p>
<pre><code>var('x')
f =matrix([[x,1],[x^2,2]]);
</code></pre>
<p>The command </p>
<pre><code>integrate(f,x,0,1)
</code></pre>
<p>doesn't work. I expect matrix as a result - integrated by elements</p>
http://ask.sagemath.org/question/31085/integration-of-matrix-valued-function/?answer=31086#post-id-31086This is not supported but you can use
sage: f.apply_map(lambda e: integrate(e,x,0,1))
[1/2 1]
[1/3 2]
The method **apply_map** simply applies a function entrywise.Thu, 26 Nov 2015 06:41:24 -0600http://ask.sagemath.org/question/31085/integration-of-matrix-valued-function/?answer=31086#post-id-31086