Ask Your Question
0

Unexpected solve() errors

asked 2012-08-29 23:43:08 +0200

anonymous user

Anonymous

updated 2012-08-29 23:50:17 +0200

#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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-08-29 23:58:48 +0200

Shashank gravatar image

updated 2012-08-30 17:25:01 +0200

The 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 eng5
edit flag offensive delete link more

Comments

That 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 why

duke11235 gravatar imageduke11235 ( 2012-08-30 14:36:45 +0200 )edit

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

Shashank gravatar imageShashank ( 2012-08-30 17:26:05 +0200 )edit

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: 2012-08-29 23:43:08 +0200

Seen: 483 times

Last updated: Aug 30 '12