ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 27 Sep 2017 10:46:09 -0500symbolic equation resolutionhttp://ask.sagemath.org/question/38978/symbolic-equation-resolution/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 !Tue, 26 Sep 2017 15:21:50 -0500http://ask.sagemath.org/question/38978/symbolic-equation-resolution/Answer by dan_fulea for <p>Dear all,</p>
<p>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.</p>
<p>What I have done is :</p>
<pre><code>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
</code></pre>
<p>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?</p>
<p>Thanks to you who will take your time to answer !</p>
http://ask.sagemath.org/question/38978/symbolic-equation-resolution/?answer=38984#post-id-38984There 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.)
Wed, 27 Sep 2017 10:46:09 -0500http://ask.sagemath.org/question/38978/symbolic-equation-resolution/?answer=38984#post-id-38984