On Friday, November 30, 2018 at 1:59:40 PM UTC-8, saad khalid wrote:
>
> However, when I try to compute this h(.1), the function doesn't plug in .1 
> in for s in the function, and it returns:
>
> [ s + 1      0]
> [     0 -s + 1]
>
>
> What exactly is happening?
>
> The problem is that a matrix over SR is not a symbolic expression itself:

sage: parent(M1+s*Mx)
Full MatrixSpace of 2 by 2 dense matrices over Symbolic Ring

The effect of "h(s)=..." is (you can check by calling 
'preparse("h(s)=...")'):

 h = symbolic_expression(M1+s*Mx).function(s)

which "forces" the sage object M1+s*Mx into the symbolic ring. Nearly 
everything can be stuffed into the symbolic ring, but in this case it 
basically becomes a constant:

sage: symbolic_expression(M1+s*Mx).variables()
()
sage: symbolic_expression(M1+s*Mx).is_constant()
True

Once stuffed into SR, it's an opaque entity, and the occurrence of s in it 
is not visible. So turning it into a function of s is straightforward: it's 
a constant function!

The solution here is to use that matrices over symbolic rings do inherit 
some properties of symbolic expressions. One is substitution, so

sage: h=M1+s*Mx
sage: h(s=1.0)
[ 2.00000000000000                 0]
[                0 0.000000000000000]

works just fine.

If you want to turn it into something for which h(1.0) works, you can do

h=lambda s0: (M1+s*Mx)(s=s0)

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to