\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}
\mathbf{if}\;J \leq -3.2764703254569817 \cdot 10^{-226}:\\
\;\;\;\;\left(\left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{elif}\;J \leq 4.665136132356276 \cdot 10^{-203}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.9974033146612488 \cdot 10^{-157}:\\
\;\;\;\;-U\\
\mathbf{elif}\;J \leq 5.037250337742537 \cdot 10^{-81}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;\left(\left(J \cdot -2\right) \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{\cos \left(\frac{K}{2}\right) \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\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
(if (<= J -3.2764703254569817e-226)
(*
(* (* J -2.0) (cos (/ K 2.0)))
(sqrt (+ 1.0 (pow (/ U (* (cos (/ K 2.0)) (* J 2.0))) 2.0))))
(if (<= J 4.665136132356276e-203)
U
(if (<= J 1.9974033146612488e-157)
(- U)
(if (<= J 5.037250337742537e-81)
U
(*
(* (* J -2.0) (cos (/ K 2.0)))
(sqrt (+ 1.0 (pow (/ U (* (cos (/ K 2.0)) (* J 2.0))) 2.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 tmp;
if (J <= -3.2764703254569817e-226) {
tmp = ((J * -2.0) * cos(K / 2.0)) * sqrt(1.0 + pow((U / (cos(K / 2.0) * (J * 2.0))), 2.0));
} else if (J <= 4.665136132356276e-203) {
tmp = U;
} else if (J <= 1.9974033146612488e-157) {
tmp = -U;
} else if (J <= 5.037250337742537e-81) {
tmp = U;
} else {
tmp = ((J * -2.0) * cos(K / 2.0)) * sqrt(1.0 + pow((U / (cos(K / 2.0) * (J * 2.0))), 2.0));
}
return tmp;
}








Bits error versus J








Bits error versus K








Bits error versus U
Results
| Alternative 1 | |
|---|---|
| Error | 27.2 |
| Cost | 20866 |
| Alternative 2 | |
|---|---|
| Error | 27.0 |
| Cost | 8132 |
| Alternative 3 | |
|---|---|
| Error | 46.8 |
| Cost | 449 |
| Alternative 4 | |
|---|---|
| Error | 46.6 |
| Cost | 64 |
| Alternative 5 | |
|---|---|
| Error | 61.9 |
| Cost | 64 |

if J < -3.27647032545698172e-226 or 5.0372503377425366e-81 < J Initial program 11.4
Simplified11.4
if -3.27647032545698172e-226 < J < 4.66513613235627618e-203 or 1.99740331466124876e-157 < J < 5.0372503377425366e-81Initial program 38.8
Taylor expanded around -inf 34.8
Simplified34.8
if 4.66513613235627618e-203 < J < 1.99740331466124876e-157Initial program 35.0
Taylor expanded around 0 39.0
Simplified39.0
Simplified39.0
Final simplification17.4
herbie shell --seed 2021044
(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)))))