(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 (<= U -2.1573275483081895e+221)
(* -2.0 (* U 0.5))
(*
-2.0
(*
(hypot 1.0 (/ U (* (cos (* 0.5 K)) (* 2.0 J))))
(* J (cos (/ K 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 (U <= -2.1573275483081895e+221) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = -2.0 * (hypot(1.0, (U / (cos((0.5 * K)) * (2.0 * J)))) * (J * cos((K / 2.0))));
}
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 tmp;
if (U <= -2.1573275483081895e+221) {
tmp = -2.0 * (U * 0.5);
} else {
tmp = -2.0 * (Math.hypot(1.0, (U / (Math.cos((0.5 * K)) * (2.0 * J)))) * (J * Math.cos((K / 2.0))));
}
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): tmp = 0 if U <= -2.1573275483081895e+221: tmp = -2.0 * (U * 0.5) else: tmp = -2.0 * (math.hypot(1.0, (U / (math.cos((0.5 * K)) * (2.0 * J)))) * (J * math.cos((K / 2.0)))) 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) tmp = 0.0 if (U <= -2.1573275483081895e+221) tmp = Float64(-2.0 * Float64(U * 0.5)); else tmp = Float64(-2.0 * Float64(hypot(1.0, Float64(U / Float64(cos(Float64(0.5 * K)) * Float64(2.0 * J)))) * Float64(J * cos(Float64(K / 2.0))))); 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) tmp = 0.0; if (U <= -2.1573275483081895e+221) tmp = -2.0 * (U * 0.5); else tmp = -2.0 * (hypot(1.0, (U / (cos((0.5 * K)) * (2.0 * J)))) * (J * cos((K / 2.0)))); 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_] := If[LessEqual[U, -2.1573275483081895e+221], N[(-2.0 * N[(U * 0.5), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[Sqrt[1.0 ^ 2 + N[(U / N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * N[(J * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\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}\;U \leq -2.1573275483081895 \cdot 10^{+221}:\\
\;\;\;\;-2 \cdot \left(U \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(\mathsf{hypot}\left(1, \frac{U}{\cos \left(0.5 \cdot K\right) \cdot \left(2 \cdot J\right)}\right) \cdot \left(J \cdot \cos \left(\frac{K}{2}\right)\right)\right)\\
\end{array}



Bits error versus J



Bits error versus K



Bits error versus U
Results
if U < -2.1573275483081895e221Initial program 41.4
Simplified25.6
Taylor expanded in U around inf 32.7
if -2.1573275483081895e221 < U Initial program 16.2
Simplified6.3
Applied egg-rr6.3
Final simplification8.2
herbie shell --seed 2022153
(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)))))