On Sep 5, 3:17 pm, Nick <aroy...@gmail.com> wrote: > Q1. How can I extract elements from a solution set? > > For example, consider: > > sage: x, y = var('x, y') > sage: solve([x+y==6, x-y==4], x, y) > [[x == 5, y == 1]]
If you use "solution_dict=true", you get the solutions back in a form that is probably more suitable for processing afterwards: sage: var("x,y,t") (x, y, t) sage: sln=solve([x^2+y^2==2,x^2-y^2==0],x,y,solution_dict=true) sage: sln [{y: 1, x: -1}, {y: -1, x: 1}, {y: -1, x: -1}, {y: 1, x: 1}] sage: [ (x.subs(s),y.subs(s)) for s in sln ] [(-1, 1), (1, -1), (-1, -1), (1, 1)] sage: [ (x*t+y).subs(s) for s in sln ] [-t + 1, t - 1, -t - 1, t + 1] -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org