The approximations work very poorly for anything beyond mid latitudes. Why not use the exact solution which is actually not complicated? For the exact solution, calculate the hour angle between sunrise and sunset. The Day Length in hours is then equal to (https://www.quora.com/How-can-you-calculate-the-length-of-the-day-on-Earth-at-a-given-latitude-on-a-given-date-of-the-year):
Day Length (hours) = 2 * ha / 15, (equation 1)
where ha is the hour angle of sunrise (sunset) from noon and is equal to (http://www.jgiesen.de/astro/suncalc/calculations.htm):
ha = arccos (cos(90.833) /(cos(L)*cos(δ)) - tan(L)*tan(δ)). (equation 2)
This uses 90.833 as the zenith angle of the sun at sunrise/sunset (i.e., it takes into account a standard value of the refraction at sunrise/sunset for the entire world, which is of course only approximate), L is the latitude, δ is the solar declination. The fraction of daylight in the day at latitude L is then,
2 * ha / (15 * 24). (equation 3)
Equation 3 can be used to plot the day-night terminator.
Note, that when the term in the arccos in equation 2 is greater or lesser than 1.0, then there is either total day or total night depending on the value of the declination). As a guide, δ is zero at equinoxes, positive in the northern summer, and negative in the northern winter (see reference 1). Equation 3 applies for all latitudes and for all times!
There are many javascript librarires that calculate δ, and then use it to plot the day-night terminator on google, bing, openstreet, etc. maps. I frankly don't understand why they don't use the exact expression above, which is not any more complicated than the one they typically use that ignores atmospheric refraction altogether (which is not physical at all).
To prove the point I modified the terminator code for Leaflet written by Jorg Dietrich. An expert Javascript coder should optimize my code. Here is the link.