Ask Your Question
1

symbolic equation resolution

asked 2017-09-26 15:21:50 -0500

this post is marked as community wiki

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?

Thanks to you who will take your time to answer !

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-09-27 10:46:09 -0500

dan_fulea gravatar image

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.)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-09-26 15:21:50 -0500

Seen: 41 times

Last updated: Sep 27