\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}\;J \leq -5.875402194156976 \cdot 10^{-300} \lor \neg \left(J \leq 4.0300150493899045 \cdot 10^{-193}\right):\\
\;\;\;\;\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(J \cdot -2\right) \cdot t_0\right) \cdot \mathsf{hypot}\left(1, \frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, \frac{\left(J \cdot J\right) \cdot {\cos \left(K \cdot 0.5\right)}^{2}}{U}, U\right)\\
\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 (<= J -5.875402194156976e-300) (not (<= J 4.0300150493899045e-193)))
(let* ((t_0 (cos (/ K 2.0))))
(* (* (* J -2.0) t_0) (hypot 1.0 (/ U (* t_0 (* J 2.0))))))
(fma 2.0 (/ (* (* J J) (pow (cos (* K 0.5)) 2.0)) U) 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 ((J <= -5.875402194156976e-300) || !(J <= 4.0300150493899045e-193)) {
double t_0_1 = cos(K / 2.0);
tmp = ((J * -2.0) * t_0_1) * hypot(1.0, (U / (t_0_1 * (J * 2.0))));
} else {
tmp = fma(2.0, (((J * J) * pow(cos(K * 0.5), 2.0)) / U), U);
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
if J < -5.8754021941569763e-300 or 4.03001504938990446e-193 < J Initial program 15.0
Simplified6.0
if -5.8754021941569763e-300 < J < 4.03001504938990446e-193Initial program 42.2
Simplified25.8
Taylor expanded in U around -inf 35.8
Simplified35.8
Final simplification9.0
herbie shell --seed 2022020
(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)))))