\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 := \mathsf{hypot}\left(1, \frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)\\
\mathbf{if}\;J \leq -3.733683180945843 \cdot 10^{-157}:\\
\;\;\;\;\left(J \cdot -2\right) \cdot \left(t_0 \cdot t_1\right)\\
\mathbf{elif}\;J \leq -7.086648613513012 \cdot 10^{-283}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 9.096025868775934 \cdot 10^{-206}:\\
\;\;\;\;-\mathsf{fma}\left(2, \frac{\left(J \cdot J\right) \cdot {\cos \left(K \cdot 0.5\right)}^{2}}{U}, U\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(\left(J \cdot -2\right) \cdot t_0\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
(let* ((t_0 (cos (/ K 2.0))) (t_1 (hypot 1.0 (/ U (* t_0 (* J 2.0))))))
(if (<= J -3.733683180945843e-157)
(* (* J -2.0) (* t_0 t_1))
(if (<= J -7.086648613513012e-283)
U
(if (<= J 9.096025868775934e-206)
(- (fma 2.0 (/ (* (* J J) (pow (cos (* K 0.5)) 2.0)) U) U))
(* t_1 (* (* J -2.0) t_0)))))))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 = hypot(1.0, (U / (t_0 * (J * 2.0))));
double tmp;
if (J <= -3.733683180945843e-157) {
tmp = (J * -2.0) * (t_0 * t_1);
} else if (J <= -7.086648613513012e-283) {
tmp = U;
} else if (J <= 9.096025868775934e-206) {
tmp = -fma(2.0, (((J * J) * pow(cos((K * 0.5)), 2.0)) / U), U);
} else {
tmp = t_1 * ((J * -2.0) * t_0);
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
if J < -3.7336831809458427e-157Initial program 11.4
Simplified2.8
Applied associate-*l*_binary642.9
if -3.7336831809458427e-157 < J < -7.08664861351301211e-283Initial program 38.1
Simplified24.6
Taylor expanded in U around -inf 35.3
if -7.08664861351301211e-283 < J < 9.09602586877593381e-206Initial program 44.1
Simplified28.3
Taylor expanded in J around 0 33.6
Simplified33.6
if 9.09602586877593381e-206 < J Initial program 12.6
Simplified4.2
Applied pow1_binary644.2
Applied pow1_binary644.2
Applied pow-prod-down_binary644.2
Applied pow1_binary644.2
Applied pow-prod-down_binary644.2
Simplified4.2
Final simplification10.0
herbie shell --seed 2022125
(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)))))