\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 := \sqrt{1 + {\left(\frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
t_2 := \left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot t_1\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;-2 \cdot \frac{{\cos \left(K \cdot 0.5\right)}^{2} \cdot \left(J \cdot J\right)}{U} - U\\
\mathbf{elif}\;t_2 \leq 6.6651908102113915 \cdot 10^{+295}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \left(t_0 \cdot 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 (sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))
(t_2 (* (* (* -2.0 J) t_0) t_1)))
(if (<= t_2 (- INFINITY))
(- (* -2.0 (/ (* (pow (cos (* K 0.5)) 2.0) (* J J)) U)) U)
(if (<= t_2 6.6651908102113915e+295) (* (* -2.0 J) (* t_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 = sqrt(1.0 + pow((U / (t_0 * (J * 2.0))), 2.0));
double t_2 = ((-2.0 * J) * t_0) * t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (-2.0 * ((pow(cos(K * 0.5), 2.0) * (J * J)) / U)) - U;
} else if (t_2 <= 6.6651908102113915e+295) {
tmp = (-2.0 * J) * (t_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)))) < -inf.0Initial program 64.0
rmApplied flip3-+_binary6464.0
Applied sqrt-div_binary6464.0
Applied associate-*r/_binary6464.0
Simplified64.0
Taylor expanded around inf 31.5
Simplified31.5
if -inf.0 < (*.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)))) < 6.6651908102113915e295Initial program 0.1
rmApplied associate-*l*_binary640.2
if 6.6651908102113915e295 < (*.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 58.8
Taylor expanded around -inf 33.6
Final simplification9.6
herbie shell --seed 2021205
(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)))))