\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 := \left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 3.759679371723039 \cdot 10^{+307}\right):\\
\;\;\;\;U + 2 \cdot \frac{{\cos \left(K \cdot 0.5\right)}^{2} \cdot \left(J \cdot J\right)}{U}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\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
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 3.759679371723039e+307)))
(+ U (* 2.0 (/ (* (pow (cos (* K 0.5)) 2.0) (* J J)) U)))
t_1)))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 = ((-2.0 * J) * t_0) * sqrt(1.0 + pow((U / (t_0 * (J * 2.0))), 2.0));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 3.759679371723039e+307)) {
tmp = U + (2.0 * ((pow(cos(K * 0.5), 2.0) * (J * J)) / U));
} else {
tmp = t_1;
}
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.0 or 3.75967937172304e307 < (*.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 64.0
Taylor expanded around -inf 31.8
Simplified31.8
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)))) < 3.75967937172304e307Initial program 0.1
rmApplied add-cube-cbrt_binary640.7
Applied associate-*r*_binary640.7
Simplified0.7
rmApplied *-un-lft-identity_binary640.7
Applied sqrt-prod_binary640.7
Applied associate-*r*_binary640.7
Simplified0.1
Final simplification9.3
herbie shell --seed 2021202
(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)))))