\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 5.7011378908621385 \cdot 10^{+302}:\\
\;\;\;\;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)))) 5.7011378908621385e+302)
(* 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))) <= 5.7011378908621385e+302) {
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)))) < 5.70113789086213847e302Initial program 10.3
Simplified4.7
if 5.70113789086213847e302 < (*.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 61.4
Simplified27.5
Taylor expanded in J around 0 33.4
Simplified33.4
Final simplification8.8
herbie shell --seed 2021313
(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)))))