A wheel does not have to be round. What it has to do is keep its middle at one height while it rolls, so that the cart on top of it rides level. On flat ground only a circle can do that. Change the ground, and a square can.
For the curious kid.
Press Flat ground first, to see the problem. A square lying on its side is short: its middle is 1 above the ground. A square standing on a corner is tall: its middle is 1.41 above the ground. So as it rolls along a flat floor its middle goes up and down, up and down, and anything riding on it is shaken to bits.
Now think about the road and not the wheel. If the middle rises by 0.41 whenever the square is up on a corner, dig a valley 0.41 deep for every corner to drop into. Make the valley a square corner, so that the wheel's corner fits. Between two valleys put a bump for the flat side to roll over, exactly as long as the side. Press Its own road and watch the dashed line through the middle of the wheel. It does not move.
The bump cannot be any old bump. Only one curve works, and the lower chart shows how well: the wobble that is left is smaller than one part in ten thousand. Every shape of wheel needs its own road. A pentagon has more sides and blunter corners, so it wants shorter, shallower bumps. A hexagon wants shallower ones still. Keep adding sides and the bumps flatten out until the road is flat and the wheel is a circle. Press The wrong road to put a wheel on a road cut for a different one, and the shaking comes straight back.
One wheel cannot be saved. Try the Triangle. There is a road that would keep its middle level, but the triangle's corners are so sharp that they would have to pass through that road to follow it. So the triangle bumps along no matter what. Four sides is the fewest that can ride smoothly. And yes, people have built this. Stan Wagon, a mathematician in Minnesota, made a tricycle with square wheels in 1997, and it rides beautifully on its bumpy track.
Deeper.
Rolling without slipping means that at each instant the wheel is turning about the point where it touches the road. A point of the wheel directly above that pivot moves sideways and nothing else. So the middle travels level exactly when the middle is always straight above the touching point. Now take a side that is 1 from the middle, lying against the road where the road slopes at an angle θ. The point of that side straight below the middle is 1/cos θ below it. The road must therefore lie 1/cos θ below the axle wherever its slope is θ. Write the road as y(x), with slope y′ = tan θ, and that sentence reads y = −√(1 + y′²). Its solution is y = −cosh x.
That curve is the catenary, the shape of a hanging chain, here turned upside down. A wheel with n sides uses the piece of it from −asinh(tan(π/n)) to +asinh(tan(π/n)). Along that piece the road is 2 tan(π/n) long, which is exactly the length of a side, and it ends at a slope of π/n, so two neighbouring bumps meet in a valley whose angle is the angle of the wheel's corner. All of that falls out of one curve. For the square the bump is 1.76 wide, the valley is √2 deep and the corner in it is a right angle.
The ride is level but not steady. If the wheel turns at an even rate, its middle moves at 1/cos of the angle it has tipped through, so a square's axle goes 41% faster through each valley than over each crest. One full turn carries it 8 asinh(1) = 7.05 forward, less than the 8 of its own rim, because a bumpy road is longer than the ground it covers. The second chart is that speed, forecast and measured.
The wheel on the screen is not following the formula. It is a stiff shape that is told two things: turn a little about the point where you touch, then settle onto the road. The page works out where it touches by looking for the lowest point of its rim. One allowance is made for the real world. A corner that comes down within a fiftieth of a valley seats itself at the bottom, as a real corner would slide into a real notch. The wheel rides level without that. But without it a slip is never forgotten: a square knocked a thousandth out of place jolts by a thousandth at every valley from then on. With it, the next valley puts the wheel right. The triangle's failure is checked the other way round: put it where the formula says, and a corner is a tenth of the wheel's size inside the road.
The curve has a much older job than carrying wheels. This room will show it to you if you type the name of the thing that hangs in that shape: five letters.
The wheel was never the problem. The road was.