\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 -7.46424867012432 \cdot 10^{-294}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;J \leq 4.5127680789433535 \cdot 10^{-253}:\\
\;\;\;\;\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\\
\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 -7.46424867012432e-294)
t_1
(if (<= J 4.5127680789433535e-253)
(fma 2.0 (/ (* (* J J) (pow (cos (* K 0.5)) 2.0)) U) 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 <= -7.46424867012432e-294) {
tmp = t_1;
} else if (J <= 4.5127680789433535e-253) {
tmp = fma(2.0, (((J * J) * pow(cos(K * 0.5), 2.0)) / U), U);
} else {
tmp = t_1;
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
if J < -7.46424867012432064e-294 or 4.51276807894335345e-253 < J Initial program 16.4
Simplified6.6
Applied pow1_binary646.6
Applied pow1_binary646.6
Applied pow-prod-down_binary646.6
Applied pow1_binary646.6
Applied pow-prod-down_binary646.6
Simplified6.6
if -7.46424867012432064e-294 < J < 4.51276807894335345e-253Initial program 42.5
Simplified28.4
Taylor expanded in U around -inf 32.2
Simplified32.2
Final simplification8.2
herbie shell --seed 2022087
(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)))))