# symbolic equation resolution

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Dear all,

I'm discovering sage capabilities and would like to start with a basic exemple : I'd like to remove some unknown variables of an electronic system I started to build to simplify as much as possible the various equations I have.

What I have done is :

sage : var('beta,ipi1,i1,i2,ipi2,ir1,ir2,r,rpi')
sage : solve([beta*ipi1==i1, i2==(beta+1)*ipi2+ipi1, ir1==(beta+1)*ipi1, ir2==(beta+1)*ipi2, r*ir2+rpi*ipi2==r*ipi1+rpi*ipi1],i1


I would like to get i1 depending on the "known" variables of the system : i2, r and beta. But Sage is answering [ ]. What am I doing wrong?

edit retag close merge delete

Sort by ยป oldest newest most voted

There are nine variables.

Three of them are known. I suppose exactly three. All other six are free.

We have five equations. This lives exactly one degree of freedom. Then the following possibilities lead to answers:

(1)

var( 'beta,ipi1,i1,i2,ipi2,ir1,ir2,r,rpi' )

solutions = solve( [ beta*ipi1 == i1
, i2  == (beta+1)*ipi2 + ipi1
, ir1 == (beta+1)*ipi1
, ir2 == (beta+1)*ipi2
, r*ir2 + rpi*ipi2 == r*ipi1 + rpi*ipi1]
, [ i1, ir1, ir2, ipi1, ipi2 ] )

for sol in solutions:
for eq in sol:
print eq


And the results are:

(beta, ipi1, i1, i2, ipi2, ir1, ir2, r, rpi)
i1 == (beta^2*i2*r + beta*i2*(r + rpi))/(beta*(2*r + rpi) + 2*r + 2*rpi)
ir1 == (beta^2*i2*r + beta*i2*(2*r + rpi) + i2*(r + rpi))/(beta*(2*r + rpi) + 2*r + 2*rpi)
ir2 == (beta*i2*(r + rpi) + i2*(r + rpi))/(beta*(2*r + rpi) + 2*r + 2*rpi)
ipi1 == (beta*i2*r + i2*(r + rpi))/(beta*(2*r + rpi) + 2*r + 2*rpi)
ipi2 == i2*(r + rpi)/(beta*(2*r + rpi) + 2*r + 2*rpi)


We have an expression of i1 depending on the variables not mentioned in the list [ i1, ir1, ir2, ipi1, ipi2 ] to solve for. It was my decision to omit also rpi.

(2)

We can also add rpi to the list. Then...

solutions = solve( [ beta*ipi1 == i1
, i2  == (beta+1)*ipi2 + ipi1
, ir1 == (beta+1)*ipi1
, ir2 == (beta+1)*ipi2
, r*ir2 + rpi*ipi2 == r*ipi1 + rpi*ipi1]
, [ i1, ir1, ir2, ipi1, ipi2, rpi ] )

for sol in solutions:
for eq in sol:
print eq


delivers:

i1 == ((beta^2 + beta)*i2*r + beta*i2*r2)/(2*(beta + 1)*r + (beta + 2)*r2)
ir1 == ((beta^2 + 2*beta + 1)*i2*r + (beta + 1)*i2*r2)/(2*(beta + 1)*r + (beta + 2)*r2)
ir2 == ((beta + 1)*i2*r + (beta + 1)*i2*r2)/(2*(beta + 1)*r + (beta + 2)*r2)
ipi1 == ((beta + 1)*i2*r + i2*r2)/(2*(beta + 1)*r + (beta + 2)*r2)
ipi2 == (i2*r + i2*r2)/(2*(beta + 1)*r + (beta + 2)*r2)
rpi == r2


with a new free variable r2. (It was my second copy+paste of the code. The first one had a small width.)

more