Spheres are nice and all, but there comes a time when more complex shapes are needed. One popular algorithm for testing collisions is the Gilbert–Johnson–Keerthi algorithm, or GJK for short. With it we can detect collisions between any two convex polygons.
Check out the full article: https://blog.winter.dev/2020/gjk-algorithm/
The textbook An Introduction to the Analysis of Algorithms by Robert Sedgewick and Phillipe Flajolet overviews the primary techniques used in the mathematical analysis of algorithms.
The textbook Analytic Combinatorics by Philippe Flajolet and Robert Sedgewick enables precise quantitative predictions of the properties of large combinatorial structures.