View Single Post
  #3  
Old 11-27-2005, 02:02 PM
BruceZ BruceZ is offline
Senior Member
 
Join Date: Sep 2002
Posts: 1,636
Default Re: General Math Question: Position on a circuit

[ 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.
Reply With Quote