What kind of times do you need? There are several defintions for "rise" and "sunset" (i.e. civil, nautical, astronomical). When comparing to published tables, you also need to know how those tables were calculated (geocentric position or not, standard time or true local time, and so on) and what result the used algorithms gives you. There are also some approximated algorithms using just a few terms and more precise one using much more. Also, be aware of the IEEE floating point issues, in some situations they can decrease precision a lot.
One of the best sources for such algorithms is Jean Meeus' Astronomical Algorithms (1998), 2nd edition