\left(\left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)}\right)}^{2}}
\begin{array}{l}
\mathbf{if}\;U \leq 1.2866515938766426 \cdot 10^{+220}:\\
\;\;\;\;\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \mathsf{hypot}\left(1, \frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)
\end{array}\\
\mathbf{elif}\;U \leq 7.956915989433689 \cdot 10^{+292}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
(FPCore (J K U) :precision binary64 (* (* (* -2.0 J) (cos (/ K 2.0))) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) (cos (/ K 2.0)))) 2.0)))))
(FPCore (J K U)
:precision binary64
(if (<= U 1.2866515938766426e+220)
(let* ((t_0 (cos (/ K 2.0))))
(* (* (* -2.0 J) t_0) (hypot 1.0 (/ U (* t_0 (* J 2.0))))))
(if (<= U 7.956915989433689e+292) (- U) U)))double code(double J, double K, double U) {
return ((-2.0 * J) * cos(K / 2.0)) * sqrt(1.0 + pow((U / ((2.0 * J) * cos(K / 2.0))), 2.0));
}
double code(double J, double K, double U) {
double tmp;
if (U <= 1.2866515938766426e+220) {
double t_0_1 = cos(K / 2.0);
tmp = ((-2.0 * J) * t_0_1) * hypot(1.0, (U / (t_0_1 * (J * 2.0))));
} else if (U <= 7.956915989433689e+292) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
Results
if U < 1.2866515938766426e220Initial program 15.8
Simplified6.3
if 1.2866515938766426e220 < U < 7.9569159894336886e292Initial program 41.5
Simplified26.9
Taylor expanded in J around 0 32.0
if 7.9569159894336886e292 < U Initial program 39.6
Simplified25.0
Taylor expanded in U around -inf 32.1
Final simplification8.2
herbie shell --seed 2022068
(FPCore (J K U)
:name "Maksimov and Kolovsky, Equation (3)"
:precision binary64
(* (* (* -2.0 J) (cos (/ K 2.0))) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) (cos (/ K 2.0)))) 2.0)))))