PDA

View Full Version : General Math Question: Position on a circuit


DavidC
11-27-2005, 10:11 AM
There's a track 300km long. There's a train on the track. The train turns infinitely quickly and has no accelleration. It has a known speed of 20km/h. The train travels for 5 days and 2 hours from the origin. Every time it gets to the endpoint, it turns around, comes back to the origin, and then turns around again...

Total hours travelled: 122. Total Distance travelled: 2440. Total lengths travelled: 8.13...

When lengths are even+ or zero+, the train started the length at the origin, and when lengths are odd+ the train started the length coming towards the origin.

Therefore we can figure out that it's 40km away from the origin at the specified time.

However, I'm curious. Is there an equation that we can write to tell us exactly where the train is without doing this "the long way"?

I mean, I took calculus, and we could answer all kinds of crazy stuff about where a bullet would be at a given time when you shot it directly upwards, but I don't know how to write out this formula.

--Dave.

Edit: Is zero an even number?

AaronBrown
11-27-2005, 12:58 PM
Yes, zero is an even number.

I can't think of an appreciably easier way to get the answer. You might say 30 hours makes no difference, because the train is in the same place, so throw away 4*30 = 120 hours and pretend the train has been running for only 2. That gives the same 40 km. However, that's really the same thing as you did.

Calculus is not much help because of the discontinuities in the train speed. It would be useful if the train accelerated at some rate, or if the track followed some curve with no stops and turns around.

BruceZ
11-27-2005, 02:02 PM
[ QUOTE ]
There's a track 300km long. There's a train on the track. The train turns infinitely quickly and has no accelleration. It has a known speed of 20km/h. The train travels for 5 days and 2 hours from the origin. Every time it gets to the endpoint, it turns around, comes back to the origin, and then turns around again...

Total hours travelled: 122. Total Distance travelled: 2440. Total lengths travelled: 8.13...

When lengths are even+ or zero+, the train started the length at the origin, and when lengths are odd+ the train started the length coming towards the origin.

Therefore we can figure out that it's 40km away from the origin at the specified time.

However, I'm curious. Is there an equation that we can write to tell us exactly where the train is without doing this "the long way"?

I mean, I took calculus, and we could answer all kinds of crazy stuff about where a bullet would be at a given time when you shot it directly upwards, but I don't know how to write out this formula.

--Dave.

[/ QUOTE ]

Try this:

position = (300/pi)*arccos[cos(pi*t/15)]

where t = hours traveled


Explanation:

lengths traveled = 20*t/300 = t/15 = x.d

where x is the integer part and d is the decimal.

We want a position function f(x.d) such that:

f(x.d) = 300*d for x even
f(x.d) = 300*(1-d) for x odd

f(x.d) = 300*triangle(x.d)

where triangle(x.d) is a periodic triangle function:

<font class="small">Code:</font><hr /><pre>

1 /\ /\ /\
/ \/ \/ \...
0 0 2 4 6

</pre><hr />

For example: triangle(4.13) = 0.13 since 4 is even, but triangle(5.13) = 1 - 0.13 since 5 is odd. This satisfies the requirement for f(x.d) above.

To implement this function, we must first periodically wrap all x from [0,infinity] into [0,2]. Note that cos(pi*x) wraps x in [2,4] -&gt; [0,2], [4,6] -&gt; [0,2], etc. as desired. Note that the arccos returns values from 0 to pi, so (1/pi)*arccos[cos(pi*x)] returns values from 0 to 1 as desired. Finally, values of x in [1,2] which came from odd intervals will map to [1,0]. This is triangle(x). Multiplying this by 300 completes the function f(x.d).

Example (even):

f(8.13) = (300/pi)*arccos[cos(pi*8.13)]

f(8.13) = (300/pi)*arccos[cos(pi*0.13)]

f(8.13) = (300/pi)*pi*0.13

f(8.13) = 300*0.13 as desired.


Example (odd):

f(9.13) = (300/pi)*arccos[cos(pi*9.13)]

f(9.13) = (300/pi)*arccos[cos(pi*1.13)]

f(9.13) = (300/pi)*arccos[cos(pi*(1-0.13))]

f(9.13) = (300/pi)*pi*(1 - 0.13)

f(9.13) = 300*(1 - 0.13) as desired.

Be sure your calculator is in radian mode before using this equation (check that cos(pi) = -1).


[ QUOTE ]
Edit: Is zero an even number?

[/ QUOTE ]

Yes, by the definition of even, since it is divisible by 2 with a remainder of 0.

DavidC
11-29-2005, 08:34 AM
I wish my PMs weren't full, or I wouldn't have bumped this post.

Holy crap, dude, this is CRAZY stuff. /images/graemlins/smile.gif

I'm not used to dealing with pi when circles aren't involved, and I'm not used to dealing with arccos ever... I think I did at one point, but the examples were so abstract that hte knowledge didn't stick.

I'm going to have to look at this again, and plug some stuff into my calculator before I get it.

No worries, though. Thanks for your time. Sorry for the bump, too. /images/graemlins/blush.gif