ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 29 Dec 2019 07:02:07 +0100can sage return a list of numbers from solve() instead of expressions?https://ask.sagemath.org/question/49245/can-sage-return-a-list-of-numbers-from-solve-instead-of-expressions/ is there any builtin methods to have `solve()` return a list of numbers instead of the sequence of expressions that it does?
which is to say `solve(eqn, x)` would return:
> $[x_1, x_2, ...,x_n]$
instead of:
> $[x == x_1, x == x_2, ... , x == x_n]$
or if there are not any built in functions recommended approaches? this is in a sage script im rating that at this point in the program is taking polynomials, computing their first and second derivatives, and adding the roots of those derivatives to a list, which needs to be iterable. if there does not exist some sage method or options for this, i believe i would need to revert to regex, which feels like im doing something wrong if thats what im having to do herealienfetuseaterSun, 29 Dec 2019 07:02:07 +0100https://ask.sagemath.org/question/49245/Use `solve`output to create a functionhttps://ask.sagemath.org/question/39802/use-solveoutput-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!JCSun, 26 Nov 2017 21:25:48 +0100https://ask.sagemath.org/question/39802/