Recently when writing/editing an answer, MathJax has at some point stopped rendering formulas and will only start rendering again if I refresh the page. I've had the problem for maybe a month now. Writing long answers is harrowing as I am afraid that I will lose the work when refreshing, and I do not want to submit before seeing the rendering. Do others have problems and could this be fixed? Things used to work well last year.
I'm running Google Chrome 48.0.2564.109 m in 64-bit Windows 10.
The developer tools console gives this error at the moment things stop working:
Uncaught TypeError: Cannot read property 'insertBefore' of null
https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full:19
The code seems to have been crammed to a single line but if I click that link the cursor goes to:
if(d){d.parentNode.removeChild(d)}b.parentNode.insertBefore(c,b)
I don't have a minimal example but if you copy-paste the following as a new question and write enough new text (100 letters or so, maybe with spaces and line changes) to the beginning or to the end, the error should be reproduced:
You can use logarithms to get rid of the division. For $(x, y)$ in the first quadrant:
$$z = \log_2(y)-\log_2(x)\\
\text{atan2}(y, x) = \text{atan}(y/x) = \text{atan}(2^z)$$
[Figure removed]
*Figure 1. Plot of $\text{atan}(2^z)$*
You would need to approximate $\text{atan}(2^z)$ in range $-30 < z < 30$ to get your required accuracy of 1E-9. You can take advantage of the symmetry $\text{atan}(2^{-z}) = \frac{\pi}{2}-\text{atan}(2^z)$. To approximate $\log_2(a)$:
$$b = \text{floor}(\log_2(a))\\
c = \frac{a}{2^b}\\
\log_2(a) = b + \log_2(c)$$
$b$ can be calculated by finding the location of the most significant non-zero bit. $c$ can be calculated by a bit shift. You would need to approximate $\log_2(c)$ in range $1 \le c < 2$.
[Figure removed]
*Figure 2. Plot of $\log_2(c)$*
For your accuracy requirements, linear interpolation and uniform sampling, $2^{14} + 1 = 16385$ samples of $\log_2(c)$ and $30\times 2^{12} + 1 = 122881$ samples of $\text{atan}(2^z)$ for $0 < z < 30$ should suffice. The latter table is pretty large. With it, the error due to interpolation depends greatly on $z$:
[Figure removed]
*Figure 3. $\text{atan}(2^z)$ approximation largest absolute error for different ranges of $z$ (horizontal axis) for a different number of samples (32 to 8192) per unit interval of $z$. The largest absolute error for $0 \le z < 1$ (omitted) is slightly less than for $\text{floor}(\log_2(z)) = 0$.*
The $\text{atan}(2^z)$ table can be split into multiple subtables that correspond to $0 \le z < 1$ and different $\text{floor}(\log_2(z))$ with $z \ge 1$, which is easy to calculate. The subtable lengths can be chosen as guided by Fig. 3. The within-subtable index can be calculated by a simple bit string manipulation. For your accuracy requirements the $\text{atan}(2^z)$ subtables will have a total of 29217 unique samples if you extend the range of $z$ to $0 \le z < 32$ for simplicity.
The error due to linear interpolation can also be estimated analytically. In the limit of infinitely dense sampling the largest error is halfway between the samples:
$$\left|\hat f(x) - \right| \approx$$
It may be that the new text needs to be written fast enough for the error to occur. If I allow it to finish rendering the page between each keystroke, then there are no problems -- unless it stopped working already at pasting.