\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 -9.456952117734688 \cdot 10^{-234} \lor \neg \left(J \leq 3.848224094713413 \cdot 10^{-273}\right):\\
\;\;\;\;\begin{array}{l}
t_0 := \left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\\
t_0 \cdot \mathsf{hypot}\left(1, \frac{-U}{t_0}\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 -9.456952117734688e-234) (not (<= J 3.848224094713413e-273)))
(let* ((t_0 (* (* J -2.0) (cos (/ K 2.0)))))
(* t_0 (hypot 1.0 (/ (- U) t_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 <= -9.456952117734688e-234) || !(J <= 3.848224094713413e-273)) {
double t_0_1 = (J * -2.0) * cos(K / 2.0);
tmp = t_0_1 * hypot(1.0, (-U / t_0_1));
} 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 < -9.45695211773468832e-234 or 3.84822409471341332e-273 < J Initial program 15.4
Simplified6.0
Applied frac-2neg_binary646.0
Simplified6.0
if -9.45695211773468832e-234 < J < 3.84822409471341332e-273Initial program 41.6
Simplified26.5
Taylor expanded in J around 0 34.0
Simplified34.0
Final simplification8.5
herbie shell --seed 2021329
(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)))))