Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The easiest way is to pass solution_dict=True to the solve command.

sage: var('x,y,z')
(x, y, z)
sage: eqs = [x + 2*y + 4*z - 1 == 0, x + 4*z - 5 == 0,  3*x + 6*z - 6]
sage: solve(eqs, (x,y,z))
[[x == -1, y == -2, z == (3/2)]]
sage: sols = solve(eqs, (x,y,z), solution_dict=True); sols
[{z: 3/2, y: -2, x: -1}]

Then, you can pass that dictionary into the subs method of your expression. For example,

sage: f = x^2 + y^2 + z^2
sage: [f.subs(sol) for sol in sols]
[29/4]