How to differentiate cosθ from first principles