ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 30 Aug 2012 17:26:05 +0200Unexpected solve() errorshttps://ask.sagemath.org/question/9275/unexpected-solve-errors/ #Area [m^2]
Ab = 0.00313659226
#CB Ratio
cb = 0.262
eng4 =[solve(cb == Vc/(Ab*Lb),Lb) for Vc in xrange(0.000001,0.00002)]
print(eng4)
This returns an empty list [] and I have no idea why.
And this one:
#Ideal Gas Law[Relates Pressure and Volume]
#Definitions v3
#Main Tank Pressure[Pascals]
Pp=1013529.32
#Tank Volume[m^3]
Vt=0.0013929
#Moles of Air
#Gas Constant
r=8.3144621
#Ambient Temperature[Kelvin][70F]
t= 294.261
eng5= solve(Pp*Vt == n*r*t,n,solution_dict=1)
v3=eng5[0]
v4=n(v3)
n(v4)
__main__:18: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
See http://trac.sagemath.org/5930 for details.
75589949342674/131001015929725
Or it just shows the fraction. It's been acting weird lately
Why?Wed, 29 Aug 2012 23:43:08 +0200https://ask.sagemath.org/question/9275/unexpected-solve-errors/Answer by Shashank for <pre><code>#Area [m^2]
Ab = 0.00313659226
#CB Ratio
cb = 0.262
eng4 =[solve(cb == Vc/(Ab*Lb),Lb) for Vc in xrange(0.000001,0.00002)]
print(eng4)
</code></pre>
<p>This returns an empty list [] and I have no idea why.
And this one:</p>
<pre><code>#Ideal Gas Law[Relates Pressure and Volume]
#Definitions v3
#Main Tank Pressure[Pascals]
Pp=1013529.32
#Tank Volume[m^3]
Vt=0.0013929
#Moles of Air
#Gas Constant
r=8.3144621
#Ambient Temperature[Kelvin][70F]
t= 294.261
eng5= solve(Pp*Vt == n*r*t,n,solution_dict=1)
v3=eng5[0]
v4=n(v3)
n(v4)
</code></pre>
<p>__main__:18: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
See <a href="http://trac.sagemath.org/5930">http://trac.sagemath.org/5930</a> for details.
75589949342674/131001015929725</p>
<p>Or it just shows the fraction. It's been acting weird lately</p>
<p>Why?</p>
https://ask.sagemath.org/question/9275/unexpected-solve-errors/?answer=12469#post-id-12469The problem is that xrange gives an empty list so the result is an empty list. Try this
import numpy as np
#Area [m^2]
Ab = 0.00313659226
#CB Ratio
cb = 0.262
Lb=var('Lb')
eng4 =[solve(cb == Vc/(Ab*Lb),Lb) for Vc in np.arange(0.0,0.00002,0.000001)]
print(eng4)
Sage is able to solve the problem if you declare n. I don't understand what you are trying to do after solving.
#Ideal Gas Law[Relates Pressure and Volume]
#Definitions v3
#Main Tank Pressure[Pascals]
Pp=1013529.32
#Tank Volume[m^3]
Vt=0.0013929
#Moles of Air
#Gas Constant
r=8.3144621
#Ambient Temperature[Kelvin][70F]
t= 294.261
n=var('n')
eng5= solve(Pp*Vt == n*r*t,n,solution_dict=1)
v3=eng5[0]
print eng5Wed, 29 Aug 2012 23:58:48 +0200https://ask.sagemath.org/question/9275/unexpected-solve-errors/?answer=12469#post-id-12469Comment by Shashank for <p>The problem is that xrange gives an empty list so the result is an empty list. Try this </p>
<pre><code>import numpy as np
#Area [m^2]
Ab = 0.00313659226
#CB Ratio
cb = 0.262
Lb=var('Lb')
eng4 =[solve(cb == Vc/(Ab*Lb),Lb) for Vc in np.arange(0.0,0.00002,0.000001)]
print(eng4)
</code></pre>
<p>Sage is able to solve the problem if you declare n. I don't understand what you are trying to do after solving.</p>
<pre><code>#Ideal Gas Law[Relates Pressure and Volume]
#Definitions v3
#Main Tank Pressure[Pascals]
Pp=1013529.32
#Tank Volume[m^3]
Vt=0.0013929
#Moles of Air
#Gas Constant
r=8.3144621
#Ambient Temperature[Kelvin][70F]
t= 294.261
n=var('n')
eng5= solve(Pp*Vt == n*r*t,n,solution_dict=1)
v3=eng5[0]
print eng5
</code></pre>
https://ask.sagemath.org/question/9275/unexpected-solve-errors/?comment=19138#post-id-19138I don't understand what you are trying to do after solving. What is n(V3) supposed to do? But now it does solve the equation.Thu, 30 Aug 2012 17:26:05 +0200https://ask.sagemath.org/question/9275/unexpected-solve-errors/?comment=19138#post-id-19138Comment by duke11235 for <p>The problem is that xrange gives an empty list so the result is an empty list. Try this </p>
<pre><code>import numpy as np
#Area [m^2]
Ab = 0.00313659226
#CB Ratio
cb = 0.262
Lb=var('Lb')
eng4 =[solve(cb == Vc/(Ab*Lb),Lb) for Vc in np.arange(0.0,0.00002,0.000001)]
print(eng4)
</code></pre>
<p>Sage is able to solve the problem if you declare n. I don't understand what you are trying to do after solving.</p>
<pre><code>#Ideal Gas Law[Relates Pressure and Volume]
#Definitions v3
#Main Tank Pressure[Pascals]
Pp=1013529.32
#Tank Volume[m^3]
Vt=0.0013929
#Moles of Air
#Gas Constant
r=8.3144621
#Ambient Temperature[Kelvin][70F]
t= 294.261
n=var('n')
eng5= solve(Pp*Vt == n*r*t,n,solution_dict=1)
v3=eng5[0]
print eng5
</code></pre>
https://ask.sagemath.org/question/9275/unexpected-solve-errors/?comment=19142#post-id-19142That works pretty well, but with 0 as the start it throws an empty list, which screws up my list comprehension. It works pretty well. Do you know about the other problem or whyThu, 30 Aug 2012 14:36:45 +0200https://ask.sagemath.org/question/9275/unexpected-solve-errors/?comment=19142#post-id-19142