Wikipedia:Reference desk/Archives/Mathematics/2013 October 14

= October 14 =

Duplo Train track behavior.
We recently got our granddaughter a set of Duplo train tracks. The set has numerous curves and straights - and two sets of "points" (aka "turnouts", aka "railroad switches"). These have the interesting property that when the train goes across the switch in the "wrong" direction, the switch flips over to make it "right" (real railroad switches do this - it's called "trailing point movement"). Looking at the topmost diagram, here is how the switch behaves:


 * if the train enters the switch from A, then the current switch position (B or C) determines whether it goes towards B or towards C.
 * if the train enters from B then it'll exit at A - and no matter how the switch was previously set, it'll now point towards B.
 * if the train enters from C then it'll exit at A - and no matter how the switch was previously set, it'll now point towards C.

This has some interesting possibilities. It's like a computer with a two-bit memory.

If my track topology is a loop with a diagonal track through it (second diagram), then if the train is travelling counter-clockwise, it'll continue to do so no matter how you fiddle with the switches manually. But if it's going clockwise, then if both switches are at B then it'll continue to do go clockwise, but if either switch is set towards C, then the train will eventually go counter-clockwise and then it's stuck like that. This is really boring!

The next two diagrams are similarly boring, the train always gets "stuck" going around some subset of the track. The leftmost one is fractionally less boring because you can manually flip one of the switches to make the train go somewhere different - but the rightmost layout is another fairly boring one.

But the bottommost diagram is fascinating. The train not only travels along every inch of the track "automatically" - but it does so in both directions without manual intervention! My granddaughter seems to be fascinated by trying to guess where the train will go next. Now, that's fun!

So - my question is, are there any other two-switch topologies that show interesting behavior? Can anyone enumerate all of the logically different track layouts with two turnouts (I don't have any bridges to make figure-8 tracks...but that's another thought). What more complicated behaviors possible if I were to buy two more switches?

SteveBaker (talk) 01:01, 14 October 2013 (UTC)


 * See Laying Track by Ivars Peterson describing results from an article about problems like that. There were some comments on it but they've disappeared. While you're at it you might like clicking on some of the pictures at Pancursal Track Layout which uses simple svg animation.
 * By the way as far as I know you can't make a computer using the switches you describe but you can using ones which switch to the wrong direction if you go the wrong way over them! Dmcq (talk) 10:04, 14 October 2013 (UTC)
 * Thanks! The "Laying Track" article seems to cover it - so there are indeed only five different layouts. The Pancursal article is for tracks where traversing them doesn't switch them (the Brio wooden track is like that) - so his animations don't match what happens with Duplo track. SteveBaker (talk) 15:32, 14 October 2013 (UTC)


 * A little armchair maths:
 * There are basically 2 arrangments you can make with the switches. A loop-plus-diagonal (LPD) as in the first and (sufficiently generalised) second diagram, and a loop-line-loop (LLL) as in the third and fourth diagram (i.e. two loops, connected by a line).
 * Let's take the LLL configuration first. It can be pretty simply split into the individual loops, and just consider what happens with an incoming train or different switch orientations.  If the b or c arm is on the line, then the train will enter, exit the a arm into the loop, come back to the c arm, and then continue around the loop, trapped forever.  If the a arm is on the line, then the train will enter, exit whichever arm is selected (lets say b for this example), travel around the loop, and exit to the line via the c arm, setting the switch to c.  Then the next train that comes along travels the opposite way.  So it looks like the fourth diagram above is the only LLL configuration that does not result in the train getting stuck in a single loop.
 * As for the LPD configuration, the first and second diagrams show the possible conigurations where the a arm is part of the loop for both junctions, and a quick bit of thinking will show that if the a arm is part of the line, the switch will end up set to whichever arm the opposite switch directs the trains to, and the circuit will end up equivalent to the second diagram.
 * So, your list of possible tracks is:
 * An LPD as in the first diagram (c on the line, both switches pointed in the same direction around the loop)
 * An LPD as in the second diagram (c on the line, switches pointed in opposite direcions around the loop)
 * An LPD where one switch has a on the line, and one has c on the line (eventually ends up on half the loop plus the line, defined by where a points for the second switch)
 * An LPD where both switches have a on the line (eventually ends up on half the loop plus the line, defined by the position of the switch where the train first exits the line)
 * An LLL where both switches have c on the line (as in the third diagram)
 * An LLL where one switch has a on the line, and one has c on the line (ends up stuck in the c-loop)
 * An LLL where both switches have a on the line (as in the fourth diagram), the only "interesting" one
 * Anything else with 2 switches will behave as one of the above
 * MChesterMC (talk) 11:11, 14 October 2013 (UTC)


 * So you think there are seven different setups? The "laying track" article claims that there are only five.  I think the three LLL cases you describe are in his article - so I guess you are thinking of two different LPD varients?   I suppose the simple distinction between LLL and LPD is that in every case there are two loops - but in LLL, there is a connecting track between them where in LPD, they share a section between them.  My thinking (at right) is that there ought to be three possible arrangements where there are two separate loops and a connecting track - and three more where two loops share a common track segment - but on that basis, you have one too many combinations and "Laying Track" has one too few (LSL(AA) in my diagram)?  Am I missing something here?  SteveBaker (talk) 15:32, 14 October 2013 (UTC)
 * (Correction): OK - so LSL(AA) and LSL(BB) are kinda-sorta the same thing...nevermind...just five possible layouts. SteveBaker (talk) 15:39, 14 October 2013 (UTC)
 * Ah, yes, my first layout is the same as my third, and my second is the same as my fourth. MChesterMC (talk) 08:09, 15 October 2013 (UTC)
 * Ah I knew I'd read something besides the MathTrek page about this. In Eureka 53 February 1994 they had an article Train Sets by Adam Chalcraft and Michael Greene, there's a copy at Train Sets. If you search for 'Turing Train' you'll find lots of trains chugging round the place computing things. Dmcq (talk) 12:26, 14 October 2013 (UTC)
 * These track layouts seem to function like finite automata to me or in other words, like state machines. We studied these in my Game Theory class as tools for describing some strategies for infinitely repeated games. The switches here seems a like transistors in that there are 3 'leads' and 2 of them have the same 'charge.' Depending on the direction of 'current flow' or in other words, which direction the train enters the switch, there will be either only one possible exit path, or perhaps two. (it especially makes me think of the difference between NPN and PNP transistors). You could also represent the track layouts as directed graphs 69.54.132.120 (talk) 00:11, 22 October 2013 (UTC)

Laplace's Method for Integrals
Practicing using Laplace's Method, and working from de Bruijin and having a little bit of difficult with the approximation on the boundary, in particular taking $$\int^{\pi}_{0} x^n \sin(x) dx$$ and applying the approximation as $$n \to \infty$$, notably because the maximum of n(log(x)) is at pi in this case, and so the method gives 0 because sin(pi)=0? Any suggestions? — Preceding unsigned comment added by 130.102.158.15 (talk) 02:15, 14 October 2013 (UTC)

In general, after rescaling to make the integration limits equal to 0 and 1, you can write

$$ \int_{0}^{1}x^{n}f(x)dx = \frac{1}{n+1}\int_{0}^{\infty}\exp(-u)f\left[ \exp \left(-\frac{u}{n+1} \right) \right]du $$

If f(1) is not zero, the leading contribution will be f(1)/(n+1). But in this case that isn't the case, so to get the leading contribution, you need to beyond this approximation.Count Iblis (talk) 17:23, 14 October 2013 (UTC)

You can expand:

f[exp(-u/(n+1))] = f[1 - u/(n+1) + 1/2 u^2/(n+1)^2+...]

= f(1) + [-u/(n+1) + 1/2 u^2/(n+1)^2+...] f'(1) + 1/2 [u^2/(n+1)^2 + ...]f^((2))(1) + ...

Then if f(1) = 0, the leading contribution to the asymptotic expansion becomes:

-1/(n+1)^2 f'(1)

Count Iblis (talk) 17:36, 14 October 2013 (UTC)

How to turn difficult probabilities into a simple sum a non-mathematician can use
I'm looking for the way very difficult statistics are sometimes turned into easy questionnaires that have reasonably precise results.

Let's say I'm a judge and I want to know what the odds are the thief will steal again after he is released from prison. I'm not a mathematician, so I need a form with questions like "has a girlfriend -> add 2 points", "never stolen before -> add 5", "someone close says he's a pathetic lier -> subtract 4", "says he's sorry -> add 1", and after adding it all up it says "10-15 points: 30%".

Similar forms could be made for a doctor with a difficult decision to operate or not, even being able to show the patient why he decided not to. I've seen some of those, but how are they constructed? I guess its got something to do with Bayes' theorem? I can imagine that question 4 might have to be like "add 3 points, unless question 2 was also positive then just add 1" for added precision, but the questionnaire shouldn't be much harder than that and still give a quite accurate estimate of the chances. Joepnl (talk) 22:39, 14 October 2013 (UTC)
 * I guess Bayes theorem tells you how to update probabilities. Let S be the event that the thief will steal again. Let $$E$$ be some evidence. Then $$P(S|E) = \frac{P(E|S)P(S)}{P(E|S)P(S)+P(E|!S)P(!S)}$$. P(S|E) is the probability the thief will steal again knowing the evidence E (what we want to find). P(S) is the probability absent that evidence. P(E|S) is the probability that evidence would arise if we know the thief will steal again. Widener (talk) 23:58, 14 October 2013 (UTC)
 * I think you misunderstand the nature of evidence, by the way. The fact that someone has a girlfriend, has never stolen before, or someone close says he's a pathetic liar, is not evidence he will steal again (in those cases $$P(E|S) = P(E)$$ and therefore $$P(S|E) = P(S)$$). Widener (talk) 00:05, 15 October 2013 (UTC)


 * Logistic regression is tailor-made for questions of the form "What are the odds that ... given various explanatory variables?". Duoduoduo (talk) 11:47, 15 October 2013 (UTC)