\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 2.851168173361108 \cdot 10^{+219} \lor \neg \left(U \leq 5.629354276877763 \cdot 10^{+291}\right):\\
\;\;\;\;\begin{array}{l}
t_0 := \left(-2 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right)\\
t_0 \cdot \mathsf{hypot}\left(1, \frac{-U}{t_0}\right)
\end{array}\\
\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 (or (<= U 2.851168173361108e+219) (not (<= U 5.629354276877763e+291)))
(let* ((t_0 (* (* -2.0 J) (cos (/ K 2.0)))))
(* t_0 (hypot 1.0 (/ (- U) t_0))))
(- 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 <= 2.851168173361108e+219) || !(U <= 5.629354276877763e+291)) {
double t_0_1 = (-2.0 * J) * cos(K / 2.0);
tmp = t_0_1 * hypot(1.0, (-U / t_0_1));
} else {
tmp = -U;
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
Results
if U < 2.8511681733611083e219 or 5.62935427687776278e291 < U Initial program 17.0
Simplified6.8
Applied frac-2neg_binary646.8
if 2.8511681733611083e219 < U < 5.62935427687776278e291Initial program 41.7
Simplified27.1
Taylor expanded in J around 0 32.9
Simplified32.9
Final simplification8.3
herbie shell --seed 2022039
(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)))))