# Revision history [back]

If you are sure that there is only one free variable, then you can easily identify it.

First, use solution_dict option to deal with the result more easily:

sage: sol1 = solve([x+y==1], x, y, solution_dict=True)
sage: sol1
[{y: r3, x: -r3 + 1}]


Now, you can ask for the variables appearing in a symbolic expression, see:

sage: sol1[0][x]
-r3 + 1
sage: sol1[0][x].variables()
(r3,)
sage: sol1[0][x].variables()[0]


So, you can give it a Python name and use it afterwards:

sage: freevar = sol1[0][x].variables()[0]
sage: expr = sol1[0][x]
sage: expr
-r3 + 1
sage: expr.subs({freevar:10})
-9


If you are sure that there is only one free variable, then you can easily identify it.

First, use solution_dict option to deal with the result more easily:

sage: sol1 = solve([x+y==1], x, y, solution_dict=True)
sage: sol1
[{y: r3, x: -r3 + 1}]


Now, you can ask for the variables appearing in a symbolic expression, see:

sage: sol1[0][x]
-r3 + 1
sage: sol1[0][x].variables()
(r3,)
sage: sol1[0][x].variables()[0]


So, you can give it a Python name and use it afterwards:

sage: freevar = sol1[0][x].variables()[0]
sage: expr = sol1[0][x]
sage: expr
-r3 + 1
sage: expr.subs({freevar:10})
-9