# Cycling Breakaway Calculator

Cycling races wouldn't be half as exciting without all the breakaways that we get to see and cheer for during every race. Riders get into breakaways for plenty of reasons - to widen the gap between them and their main rivals on the mountain stages, to grab particular jerseys and win classifications, and, most commonly, to win stages and races. When this happens, there is only one question on the minds of everyone watching - will they make it or not?

And this is where mathematics comes in handy. Professor Hendrik Van Maldeghem, of Ghent University, Belgium, came up with an equation that can, with surprising accuracy, predict whether cyclists will make it or not. He tested it during plenty of races, and the results turned out to be very precise very often. The equation, and as a result our calculator, lets you calculate how much distance the peloton needs to catch the group of riders ahead of them. This calculator takes into consideration the following values:

- Number of riders in the breakaway -
`number_of_sprinters`

- Time gap between the breakaway and the peloton -
`time_gap`

- Speed of peloton -
`peloton_speed`

- Speed of breakaway -
`sprinters_speed`

Different equations are used depending on the number of riders. If there are 10 or more cyclists in the breakaway, the equation assumes they get tired at the same pace as the peloton riding at the same speed (this relation has also been tested). The fewer the number of riders in the breakaway, the more important the role of fatigue is and the shorter the distance the peloton needs to cover to catch them. However, the equation doesn't take into consideration factors such as wind or the road's profile, and will be most accurate on flat stages.

Prof. Van Maldeghem's formula is as follows:

`distance_needed = time_gap * peloton_speed * (6 * peloton_speed / (3 * (peloton_speed - sprinters_speed) + √(6 * peloton_speed * time_gap * (10 - number_of_sprinters) + 9 * (peloton_speed - sprinters_speed)²)) - 1)`

Time gap is expressed in hours, speed in kilometers per hour.