How does this magnetic toy work? A nephew of mine has this toy called "Gravitrax". It is basically a track building kit - you can build various tracks for iron balls which go through the track thanks to gravity.
However, there is one component, principle of which I do not understand. It is called "a magnetic cannon" and the image below describes its functionality:

The white wall between balls on the left and the ball which is arriving on the right is magnetic. The red ball is launched in the moment the blue ball hits the magnet. There are a few facts I do not understand:


*

*If there is just one ball on the left (no gray balls), it is not launched at all. When the blue ball hits the magnet, nothing happens. Why?

*If there is already a ball on the right, nothing happens. Why?

*The red ball is launched very fast, even though the blue ball arrives to the magnet very slowly. Where does the momentum of the red ball come from and why is it launched at all?


Could you please explain it to me so I can explain it to my nephew?
This video shows how it works in real life.
 A: I found the following,  the physics of the magnetic cannon:

The magnetic cannon is a simple device that converts magnetic energy into kinetic energy. When a steel ball with low initial velocity impacts a chain consisting of a magnet followed by addition steel balls, the last ball in the chain gets ejected at a much larger velocity. The analysis of this spectacular device involves an understanding of advanced magnetostatics, energy conversion, and the collision of solids. In this article, the phenomena at each step of the process are modeled to predict the final kinetic energy of the ejected ball as a function of a few parameters that can be experimentally measured.

Just found this model for the magnetic cannon.

A magnetic cannon consists of a line of steel balls which are in contact with a permanent magnet. If another steel ball collides with the system on one side, then the ball at the other end of the line is ejected at high speed. A theoretical model is proposed for the system by neglecting energy losses and making the approximation that the magnetic field is uniform near each ball. Our model can account for any magnet shape and is able to accurately predict the most efficient system con figuration, as verified by experiments. Additionally, the predicted values of the ejection velocity are in most cases found to be in reasonable agreement with the experiment.
The magnetic cannon is a simple system that behaves in an unintuitive way. It consists of a line of steel balls, which is placed in contact with a permanent magnet. When another steel ball, initially at rest, is released under the attraction of the magnet, it collides with the line of balls and magnet. Then, the final ball in the line is ejected with a surprisingly high velocity.
At first glance, because the velocity of the ejected ball is much higher than that of the incoming ball, this system appears not to respect the law of conservation of energy. With a closer look, however, the reason for this surprising behaviour is clear: the potential energy of the system is significantly reduced when the incoming ball reaches the line of balls, thus allowing for a substantial increase in kinetic energy.

Here is a simpler system and  model :

The final kinetic energy of the last ball is equal to the change in the magnetic field energy stored in the system. Each cell of the system changes from a configuration of one ball far from the magnet plus two balls in sequence on one side of the magnet to a configuration of one ball far from the magnet plus one ball one each side of the magnet.

Here in this youtube video is a simpler demonstration where only the balls are magnetized.
Note that when the ball is ejected with obviously larger velocity than the incoming, the four magnetically joined  balls go backward, and that is momentum conservation. When you have a fixed magnet in between momentum conservation is is taken up by the much larger mass of the rigid  system.
I do not think it is easy to explain to a child, maybe with hand waving about potential and kinetic energy and magnetic fields he will learn about later. You could demonstrate the attraction to the magnet of steel balls.
