\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}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \frac{U}{t_0 \cdot \left(J \cdot 2\right)}\\
t_2 := \left(-2 \cdot J\right) \cdot t_0\\
\mathbf{if}\;t_2 \cdot \sqrt{1 + {t_1}^{2}} \leq 1.036085576853195 \cdot 10^{+305}:\\
\;\;\;\;t_2 \cdot \mathsf{hypot}\left(1, t_1\right)\\
\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
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (/ U (* t_0 (* J 2.0))))
(t_2 (* (* -2.0 J) t_0)))
(if (<= (* t_2 (sqrt (+ 1.0 (pow t_1 2.0)))) 1.036085576853195e+305)
(* t_2 (hypot 1.0 t_1))
(- 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 t_0 = cos((K / 2.0));
double t_1 = U / (t_0 * (J * 2.0));
double t_2 = (-2.0 * J) * t_0;
double tmp;
if ((t_2 * sqrt((1.0 + pow(t_1, 2.0)))) <= 1.036085576853195e+305) {
tmp = t_2 * hypot(1.0, t_1);
} else {
tmp = -U;
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
Results
if (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < 1.036085576853195e305Initial program 10.4
Simplified4.5
if 1.036085576853195e305 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) Initial program 62.8
Simplified28.6
Taylor expanded in J around 0 31.2
Simplified31.2
Final simplification8.3
herbie shell --seed 2022130
(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)))))