Baseball and basketball

A baseball is placed on top of a basketball and the two are dropped. When the basketball hits the ground the baseball shoots up, going much higher than the height it had been dropped from. How can we account for this?

The masses of the two balls are in roughly a 3:1 ratio, which is actually a special case for elastic collisions, as we will see.

In the simulation the baseball is separated from the basketball so that we can analyze the different collisions (basketball with ground, baseball with basketball) separately. In reality they take place virtually simultaneously, but the net result is the same.
Part 1 - Both balls are accelerated down by gravity.

Part 2 - The basketball, with speed v down, collides with the floor. Assume this is an elastic collision, so the ball rebounds with speed v up.

Part 3 - The balls collide.

Part 4 - The baseball shoots up.