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.Tue, 28 Aug 2012 18:20:18 +0200What's Wrong With This?https://ask.sagemath.org/question/9273/whats-wrong-with-this/ #Pneumatic Air Gun Calculations
import matplotlib.pyplot as plt
#Variables Outlined
#Muzzle Velocity
Vm=var('Vm')
#Atmospheric Pressure
Patm=var('Patm')
#Gas Chamber Volume
Vc=var('Vc')
#Barrel Area[Internal]
Ab=var('Ab')
#Barrel Length
Lb=var('Lb')
#Specific Heat of Air
k=var('k')
#CB Ratio[see table]
cb=var('cb')
#formula variable
eng=var('eng')
#2nd Formula Variable
eng2=var('eng2')
#Mass of the Projectile
md=var('md')
#Operating Pressure in atm
Pc=var('Pc')
#Definitions
k = 1.4
Patm = 101235
cb = 0.261208
#m/s^2
Vm= 91.44
md=2
Pc=10
eng=0.618081
#Main Formula
solve(eng=(k-1)*md*Vm^2/(2*Patm*Vc*(Pc-Pc^(1/k)),Vc)
Can anyone tell me why this is giving a syntax error and pointing to my variable definition Vm? It's really bugging me!Tue, 28 Aug 2012 17:55:37 +0200https://ask.sagemath.org/question/9273/whats-wrong-with-this/Answer by DSM for <pre><code>#Pneumatic Air Gun Calculations
import matplotlib.pyplot as plt
#Variables Outlined
#Muzzle Velocity
Vm=var('Vm')
#Atmospheric Pressure
Patm=var('Patm')
#Gas Chamber Volume
Vc=var('Vc')
#Barrel Area[Internal]
Ab=var('Ab')
#Barrel Length
Lb=var('Lb')
#Specific Heat of Air
k=var('k')
#CB Ratio[see table]
cb=var('cb')
#formula variable
eng=var('eng')
#2nd Formula Variable
eng2=var('eng2')
#Mass of the Projectile
md=var('md')
#Operating Pressure in atm
Pc=var('Pc')
#Definitions
k = 1.4
Patm = 101235
cb = 0.261208
#m/s^2
Vm= 91.44
md=2
Pc=10
eng=0.618081
#Main Formula
solve(eng=(k-1)*md*Vm^2/(2*Patm*Vc*(Pc-Pc^(1/k)),Vc)
</code></pre>
<p>Can anyone tell me why this is giving a syntax error and pointing to my variable definition Vm? It's really bugging me!</p>
https://ask.sagemath.org/question/9273/whats-wrong-with-this/?answer=13969#post-id-13969Your solve syntax has two minor problems. First, Sage uses `==` for equality, not `=`, and second, the parentheses aren't balanced. You're missing "`)`". After correcting these:
sage: solve(eng==(k-1)*md*Vm^2/(2*Patm*Vc*(Pc-Pc^(1/k))),Vc)
[Vc == (1821842000000/164304225615681)]
Tue, 28 Aug 2012 18:20:18 +0200https://ask.sagemath.org/question/9273/whats-wrong-with-this/?answer=13969#post-id-13969