\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 -5.636250867741126 \cdot 10^{-255}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;J \leq -2.4993835334593255 \cdot 10^{-282}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 3.0750365055579345 \cdot 10^{-288}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.9339533218706902 \cdot 10^{-169}:\\
\;\;\;\;-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 (* (* (* J -2.0) t_0) (hypot 1.0 (/ U (* t_0 (* J 2.0)))))))
(if (<= J -5.636250867741126e-255)
t_1
(if (<= J -2.4993835334593255e-282)
(- U)
(if (<= J 3.0750365055579345e-288)
U
(if (<= J 1.9339533218706902e-169) (- 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 = ((J * -2.0) * t_0) * hypot(1.0, (U / (t_0 * (J * 2.0))));
double tmp;
if (J <= -5.636250867741126e-255) {
tmp = t_1;
} else if (J <= -2.4993835334593255e-282) {
tmp = -U;
} else if (J <= 3.0750365055579345e-288) {
tmp = U;
} else if (J <= 1.9339533218706902e-169) {
tmp = -U;
} else {
tmp = t_1;
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
Results
if J < -5.6362508677411259e-255 or 1.9339533218706902e-169 < J Initial program 14.0
Simplified5.0
if -5.6362508677411259e-255 < J < -2.4993835334593255e-282 or 3.07503650555793452e-288 < J < 1.9339533218706902e-169Initial program 39.9
Simplified24.6
Taylor expanded around 0 33.5
Simplified33.5
if -2.4993835334593255e-282 < J < 3.07503650555793452e-288Initial program 45.9
Simplified27.3
Taylor expanded around -inf 31.1
Final simplification9.6
herbie shell --seed 2021211
(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)))))