# Revision history [back]

Your program rebinds the Python variables initially bound to the objects representing your mathematical variables. Therefore, it does not solve the *same *system of equations.

This can be illustrated by tracing the state of your variables. Your initial setup, with a slight modification :

reset()
# Collect variable names
Vars = var('i_B10 i_B6 i_B11 i_C10 i_C6 i_C11 beta i_in i_out i_E10 i_E6 i_E11')
# Collect equations
Sys = [i_C10 == i_B10 * beta,
i_E10 == i_C10 + i_B10,
i_C6 == i_B6 * beta,
i_E6 == i_B6 + i_C6,
i_C11 == i_B11 * beta,
i_E11 == i_B11 + i_C11,
i_E10 == i_B11 + i_E6,
i_E11 + i_E6 == i_in + i_out,
i_B11 == i_B6,
i_in == i_B10 + i_C11,
i_out == i_C10]
# *Text* of the program
Txt="""i_C10 = i_B10 * beta
i_E10 = i_C10 + i_B10
i_C6 = i_B6 * beta
i_E6 = i_B6 + i_C6
i_C11 = i_B11 * beta
i_E11 = i_B11 + i_C11
i_B10 = (i_E10 == i_B11 + i_E6).solve(i_B10)[0].right()
i_B10 = i_B10(i_B11=i_B6)
i_C10 = i_C10(i_B10=i_B10)
i_B6 = solve(i_in == i_B10 + i_C11(i_B11=i_B6), i_B6)[0].right()
i_out = i_C10(i_B6=i_B6)"""


We create a copy by renaming variables (and modify program text accordingly).

# New (= renamed) variables
uVars = var([repr(u).replace("i_","u_") for u in Vars])
# use them in program text (and split it in lines)
uTxt = Txt.replace("i_","u_").split("\n")


Now, we can execute the program step by step, and trace identifier's values after each step :

State = []
for t in uTxt:
exec(t)
State.append([eval(repr(u)) for u in uVars])
# Effective history of identifiers :


The result cannot currently be displayed in this site, whose typesetting is questionable, but is visible in Sagecell.

HTH,

Your program rebinds the Python variables initially bound to the objects representing your mathematical variables. Therefore, it does not solve the *same *system of equations.

This can be illustrated by tracing the state of your variables. Your initial setup, with a slight modification :

reset()
# Collect variable names
Vars = var('i_B10 i_B6 i_B11 i_C10 i_C6 i_C11 beta i_in i_out i_E10 i_E6 i_E11')
# Collect equations
Sys = [i_C10 == i_B10 * beta,
i_E10 == i_C10 + i_B10,
i_C6 == i_B6 * beta,
i_E6 == i_B6 + i_C6,
i_C11 == i_B11 * beta,
i_E11 == i_B11 + i_C11,
i_E10 == i_B11 + i_E6,
i_E11 + i_E6 == i_in + i_out,
i_B11 == i_B6,
i_in == i_B10 + i_C11,
i_out == i_C10]
# *Text* of the program
Txt="""i_C10 = i_B10 * beta
i_E10 = i_C10 + i_B10
i_C6 = i_B6 * beta
i_E6 = i_B6 + i_C6
i_C11 = i_B11 * beta
i_E11 = i_B11 + i_C11
i_B10 = (i_E10 == i_B11 + i_E6).solve(i_B10)[0].right()
i_B10 = i_B10(i_B11=i_B6)
i_C10 = i_C10(i_B10=i_B10)
i_B6 = solve(i_in == i_B10 + i_C11(i_B11=i_B6), i_B6)[0].right()
i_out = i_C10(i_B6=i_B6)"""


We create a copy by renaming variables (and modify program text accordingly).

# New (= renamed) variables
uVars = var([repr(u).replace("i_","u_") for u in Vars])
# use them in program text (and split it in lines)
uTxt = Txt.replace("i_","u_").split("\n")


Now, we can execute the program step by step, and trace identifier's values after each step :

State = []
for t in uTxt:
exec(t)
State.append([eval(repr(u)) for u in uVars])
# Effective history of identifiers :


The result cannot currently be displayed in this site, whose typesetting is questionable, but is visible in Sagecell.

HTH,

EDIT : avi9526's answer to his own question, which is correct, can be clarified as :

reset()
Vars = var('i_B10 i_B6 i_B11 i_C10 i_C6 i_C11 beta i_in i_out i_E10 i_E6 i_E11')
Sys = [
i_C10 == i_B10 * beta,
i_E10 == i_C10 + i_B10,
i_C6 == i_B6 * beta,
i_E6 == i_B6 + i_C6,
i_C11 == i_B11 * beta,
i_E11 == i_B11 + i_C11,
i_E10 == i_B11 + i_E6,
i_E11 + i_E6 == i_in + i_out,
i_B11 == i_B6,
i_in == i_B10 + i_C11,
i_out == i_C10
]
Unk = [i_B10, i_B6, i_B11, i_C10, i_C6, i_C11, i_out, i_E10, i_E6, i_E11]
Sol =solve(Sys,Unk)


This solution is unique :

sage: len(Sol)
1


ad can be displayed as :

sage: print("\n".join(map(repr,Sol[0])))
i_B10 == (beta*i_in + 2*i_in)/(beta^2 + 2*beta + 2)
i_B6 == (beta*i_in + i_in)/(beta^2 + 2*beta + 2)
i_B11 == (beta*i_in + i_in)/(beta^2 + 2*beta + 2)
i_C10 == (beta^2*i_in + 2*beta*i_in)/(beta^2 + 2*beta + 2)
i_C6 == (beta^2*i_in + beta*i_in)/(beta^2 + 2*beta + 2)
i_C11 == (beta^2*i_in + beta*i_in)/(beta^2 + 2*beta + 2)
i_out == (beta^2*i_in + 2*beta*i_in)/(beta^2 + 2*beta + 2)
i_E10 == (beta^2*i_in + 3*beta*i_in + 2*i_in)/(beta^2 + 2*beta + 2)
i_E6 == (beta^2*i_in + 2*beta*i_in + i_in)/(beta^2 + 2*beta + 2)
i_E11 == (beta^2*i_in + 2*beta*i_in + i_in)/(beta^2 + 2*beta + 2)


HTH,