(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 (* -2.0 (* U -0.5)))
(t_1 (cos (* K 0.5)))
(t_2 (* -2.0 (* (* J t_1) (hypot 1.0 (/ U (* t_1 (* J 2.0))))))))
(if (<= J -1.06e-197)
t_2
(if (<= J 2.7e-303)
t_0
(if (<= J 4e-290) (* -2.0 (* 0.5 U)) (if (<= J 1.6e-250) t_0 t_2))))))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 = -2.0 * (U * -0.5);
double t_1 = cos((K * 0.5));
double t_2 = -2.0 * ((J * t_1) * hypot(1.0, (U / (t_1 * (J * 2.0)))));
double tmp;
if (J <= -1.06e-197) {
tmp = t_2;
} else if (J <= 2.7e-303) {
tmp = t_0;
} else if (J <= 4e-290) {
tmp = -2.0 * (0.5 * U);
} else if (J <= 1.6e-250) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double J, double K, double U) {
return ((-2.0 * J) * Math.cos((K / 2.0))) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * Math.cos((K / 2.0)))), 2.0)));
}
public static double code(double J, double K, double U) {
double t_0 = -2.0 * (U * -0.5);
double t_1 = Math.cos((K * 0.5));
double t_2 = -2.0 * ((J * t_1) * Math.hypot(1.0, (U / (t_1 * (J * 2.0)))));
double tmp;
if (J <= -1.06e-197) {
tmp = t_2;
} else if (J <= 2.7e-303) {
tmp = t_0;
} else if (J <= 4e-290) {
tmp = -2.0 * (0.5 * U);
} else if (J <= 1.6e-250) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(J, K, U): return ((-2.0 * J) * math.cos((K / 2.0))) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * math.cos((K / 2.0)))), 2.0)))
def code(J, K, U): t_0 = -2.0 * (U * -0.5) t_1 = math.cos((K * 0.5)) t_2 = -2.0 * ((J * t_1) * math.hypot(1.0, (U / (t_1 * (J * 2.0))))) tmp = 0 if J <= -1.06e-197: tmp = t_2 elif J <= 2.7e-303: tmp = t_0 elif J <= 4e-290: tmp = -2.0 * (0.5 * U) elif J <= 1.6e-250: tmp = t_0 else: tmp = t_2 return tmp
function code(J, K, U) return Float64(Float64(Float64(-2.0 * J) * cos(Float64(K / 2.0))) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * cos(Float64(K / 2.0)))) ^ 2.0)))) end
function code(J, K, U) t_0 = Float64(-2.0 * Float64(U * -0.5)) t_1 = cos(Float64(K * 0.5)) t_2 = Float64(-2.0 * Float64(Float64(J * t_1) * hypot(1.0, Float64(U / Float64(t_1 * Float64(J * 2.0)))))) tmp = 0.0 if (J <= -1.06e-197) tmp = t_2; elseif (J <= 2.7e-303) tmp = t_0; elseif (J <= 4e-290) tmp = Float64(-2.0 * Float64(0.5 * U)); elseif (J <= 1.6e-250) tmp = t_0; else tmp = t_2; end return tmp end
function tmp = code(J, K, U) tmp = ((-2.0 * J) * cos((K / 2.0))) * sqrt((1.0 + ((U / ((2.0 * J) * cos((K / 2.0)))) ^ 2.0))); end
function tmp_2 = code(J, K, U) t_0 = -2.0 * (U * -0.5); t_1 = cos((K * 0.5)); t_2 = -2.0 * ((J * t_1) * hypot(1.0, (U / (t_1 * (J * 2.0))))); tmp = 0.0; if (J <= -1.06e-197) tmp = t_2; elseif (J <= 2.7e-303) tmp = t_0; elseif (J <= 4e-290) tmp = -2.0 * (0.5 * U); elseif (J <= 1.6e-250) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[J_, K_, U_] := N[(N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(U * -0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(-2.0 * N[(N[(J * t$95$1), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(t$95$1 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.06e-197], t$95$2, If[LessEqual[J, 2.7e-303], t$95$0, If[LessEqual[J, 4e-290], N[(-2.0 * N[(0.5 * U), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.6e-250], t$95$0, t$95$2]]]]]]]
\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 := -2 \cdot \left(U \cdot -0.5\right)\\
t_1 := \cos \left(K \cdot 0.5\right)\\
t_2 := -2 \cdot \left(\left(J \cdot t_1\right) \cdot \mathsf{hypot}\left(1, \frac{U}{t_1 \cdot \left(J \cdot 2\right)}\right)\right)\\
\mathbf{if}\;J \leq -1.06 \cdot 10^{-197}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;J \leq 2.7 \cdot 10^{-303}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 4 \cdot 10^{-290}:\\
\;\;\;\;-2 \cdot \left(0.5 \cdot U\right)\\
\mathbf{elif}\;J \leq 1.6 \cdot 10^{-250}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}



Bits error versus J



Bits error versus K



Bits error versus U
Results
if J < -1.05999999999999997e-197 or 1.60000000000000002e-250 < J Initial program 14.0
Simplified5.0
Applied egg-rr6.1
Applied egg-rr5.0
if -1.05999999999999997e-197 < J < 2.69999999999999986e-303 or 4.0000000000000003e-290 < J < 1.60000000000000002e-250Initial program 43.3
Simplified27.5
Applied egg-rr28.3
Applied egg-rr27.6
Taylor expanded in U around -inf 33.6
Simplified33.6
if 2.69999999999999986e-303 < J < 4.0000000000000003e-290Initial program 46.1
Simplified29.9
Applied egg-rr30.8
Applied egg-rr30.0
Taylor expanded in U around inf 26.7
Simplified26.7
Final simplification8.7
herbie shell --seed 2022156
(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)))))