Ask Your Question

Revision history [back]

If you ask for the type of $f$, you get <πšπš’πš™πšŽ'𝚜𝚊𝚐𝚎.πšœπš’πš–πš‹πš˜πš•πš’πšŒ.πšŽπš‘πš™πš›πšŽπšœπšœπš’πš˜πš—.π™΄πš‘πš™πš›πšŽπšœπšœπš’πš˜πš—'>: apparently the substitution into symbolic expressions is not overloaded to matrix-valued functions. However, with

var('x y')
f = matrix(SR, [[sin(x)],[cos(x)]])
type(f)

you get <πšπš’πš™πšŽ'𝚜𝚊𝚐𝚎.πš–πšŠπšπš›πš’πš‘.πš–πšŠπšπš›πš’πš‘βŽ―πšœπš’πš–πš‹πš˜πš•πš’πšŒβŽ―πšπšŽπš—πšœπšŽ.π™ΌπšŠπšπš›πš’πš‘βŽ―πšœπš’πš–πš‹πš˜πš•πš’πšŒβŽ―πšπšŽπš—πšœπšŽ'>, and

f(x=x+y)

gives the expected result.

If you ask for the type of $f$, you get <πšπš’πš™πšŽ'𝚜𝚊𝚐𝚎.πšœπš’πš–πš‹πš˜πš•πš’πšŒ.πšŽπš‘πš™πš›πšŽπšœπšœπš’πš˜πš—.π™΄πš‘πš™πš›πšŽπšœπšœπš’πš˜πš—'>: apparently the substitution into symbolic expressions is not overloaded to matrix-valued functions. However, with

var('x y')
f = matrix(SR, [[sin(x)],[cos(x)]])
type(f)

you get <πšπš’πš™πšŽ'𝚜𝚊𝚐𝚎.πš–πšŠπšπš›πš’πš‘.πš–πšŠπšπš›πš’πš‘βŽ―πšœπš’πš–πš‹πš˜πš•πš’πšŒβŽ―πšπšŽπš—πšœπšŽ.π™ΌπšŠπšπš›πš’πš‘βŽ―πšœπš’πš–πš‹πš˜πš•πš’πšŒβŽ―πšπšŽπš—πšœπšŽ'>, and

f(x=x+y)

gives the expected result.

Alternatively, try with:

def f(x): return matrix(SR, [[sin(x)],[cos(x)]])

to obtain an object $f$ of type 'function'.