[0] https://manpages.debian.org/bullseye/bsdgames/pom.6.en.html
[1] https://www.cambridge.org/core/books/practical-astronomy-wit...
[2] http://xjubier.free.fr/en/site_pages/LunarEclipseCalculator....
[0] https://manpages.debian.org/bullseye/bsdgames/pom.6.en.html
[1] https://www.cambridge.org/core/books/practical-astronomy-wit...
[2] http://xjubier.free.fr/en/site_pages/LunarEclipseCalculator....
For sunrise/set and moonrise/set calculations you also need to allow for refraction in the Earth's atmosphere (around half a degree or so). Also for moonrise/set you need to allow for the parallax of the Moon's position because you are standing on the surface of the Earth not the centre (up to 1 degree difference in position). This all assumes a spherical Earth and an Ocean horizon. And the rise/set time can changes a little bit with your altitude above the horizon.
For latitudes near the Arctic/Antarctic circles any method based on iteration (as in Duffett-Smith's lovely book) is going to have convergence issues because there might not actually be a rise/set event near that day so if you really want an algorithm that will work anywhere on Earth you'll need to use a method based on fitting a quadratic curve to (say) 24 positions calculated for the day. Have a look at [1] in a library. The code is in Pascal, but it is the search method using a quadratic fit to sets of 3 consecutive positions you want.
Just for low-precision lunar positions, an interesting alternative that also summarises the various methods was produced by NASA [2] for space craft use.
[1] https://link.springer.com/book/10.1007/978-3-642-03436-7