Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the names of variables:

var('x_1 x_2')
s=solve([x_1^2+x_2^2==1,x_1-x_2==1/2],x_1,x_2,solution_dict=True)
s

[{x_1: -1/4*sqrt(7) + 1/4, x_2: -1/4*sqrt(7) - 1/4},
 {x_1: 1/4*sqrt(7) + 1/4, x_2: 1/4*sqrt(7) - 1/4}]

s[0]                  # first solution

{x_1: -1/4*sqrt(7) + 1/4, x_2: -1/4*sqrt(7) - 1/4}

s[0][x_1]             # x_1 component of the first solution

-1/4*sqrt(7) + 1/4