\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.728300495480963 \cdot 10^{+268}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;\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}\\
\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.728300495480963e+268)
(- U)
(let* ((t_0 (cos (/ K 2.0))))
(* (* (* -2.0 J) t_0) (hypot 1.0 (/ U (* t_0 (* J 2.0))))))))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.728300495480963e+268) {
tmp = -U;
} else {
double t_0 = cos(K / 2.0);
tmp = ((-2.0 * J) * t_0) * hypot(1.0, (U / (t_0 * (J * 2.0))));
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
Results
if U < -1.7283004954809631e268Initial program 45.1
Simplified30.9
Taylor expanded in J around 0 35.9
Simplified35.9
if -1.7283004954809631e268 < U Initial program 15.8
Simplified6.7
Final simplification7.7
herbie shell --seed 2022067
(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)))))