# Revision history [back]

### How can I get back an expression for free variables in solve function.

I have a number of linear equations on some symbols A,B,C,D,E,F,G. When I solve them in Sagemath, I get some free variables in the solution.

$A,B,C,D,E,F,G=var('A,B,C,D,E,F,G')$

$eqns=[A+B==0,C+D+E==0,F+G==0,A+E-F==0]$

$solution=solve(eqns,A,B,C,D,E,F,G)$

Sage gives the following solution: $[[A == r1, B == -r1, C == r1 - r2 - r3, D == r3, E == -r1 + r2, F == r2, G == -r2]]$

Now I can ask Sage to give me an expression of any combination of the symbols, for example: $(A+C).subs(solution)$, then I get $2*r1 - r2 - r3$. For my purpose I would now like to have an expression for any of the free variables. If I assign $r1=var('r1')$ and ask Sage $s1.subs(solution)$ I get back $r1$ again. But I would lik to get back an expression in terms of $A,B,C,D,E,F,G$. Any suggestions on how to do this?

 2 retagged FrédéricC 4968 ●3 ●41 ●107

### How can I get back an expression for free variables in solve function.

I have a number of linear equations on some symbols A,B,C,D,E,F,G. When I solve them in Sagemath, I get some free variables in the solution.

$A,B,C,D,E,F,G=var('A,B,C,D,E,F,G')$

$eqns=[A+B==0,C+D+E==0,F+G==0,A+E-F==0]$

$solution=solve(eqns,A,B,C,D,E,F,G)$

Sage gives the following solution: $[[A == r1, B == -r1, C == r1 - r2 - r3, D == r3, E == -r1 + r2, F == r2, G == -r2]]$

Now I can ask Sage to give me an expression of any combination of the symbols, for example: $(A+C).subs(solution)$, then I get $2*r1 - r2 - r3$. For my purpose I would now like to have an expression for any of the free variables. If I assign $r1=var('r1')$ and ask Sage $s1.subs(solution)$ I get back $r1$ again. But I would lik to get back an expression in terms of $A,B,C,D,E,F,G$. Any suggestions on how to do this?