Ask Your Question
0

Unexpected solve() errors

asked 12 years ago

anonymous user

Anonymous

updated 12 years ago

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

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 12 years ago

Shashank gravatar image

updated 12 years ago

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
Preview: (hide)
link

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 ( 12 years ago )

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 ( 12 years ago )

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: 12 years ago

Seen: 928 times

Last updated: Aug 30 '12