E46 BMW Social Directory E46 FAQ 3-Series Discussion Forums BMW Photo Gallery BMW 3-Series Technical Information E46 Fanatics - The Ultimate BMW Resource BMW Vendors General E46 Forum The Tire Rack's Tire Wheel Forum Forced Induction Forum The Off-Topic The E46 BMW Showroom For Sale, For Trade or Wanting to Buy

Welcome to the E46Fanatics forums. E46Fanatics is the premiere website for BMW 3 series owners around the world with interactive forums, a geographical enthusiast directory, photo galleries, and technical information for BMW enthusiasts.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   E46Fanatics > Everything Else > The Off-Topic > General Off-Topic

General Off-Topic
Everything not about BMWs. Posts must be "primetime" safe and in good taste. You must be logged in to see sub-forums.
Click here to browse all new posts.

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 01-15-2013, 04:39 PM   #1
cowmoo32
drunken science
 
cowmoo32's Avatar
 
Join Date: Jul 2003
Location: Raleigh, NC
Posts: 5,532
My Ride: Trek 1.5
CS Guys - Help me out really quick

This is some python code but I fugure the loop logic should be the same in all languages. I'm using this function to plot decay:

100e-t/5

And I need it to step through 1 second intervals 0-->5 and plot the result. I'm sending the results to a 1D array. The array and plotting are working fine but for some reason it's not calculating correctly.

Code:
for j in range(6):
	num2[j] = n2
	n2 = 100*e**(-j/5)
And this is the array that it spits out. I have no clue why it repeats 100 and then jumps down to 36.
Code:
[ 100.          100.           36.78794412   36.78794412   36.78794412    36.78794412]
__________________

flickher

What's this about a brownie in motion?

Last edited by cowmoo32; 01-15-2013 at 04:39 PM.
cowmoo32 is online now   Reply With Quote
Old 01-15-2013, 04:41 PM   #2
Treburkulosis
Registered User
 
Join Date: Dec 2012
Location: somewhere
Posts: 34
My Ride: BMW
about 350
Treburkulosis is offline   Reply With Quote
Old 01-15-2013, 04:43 PM   #3
kuksul08
Registered User
 
Join Date: Sep 2006
Location: California
Posts: 2,108
My Ride: M3
Terrorists win.
__________________

Look at that subtle jet-black coloring. The tasteful thickness of it. Oh my God, it even has a 6mt.
S54 Valve Adjustment Spreadsheet & Info: http://dl.dropbox.com/u/28231781/S54...ent%20info.zip
S54 VANOS DIY Video: http://www.youtube.com/watch?v=9SkT2j3jsU0
kuksul08 is online now   Reply With Quote
Old 01-15-2013, 04:48 PM   #4
NOVAbimmer
Registered User
 
Join Date: Aug 2006
Location: VA
Posts: 12,385
My Ride: 14 Impala FXST M796
42
__________________
NOVAbimmer is online now   Reply With Quote
Old 01-15-2013, 05:16 PM   #5
bioman
Registered User
 
Join Date: May 2003
Location: S.California
Posts: 81
My Ride: is fast.
Is n2's initial value 100? When you calculate n2 for the first loop, you're basically doing 100*1.
bioman is offline   Reply With Quote
Old 01-15-2013, 06:00 PM   #6
cowmoo32
drunken science
 
cowmoo32's Avatar
 
Join Date: Jul 2003
Location: Raleigh, NC
Posts: 5,532
My Ride: Trek 1.5
Quote:
Originally Posted by bioman View Post
Is n2's initial value 100? When you calculate n2 for the first loop, you're basically doing 100*1.
Yeah. And that's correct, at t=0, n2=100. But at t=1, it should be 81.87

edit: Messing with j just shifts the array but still gives the wrong answers. I know it's a simple fix but for whatever reason I'm not seeing it


__________________

flickher

What's this about a brownie in motion?

Last edited by cowmoo32; 01-15-2013 at 06:41 PM.
cowmoo32 is online now   Reply With Quote
Old 01-15-2013, 07:09 PM   #7
cowmoo32
drunken science
 
cowmoo32's Avatar
 
Join Date: Jul 2003
Location: Raleigh, NC
Posts: 5,532
My Ride: Trek 1.5
Ok so something is wrong with the math, not sure why it's doing this
__________________

flickher

What's this about a brownie in motion?
cowmoo32 is online now   Reply With Quote
Old 01-15-2013, 08:59 PM   #8
dreamdrivedrift
Registered User
 
Join Date: Dec 2006
Location: Ithaca, NY --> Baltimore, MD
Posts: 6,461
My Ride: 99 M3 & 95 325i
Send a message via AIM to dreamdrivedrift
didn't really look closely but it looks like you inputted the array value before you actually calculated n2
__________________
Chris
dreamdrivedrift is online now   Reply With Quote
Old 01-15-2013, 09:19 PM   #9
nikkeiS2K
Registered User
 
Join Date: Mar 2005
Location: N/A
Posts: 353
My Ride: N/A
Send a message via ICQ to nikkeiS2K Send a message via AIM to nikkeiS2K Send a message via MSN to nikkeiS2K Send a message via Yahoo to nikkeiS2K
Try using parenthesis.
Does the exp() function work the same way as e**?
I see you have it two different ways.
nikkeiS2K is offline   Reply With Quote
Old 01-15-2013, 09:23 PM   #10
mistrzmiasta
Registered User
 
Join Date: Dec 2006
Location: NYC
Posts: 999
My Ride: GLK350,ML63, Duc1098
just use science.
mistrzmiasta is offline   Reply With Quote
Old 01-15-2013, 09:28 PM   #11
bimmerfan08
Registered User
 
Join Date: Feb 2009
Location: Hampton Roads, VA
Posts: 4,891
My Ride: Phoenix Yellow M3
You're a civil engineer :p
__________________
Quote:
The whole business of politics has been effectively subcontracted out to a band of professionals. Money people, outreach people, message people, research people. The rest of us are meant to feel like amateurs. In the sense of suckers. We become demotivated to learn more about how things work. We begin to opt out.
bimmerfan08 is offline   Reply With Quote
Old 01-15-2013, 09:41 PM   #12
cowmoo32
drunken science
 
cowmoo32's Avatar
 
Join Date: Jul 2003
Location: Raleigh, NC
Posts: 5,532
My Ride: Trek 1.5
I need to set everything in the exp(), or e**, function as a floating point instead of an integer. That was the problem
__________________

flickher

What's this about a brownie in motion?
cowmoo32 is online now   Reply With Quote
Old 01-28-2013, 05:36 PM   #13
cowmoo32
drunken science
 
cowmoo32's Avatar
 
Join Date: Jul 2003
Location: Raleigh, NC
Posts: 5,532
My Ride: Trek 1.5
I'm at a loss here. It keeps telling me I'm using invalid sytanx when delcaring density. I've tried changing the variable name, tried commenting out the else/elif statements even though they work fine, tried putting the equation to the right of it in parentheses, but it keeps telling me the same thing. All I want to do is test to be sure the equation is correct


Code:
height = raw_input('Fall height (meters): ')
height = float(height)

t_0 = 288.15 	# Air temperature (degrees kelvin) at sea level
L = 0.0065 	# Temperature lapse rate (degrees kelvin / m)
R = 287.058 
g = 9.80665
R2 = 8.31432
m = 0.0289644
p_0 = 101325
t_0 = 273.15
Lb = -0.0065
power = (g*m)/(R2*Lb)
temp = 271

if (0.0<=height<100):
	temp = 100

elif (100<=height<200):
	temp = 200

elif (200<=height<300):
	temp = 300

elif (300<=height):
	temp = 400


pressure = p_0*(t_0/(t_0-Lb*(height))**power
density = pressure/(R*temp)

print(temp)
print(pressure)
print(density)
__________________

flickher

What's this about a brownie in motion?

Last edited by cowmoo32; 01-28-2013 at 05:38 PM.
cowmoo32 is online now   Reply With Quote
Old 01-28-2013, 05:39 PM   #14
VaderDave
Invictus
 
VaderDave's Avatar
 
Join Date: Aug 2004
Location: El Dorado Hills, CA
Posts: 11,896
My Ride: 330CiC ZHP
I'm not sure what any of this has to do with customer service.
VaderDave is offline   Reply With Quote
Old 01-28-2013, 05:45 PM   #15
Spiral Prophet
Über-Geek
 
Spiral  Prophet's Avatar
 
Join Date: Dec 1969
Location: Long Island, NY
Posts: 913
My Ride: '01 Topaz Blue 330ci
Send a message via AIM to Spiral  Prophet
The invalid syntax isn't with the density equation.. it's with the line previous.. you're missing a ) in the formula.. you have 3 ( and only 2 )

Python tends to report an invalid syntax at the line after the actual problem

Last edited by Spiral Prophet; 01-28-2013 at 05:46 PM.
Spiral  Prophet is offline   Reply With Quote
Old 01-28-2013, 05:48 PM   #16
cowmoo32
drunken science
 
cowmoo32's Avatar
 
Join Date: Jul 2003
Location: Raleigh, NC
Posts: 5,532
My Ride: Trek 1.5
Quote:
Originally Posted by Spiral Prophet View Post
The invalid syntax isn't with the density equation.. it's with the line previous.. you're missing a ) in the formula.. you have 3 ( and only 2 )

Python tends to report an invalid syntax at the line after the actual problem
This is why I will never code for a living. Small sh!t like this drives me nuts. Thanks.
__________________

flickher

What's this about a brownie in motion?

Last edited by cowmoo32; 01-28-2013 at 05:48 PM.
cowmoo32 is online now   Reply With Quote
Old 01-28-2013, 05:56 PM   #17
Spiral Prophet
Über-Geek
 
Spiral  Prophet's Avatar
 
Join Date: Dec 1969
Location: Long Island, NY
Posts: 913
My Ride: '01 Topaz Blue 330ci
Send a message via AIM to Spiral  Prophet
Quote:
Originally Posted by cowmoo32 View Post
This is why I will never code for a living. Small sh!t like this drives me nuts. Thanks.
not a problem.
Just remember that debuggers are smart but also really dumb.. if it points to something as an error.. the chance of the error being the previous line is just as good as it being where it's pointing.

Coding all day is relaxing as hell..
however coding for micros is in itself a whole other level of hell.. That's what i do all day.
Spiral  Prophet is offline   Reply With Quote
Old 01-28-2013, 06:03 PM   #18
cowmoo32
drunken science
 
cowmoo32's Avatar
 
Join Date: Jul 2003
Location: Raleigh, NC
Posts: 5,532
My Ride: Trek 1.5
It's too tedious for me, I need action. Although I'll admit that when everything works well it does feel good.
__________________

flickher

What's this about a brownie in motion?
cowmoo32 is online now   Reply With Quote
Old 01-28-2013, 06:05 PM   #19
v8 5
Registered User
 
Join Date: Sep 2011
Location: New Jarzy, New Jarzy
Posts: 343
My Ride: 6 speed BMW
Quote:
Originally Posted by kuksul08 View Post
Terrorists win.
__________________
Gutted with a Getrag



We have 4 websites within the family.
v8 5 is offline   Reply With Quote
Old 01-28-2013, 07:10 PM   #20
Grande D
Registered User
 
Join Date: Dec 2006
Location: PA
Posts: 3,326
My Ride: E90 M-Sport
I HATE Python.
Grande D is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Censor is ON





All times are GMT -5. The time now is 01:59 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
(c) 1999 - 2011 performanceIX Inc - privacy policy - terms of use