I did a lot of maths in college before I moved onto programming and computer science, but I also found the problem hard. I think I could probably work it out from first principles eventually, but it's surprising how much calculus and trig comes down to memorising rules.