Ask Your Question

Revision history [back]

This is trac ticket #12075.

This way to define a function is syntactic sugar offered by Sage, but it doesn't yet work for matrix functions.

I suggest defining an ordinary Python function instead (using a lambda for brevity):

sage: var('alpha')
sage: i = matrix(SR, [[ 0, -I], [-I, 0]])
sage: f = lambda alpha: cos(alpha)*i
sage: f(0)
[ 0 -I]
[-I  0]

This is trac ticket #12075.

This way to define a function is syntactic sugar offered by Sage, but it doesn't yet work for matrix functions.

I suggest defining an ordinary Python function instead (using a lambda for brevity):

sage: var('alpha')
sage: i = matrix(SR, [[ 0, -I], [-I, 0]])
sage: f = lambda alpha: cos(alpha)*i
x: cos(x)*i
sage: f(0)
[ 0 -I]
[-I  0]
sage: f(alpha)
[            0 -I*cos(alpha)]
[-I*cos(alpha)             0]

This is trac ticket #12075. (since 2011).

This way to define a function is syntactic sugar offered by Sage, but it doesn't yet work for matrix functions.

I suggest defining an ordinary Python function instead (using a lambda for brevity):

sage: var('alpha')
sage: i = matrix(SR, [[ 0, -I], [-I, 0]])
sage: f = lambda x: cos(x)*i
sage: f(0)
[ 0 -I]
[-I  0]
sage: f(alpha)
[            0 -I*cos(alpha)]
[-I*cos(alpha)             0]