\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(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq -9.456952117734688 \cdot 10^{-234} \lor \neg \left(J \leq 3.848224094713413 \cdot 10^{-273}\right):\\
\;\;\;\;\left(\left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J \cdot t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{{t_0}^{2} \cdot {J}^{2}}{U} - U\\
\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 0.5))))
(if (or (<= J -9.456952117734688e-234) (not (<= J 3.848224094713413e-273)))
(* (* (* J -2.0) (cos (/ K 2.0))) (hypot 1.0 (* 0.5 (/ U (* J t_0)))))
(- (* -2.0 (/ (* (pow t_0 2.0) (pow J 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 t_0 = cos(K * 0.5);
double tmp;
if ((J <= -9.456952117734688e-234) || !(J <= 3.848224094713413e-273)) {
tmp = ((J * -2.0) * cos(K / 2.0)) * hypot(1.0, (0.5 * (U / (J * t_0))));
} else {
tmp = (-2.0 * ((pow(t_0, 2.0) * pow(J, 2.0)) / U)) - U;
}
return tmp;
}



Bits error versus J



Bits error versus K



Bits error versus U
Results
if J < -9.45695211773468832e-234 or 3.84822409471341332e-273 < J Initial program 15.4
Simplified6.0
Applied *-un-lft-identity_binary646.0
Applied times-frac_binary646.0
Taylor expanded in K around inf 6.0
if -9.45695211773468832e-234 < J < 3.84822409471341332e-273Initial program 41.6
Simplified26.5
Applied *-un-lft-identity_binary6426.5
Applied times-frac_binary6426.6
Taylor expanded in U around inf 34.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)))))