from std.math import floor def minimum_image(dx: Float64, box: Float64) -> Float64: return dx - box * floor(dx / box + 0.5)