Workshop maths is a nice source of small, testable functions. One that comes up whenever a closed band saw blade has to be ordered: given two wheels and the distance between their centres, how long should the loop be?
The formula
For wheel diameters D and d and centre distance C (same unit everywhere):
L = 2C + π(D + d)/2 + (D − d)² / (4C) The first term is the two straight spans, the second is the wrap around the wheels, and the third corrects for unequal wheels, where the tangents are not parallel to the centre line. With equal wheels the third term is zero and you get L = 2C + πD. I first ran into this while reading reference material on metal-cutting band saw blades and wanted a version I could unit-test.
The code
import math def blade_length(C: float, D: float, d: float | None = None) -> float: """Closed belt/blade length for two wheels. C -- centre distance, D -- larger wheel diameter, d -- smaller wheel diameter (defaults to D). All values in the same unit. """ if d is None: d = D if C <= 0 or D <= 0 or d <= 0: raise ValueError("dimensions must be positive") return 2 * C + math.pi * (D + d) / 2 + (D - d) ** 2 / (4 * C) Tests from worked examples
def test_equal_wheels_mm(): assert round(blade_length(620, 400), 2) == 2496.64 def test_equal_wheels_inches(): assert round(blade_length(25, 14), 2) == 93.98 def test_unequal_wheels(): assert round(blade_length(750, 500, 400), 2) == 2917.05 For the unequal example (C = 750, D = 500, d = 400) the correction term is only 3.33 mm. Using the equal-wheel formula with the larger wheel instead would give 3070.80 mm, about 154 mm too long, which is the kind of bug a single test catches immediately.
Practical notes
- Measure
Cbetween shaft centres with the tensioner in mid-travel; a change ΔC movesLby about 2ΔC, so tensioner travel defines your tolerance window. - Measure diameters on the running surface, including tyres.
- Don't mix millimetres and inches; the function won't save you from that.
- Blades are sold in set lengths, so round to a stock length that leaves tensioner travel both ways.
The same function works for flat belts on two pulleys.
Source: Metal-Cutting Band Saw Blades (publisher — Stankotorg), DOI https://doi.org/10.5281/zenodo.23297044

