\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(J \cdot -2\right) \cdot t_0\right) \cdot \mathsf{hypot}\left(1, \frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)\\
\mathbf{if}\;J \leq -3.678515660926543 \cdot 10^{-236}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \mathsf{fma}\left(2, \frac{\left(J \cdot J\right) \cdot {\cos \left(K \cdot 0.5\right)}^{2}}{U}, U\right)\\
\mathbf{if}\;J \leq -2.0731189763801308 \cdot 10^{-263}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;J \leq 2.3963648443487414 \cdot 10^{-281}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 2.7554685803717827 \cdot 10^{-249}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\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 (* (* (* J -2.0) t_0) (hypot 1.0 (/ U (* t_0 (* J 2.0)))))))
(if (<= J -3.678515660926543e-236)
t_1
(let* ((t_2 (fma 2.0 (/ (* (* J J) (pow (cos (* K 0.5)) 2.0)) U) U)))
(if (<= J -2.0731189763801308e-263)
t_2
(if (<= J 2.3963648443487414e-281)
(- U)
(if (<= J 2.7554685803717827e-249) t_2 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 = ((J * -2.0) * t_0) * hypot(1.0, (U / (t_0 * (J * 2.0))));
double tmp;
if (J <= -3.678515660926543e-236) {
tmp = t_1;
} else {
double t_2 = fma(2.0, (((J * J) * pow(cos(K * 0.5), 2.0)) / U), U);
double tmp_1;
if (J <= -2.0731189763801308e-263) {
tmp_1 = t_2;
} else if (J <= 2.3963648443487414e-281) {
tmp_1 = -U;
} else if (J <= 2.7554685803717827e-249) {
tmp_1 = t_2;
} else {
tmp_1 = t_1;
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
if J < -3.67851566092654312e-236 or 2.7554685803717827e-249 < J Initial program 15.1
Simplified5.5
if -3.67851566092654312e-236 < J < -2.07311897638013076e-263 or 2.3963648443487414e-281 < J < 2.7554685803717827e-249Initial program 41.1
Simplified25.6
Taylor expanded in U around -inf 35.9
Simplified35.9
if -2.07311897638013076e-263 < J < 2.3963648443487414e-281Initial program 46.4
Simplified32.1
Taylor expanded in J around 0 32.2
Simplified32.2
Final simplification8.4
herbie shell --seed 2022019
(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)))))