Use `solve`output to create a function
Hi there,
I want to use the ouptut of solve
to create a function from it.
My system depends on some parameter, say $a$, it is a tiny linear system $2\times 2$, and I know there is always a solution. The right-hand term also contains some $a$ into it. What I want to do is to use the first and the second component to buy functions, calle them x1(a)
and x2(a)
that I will call later. I tried something like
var("v1, v2, a")
Sols = solve([v1+a*v2 == a, -a*v1 + v2 ==0],[v1,v2])
x1(a) = Sols[0][0].rhs()
x2(a) = Sols[0][1].rhs()
This gives the expected expressions for x1
and x2
but I cannot use these to do further computations, for instance, using x1(1)
wont evaluate the expression when $a=1$, as I would expect.
The very precise example above is not what I actually want to handle, my actual system is actually more complex.
Many thanks!
Works for me on Sage 8.1.rc2:
Works ditto for me on Sage 8.0.