
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t_0}\right)}^{2}}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
}
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t_0}\right)}^{2}}
\end{array}
\end{array}
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (* J t_0))
(t_2
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_2 (- INFINITY))
(* -2.0 (* U_m 0.5))
(if (<= t_2 4e+302)
(* -2.0 (* t_1 (hypot 1.0 (/ (/ U_m 2.0) t_1))))
(* -2.0 (* U_m -0.5))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = J * t_0;
double t_2 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -2.0 * (U_m * 0.5);
} else if (t_2 <= 4e+302) {
tmp = -2.0 * (t_1 * hypot(1.0, ((U_m / 2.0) / t_1)));
} else {
tmp = -2.0 * (U_m * -0.5);
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = Math.cos((K / 2.0));
double t_1 = J * t_0;
double t_2 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = -2.0 * (U_m * 0.5);
} else if (t_2 <= 4e+302) {
tmp = -2.0 * (t_1 * Math.hypot(1.0, ((U_m / 2.0) / t_1)));
} else {
tmp = -2.0 * (U_m * -0.5);
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = J * t_0 t_2 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U_m / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_2 <= -math.inf: tmp = -2.0 * (U_m * 0.5) elif t_2 <= 4e+302: tmp = -2.0 * (t_1 * math.hypot(1.0, ((U_m / 2.0) / t_1))) else: tmp = -2.0 * (U_m * -0.5) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(J * t_0) t_2 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U_m / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(-2.0 * Float64(U_m * 0.5)); elseif (t_2 <= 4e+302) tmp = Float64(-2.0 * Float64(t_1 * hypot(1.0, Float64(Float64(U_m / 2.0) / t_1)))); else tmp = Float64(-2.0 * Float64(U_m * -0.5)); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); t_1 = J * t_0; t_2 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U_m / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_2 <= -Inf) tmp = -2.0 * (U_m * 0.5); elseif (t_2 <= 4e+302) tmp = -2.0 * (t_1 * hypot(1.0, ((U_m / 2.0) / t_1))); else tmp = -2.0 * (U_m * -0.5); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(J * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U$95$m / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e+302], N[(-2.0 * N[(t$95$1 * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / t$95$1), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(U$95$m * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := J \cdot t_0\\
t_2 := \left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U_m}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;-2 \cdot \left(U_m \cdot 0.5\right)\\
\mathbf{elif}\;t_2 \leq 4 \cdot 10^{+302}:\\
\;\;\;\;-2 \cdot \left(t_1 \cdot \mathsf{hypot}\left(1, \frac{\frac{U_m}{2}}{t_1}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot -0.5\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < -inf.0Initial program 6.5%
associate-*l*6.5%
associate-*l*6.5%
unpow26.5%
sqr-neg6.5%
distribute-frac-neg6.5%
distribute-frac-neg6.5%
unpow26.5%
Simplified67.3%
Taylor expanded in U around inf 35.6%
if -inf.0 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < 4.0000000000000003e302Initial program 99.8%
associate-*l*99.8%
associate-*l*99.8%
unpow299.8%
sqr-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg99.8%
unpow299.8%
Simplified99.8%
if 4.0000000000000003e302 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) Initial program 5.0%
associate-*l*5.0%
associate-*l*5.0%
unpow25.0%
sqr-neg5.0%
distribute-frac-neg5.0%
distribute-frac-neg5.0%
unpow25.0%
Simplified70.1%
Taylor expanded in U around -inf 54.0%
*-commutative54.0%
Simplified54.0%
Final simplification83.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 1.95e+223) (* -2.0 (* (cos (* K 0.5)) (* J (hypot 1.0 (/ U_m (* J 2.0)))))) (* -2.0 (* U_m 0.5))))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.95e+223) {
tmp = -2.0 * (cos((K * 0.5)) * (J * hypot(1.0, (U_m / (J * 2.0)))));
} else {
tmp = -2.0 * (U_m * 0.5);
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 1.95e+223) {
tmp = -2.0 * (Math.cos((K * 0.5)) * (J * Math.hypot(1.0, (U_m / (J * 2.0)))));
} else {
tmp = -2.0 * (U_m * 0.5);
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 1.95e+223: tmp = -2.0 * (math.cos((K * 0.5)) * (J * math.hypot(1.0, (U_m / (J * 2.0))))) else: tmp = -2.0 * (U_m * 0.5) return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 1.95e+223) tmp = Float64(-2.0 * Float64(cos(Float64(K * 0.5)) * Float64(J * hypot(1.0, Float64(U_m / Float64(J * 2.0)))))); else tmp = Float64(-2.0 * Float64(U_m * 0.5)); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (U_m <= 1.95e+223) tmp = -2.0 * (cos((K * 0.5)) * (J * hypot(1.0, (U_m / (J * 2.0))))); else tmp = -2.0 * (U_m * 0.5); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 1.95e+223], N[(-2.0 * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * N[Sqrt[1.0 ^ 2 + N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U_m \leq 1.95 \cdot 10^{+223}:\\
\;\;\;\;-2 \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{U_m}{J \cdot 2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot 0.5\right)\\
\end{array}
\end{array}
if U < 1.9499999999999999e223Initial program 74.0%
associate-*l*74.0%
associate-*l*74.0%
unpow274.0%
sqr-neg74.0%
distribute-frac-neg74.0%
distribute-frac-neg74.0%
unpow274.0%
Simplified92.4%
Taylor expanded in K around 0 75.7%
Applied egg-rr31.7%
expm1-def45.8%
expm1-log1p75.7%
*-commutative75.7%
*-commutative75.7%
*-commutative75.7%
associate-*l*75.7%
*-commutative75.7%
Simplified75.7%
if 1.9499999999999999e223 < U Initial program 44.4%
associate-*l*44.4%
associate-*l*44.4%
unpow244.4%
sqr-neg44.4%
distribute-frac-neg44.4%
distribute-frac-neg44.4%
unpow244.4%
Simplified63.0%
Taylor expanded in U around inf 60.1%
Final simplification74.8%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* -2.0 (* J (hypot 1.0 (/ (/ U_m 2.0) J))))))
(if (<= J 1.7e-196)
(* -2.0 (* U_m 0.5))
(if (<= J 9.6e-32)
t_0
(if (<= J 6.2e-19)
(* -2.0 (* U_m -0.5))
(if (<= J 4.6e+51) t_0 (* -2.0 (* J (cos (* K 0.5))))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = -2.0 * (J * hypot(1.0, ((U_m / 2.0) / J)));
double tmp;
if (J <= 1.7e-196) {
tmp = -2.0 * (U_m * 0.5);
} else if (J <= 9.6e-32) {
tmp = t_0;
} else if (J <= 6.2e-19) {
tmp = -2.0 * (U_m * -0.5);
} else if (J <= 4.6e+51) {
tmp = t_0;
} else {
tmp = -2.0 * (J * cos((K * 0.5)));
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = -2.0 * (J * Math.hypot(1.0, ((U_m / 2.0) / J)));
double tmp;
if (J <= 1.7e-196) {
tmp = -2.0 * (U_m * 0.5);
} else if (J <= 9.6e-32) {
tmp = t_0;
} else if (J <= 6.2e-19) {
tmp = -2.0 * (U_m * -0.5);
} else if (J <= 4.6e+51) {
tmp = t_0;
} else {
tmp = -2.0 * (J * Math.cos((K * 0.5)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = -2.0 * (J * math.hypot(1.0, ((U_m / 2.0) / J))) tmp = 0 if J <= 1.7e-196: tmp = -2.0 * (U_m * 0.5) elif J <= 9.6e-32: tmp = t_0 elif J <= 6.2e-19: tmp = -2.0 * (U_m * -0.5) elif J <= 4.6e+51: tmp = t_0 else: tmp = -2.0 * (J * math.cos((K * 0.5))) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(-2.0 * Float64(J * hypot(1.0, Float64(Float64(U_m / 2.0) / J)))) tmp = 0.0 if (J <= 1.7e-196) tmp = Float64(-2.0 * Float64(U_m * 0.5)); elseif (J <= 9.6e-32) tmp = t_0; elseif (J <= 6.2e-19) tmp = Float64(-2.0 * Float64(U_m * -0.5)); elseif (J <= 4.6e+51) tmp = t_0; else tmp = Float64(-2.0 * Float64(J * cos(Float64(K * 0.5)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = -2.0 * (J * hypot(1.0, ((U_m / 2.0) / J))); tmp = 0.0; if (J <= 1.7e-196) tmp = -2.0 * (U_m * 0.5); elseif (J <= 9.6e-32) tmp = t_0; elseif (J <= 6.2e-19) tmp = -2.0 * (U_m * -0.5); elseif (J <= 4.6e+51) tmp = t_0; else tmp = -2.0 * (J * cos((K * 0.5))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 1.7e-196], N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 9.6e-32], t$95$0, If[LessEqual[J, 6.2e-19], N[(-2.0 * N[(U$95$m * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 4.6e+51], t$95$0, N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U_m}{2}}{J}\right)\right)\\
\mathbf{if}\;J \leq 1.7 \cdot 10^{-196}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot 0.5\right)\\
\mathbf{elif}\;J \leq 9.6 \cdot 10^{-32}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 6.2 \cdot 10^{-19}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 4.6 \cdot 10^{+51}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if J < 1.7e-196Initial program 65.6%
associate-*l*65.6%
associate-*l*65.6%
unpow265.6%
sqr-neg65.6%
distribute-frac-neg65.6%
distribute-frac-neg65.6%
unpow265.6%
Simplified85.8%
Taylor expanded in U around inf 22.5%
if 1.7e-196 < J < 9.6000000000000005e-32 or 6.1999999999999998e-19 < J < 4.6000000000000001e51Initial program 61.8%
associate-*l*61.8%
associate-*l*61.8%
unpow261.8%
sqr-neg61.8%
distribute-frac-neg61.8%
distribute-frac-neg61.8%
unpow261.8%
Simplified93.1%
Taylor expanded in K around 0 65.1%
Taylor expanded in K around 0 67.8%
if 9.6000000000000005e-32 < J < 6.1999999999999998e-19Initial program 80.4%
associate-*l*80.4%
associate-*l*80.4%
unpow280.4%
sqr-neg80.4%
distribute-frac-neg80.4%
distribute-frac-neg80.4%
unpow280.4%
Simplified99.4%
Taylor expanded in U around -inf 22.6%
*-commutative22.6%
Simplified22.6%
if 4.6000000000000001e51 < J Initial program 94.0%
associate-*l*94.0%
associate-*l*94.0%
unpow294.0%
sqr-neg94.0%
distribute-frac-neg94.0%
distribute-frac-neg94.0%
unpow294.0%
Simplified99.8%
Taylor expanded in U around 0 77.7%
Final simplification43.5%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* -2.0 (* J (hypot 1.0 (/ (/ U_m 2.0) J))))))
(if (<= J 6e-87)
(* -2.0 (fma 0.5 U_m (* J (/ J U_m))))
(if (<= J 9.5e-32)
t_0
(if (<= J 6.2e-19)
(* -2.0 (* U_m -0.5))
(if (<= J 3.2e+51) t_0 (* -2.0 (* J (cos (* K 0.5))))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = -2.0 * (J * hypot(1.0, ((U_m / 2.0) / J)));
double tmp;
if (J <= 6e-87) {
tmp = -2.0 * fma(0.5, U_m, (J * (J / U_m)));
} else if (J <= 9.5e-32) {
tmp = t_0;
} else if (J <= 6.2e-19) {
tmp = -2.0 * (U_m * -0.5);
} else if (J <= 3.2e+51) {
tmp = t_0;
} else {
tmp = -2.0 * (J * cos((K * 0.5)));
}
return tmp;
}
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(-2.0 * Float64(J * hypot(1.0, Float64(Float64(U_m / 2.0) / J)))) tmp = 0.0 if (J <= 6e-87) tmp = Float64(-2.0 * fma(0.5, U_m, Float64(J * Float64(J / U_m)))); elseif (J <= 9.5e-32) tmp = t_0; elseif (J <= 6.2e-19) tmp = Float64(-2.0 * Float64(U_m * -0.5)); elseif (J <= 3.2e+51) tmp = t_0; else tmp = Float64(-2.0 * Float64(J * cos(Float64(K * 0.5)))); end return tmp end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[(-2.0 * N[(J * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / 2.0), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 6e-87], N[(-2.0 * N[(0.5 * U$95$m + N[(J * N[(J / U$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 9.5e-32], t$95$0, If[LessEqual[J, 6.2e-19], N[(-2.0 * N[(U$95$m * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 3.2e+51], t$95$0, N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := -2 \cdot \left(J \cdot \mathsf{hypot}\left(1, \frac{\frac{U_m}{2}}{J}\right)\right)\\
\mathbf{if}\;J \leq 6 \cdot 10^{-87}:\\
\;\;\;\;-2 \cdot \mathsf{fma}\left(0.5, U_m, J \cdot \frac{J}{U_m}\right)\\
\mathbf{elif}\;J \leq 9.5 \cdot 10^{-32}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 6.2 \cdot 10^{-19}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 3.2 \cdot 10^{+51}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if J < 6.00000000000000033e-87Initial program 64.0%
associate-*l*64.0%
associate-*l*64.0%
unpow264.0%
sqr-neg64.0%
distribute-frac-neg64.0%
distribute-frac-neg64.0%
unpow264.0%
Simplified85.1%
Taylor expanded in U around inf 24.2%
fma-def24.2%
unpow224.2%
*-commutative24.2%
unpow224.2%
swap-sqr24.2%
unpow224.2%
*-commutative24.2%
Simplified24.2%
Taylor expanded in K around 0 24.2%
unpow224.2%
*-un-lft-identity24.2%
times-frac25.6%
Applied egg-rr25.6%
if 6.00000000000000033e-87 < J < 9.4999999999999999e-32 or 6.1999999999999998e-19 < J < 3.2000000000000002e51Initial program 68.7%
associate-*l*68.7%
associate-*l*68.7%
unpow268.7%
sqr-neg68.7%
distribute-frac-neg68.7%
distribute-frac-neg68.7%
unpow268.7%
Simplified99.8%
Taylor expanded in K around 0 71.1%
Taylor expanded in K around 0 71.3%
if 9.4999999999999999e-32 < J < 6.1999999999999998e-19Initial program 80.4%
associate-*l*80.4%
associate-*l*80.4%
unpow280.4%
sqr-neg80.4%
distribute-frac-neg80.4%
distribute-frac-neg80.4%
unpow280.4%
Simplified99.4%
Taylor expanded in U around -inf 22.6%
*-commutative22.6%
Simplified22.6%
if 3.2000000000000002e51 < J Initial program 94.0%
associate-*l*94.0%
associate-*l*94.0%
unpow294.0%
sqr-neg94.0%
distribute-frac-neg94.0%
distribute-frac-neg94.0%
unpow294.0%
Simplified99.8%
Taylor expanded in U around 0 77.7%
Final simplification43.7%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* -2.0 (* U_m 0.5))))
(if (<= J 2.55e-33)
t_0
(if (<= J 1.05e-18)
(* -2.0 (* U_m -0.5))
(if (<= J 5.2e+14) t_0 (* -2.0 (* J (cos (* K 0.5)))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = -2.0 * (U_m * 0.5);
double tmp;
if (J <= 2.55e-33) {
tmp = t_0;
} else if (J <= 1.05e-18) {
tmp = -2.0 * (U_m * -0.5);
} else if (J <= 5.2e+14) {
tmp = t_0;
} else {
tmp = -2.0 * (J * cos((K * 0.5)));
}
return tmp;
}
U_m = abs(U)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: t_0
real(8) :: tmp
t_0 = (-2.0d0) * (u_m * 0.5d0)
if (j <= 2.55d-33) then
tmp = t_0
else if (j <= 1.05d-18) then
tmp = (-2.0d0) * (u_m * (-0.5d0))
else if (j <= 5.2d+14) then
tmp = t_0
else
tmp = (-2.0d0) * (j * cos((k * 0.5d0)))
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = -2.0 * (U_m * 0.5);
double tmp;
if (J <= 2.55e-33) {
tmp = t_0;
} else if (J <= 1.05e-18) {
tmp = -2.0 * (U_m * -0.5);
} else if (J <= 5.2e+14) {
tmp = t_0;
} else {
tmp = -2.0 * (J * Math.cos((K * 0.5)));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = -2.0 * (U_m * 0.5) tmp = 0 if J <= 2.55e-33: tmp = t_0 elif J <= 1.05e-18: tmp = -2.0 * (U_m * -0.5) elif J <= 5.2e+14: tmp = t_0 else: tmp = -2.0 * (J * math.cos((K * 0.5))) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(-2.0 * Float64(U_m * 0.5)) tmp = 0.0 if (J <= 2.55e-33) tmp = t_0; elseif (J <= 1.05e-18) tmp = Float64(-2.0 * Float64(U_m * -0.5)); elseif (J <= 5.2e+14) tmp = t_0; else tmp = Float64(-2.0 * Float64(J * cos(Float64(K * 0.5)))); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = -2.0 * (U_m * 0.5); tmp = 0.0; if (J <= 2.55e-33) tmp = t_0; elseif (J <= 1.05e-18) tmp = -2.0 * (U_m * -0.5); elseif (J <= 5.2e+14) tmp = t_0; else tmp = -2.0 * (J * cos((K * 0.5))); end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 2.55e-33], t$95$0, If[LessEqual[J, 1.05e-18], N[(-2.0 * N[(U$95$m * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 5.2e+14], t$95$0, N[(-2.0 * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := -2 \cdot \left(U_m \cdot 0.5\right)\\
\mathbf{if}\;J \leq 2.55 \cdot 10^{-33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 1.05 \cdot 10^{-18}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 5.2 \cdot 10^{+14}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if J < 2.55000000000000004e-33 or 1.05e-18 < J < 5.2e14Initial program 63.4%
associate-*l*63.4%
associate-*l*63.4%
unpow263.4%
sqr-neg63.4%
distribute-frac-neg63.4%
distribute-frac-neg63.4%
unpow263.4%
Simplified87.0%
Taylor expanded in U around inf 26.7%
if 2.55000000000000004e-33 < J < 1.05e-18Initial program 80.4%
associate-*l*80.4%
associate-*l*80.4%
unpow280.4%
sqr-neg80.4%
distribute-frac-neg80.4%
distribute-frac-neg80.4%
unpow280.4%
Simplified99.4%
Taylor expanded in U around -inf 22.6%
*-commutative22.6%
Simplified22.6%
if 5.2e14 < J Initial program 94.5%
associate-*l*94.5%
associate-*l*94.5%
unpow294.5%
sqr-neg94.5%
distribute-frac-neg94.5%
distribute-frac-neg94.5%
unpow294.5%
Simplified99.8%
Taylor expanded in U around 0 77.2%
Final simplification40.4%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* -2.0 (* U_m 0.5))))
(if (<= J 9.6e-32)
t_0
(if (<= J 6.6e-19)
(* -2.0 (* U_m -0.5))
(if (<= J 5.2e+14) t_0 (* -2.0 J))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = -2.0 * (U_m * 0.5);
double tmp;
if (J <= 9.6e-32) {
tmp = t_0;
} else if (J <= 6.6e-19) {
tmp = -2.0 * (U_m * -0.5);
} else if (J <= 5.2e+14) {
tmp = t_0;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = abs(U)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: t_0
real(8) :: tmp
t_0 = (-2.0d0) * (u_m * 0.5d0)
if (j <= 9.6d-32) then
tmp = t_0
else if (j <= 6.6d-19) then
tmp = (-2.0d0) * (u_m * (-0.5d0))
else if (j <= 5.2d+14) then
tmp = t_0
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = -2.0 * (U_m * 0.5);
double tmp;
if (J <= 9.6e-32) {
tmp = t_0;
} else if (J <= 6.6e-19) {
tmp = -2.0 * (U_m * -0.5);
} else if (J <= 5.2e+14) {
tmp = t_0;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = -2.0 * (U_m * 0.5) tmp = 0 if J <= 9.6e-32: tmp = t_0 elif J <= 6.6e-19: tmp = -2.0 * (U_m * -0.5) elif J <= 5.2e+14: tmp = t_0 else: tmp = -2.0 * J return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(-2.0 * Float64(U_m * 0.5)) tmp = 0.0 if (J <= 9.6e-32) tmp = t_0; elseif (J <= 6.6e-19) tmp = Float64(-2.0 * Float64(U_m * -0.5)); elseif (J <= 5.2e+14) tmp = t_0; else tmp = Float64(-2.0 * J); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = -2.0 * (U_m * 0.5); tmp = 0.0; if (J <= 9.6e-32) tmp = t_0; elseif (J <= 6.6e-19) tmp = -2.0 * (U_m * -0.5); elseif (J <= 5.2e+14) tmp = t_0; else tmp = -2.0 * J; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, 9.6e-32], t$95$0, If[LessEqual[J, 6.6e-19], N[(-2.0 * N[(U$95$m * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 5.2e+14], t$95$0, N[(-2.0 * J), $MachinePrecision]]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := -2 \cdot \left(U_m \cdot 0.5\right)\\
\mathbf{if}\;J \leq 9.6 \cdot 10^{-32}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq 6.6 \cdot 10^{-19}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot -0.5\right)\\
\mathbf{elif}\;J \leq 5.2 \cdot 10^{+14}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 9.6000000000000005e-32 or 6.5999999999999995e-19 < J < 5.2e14Initial program 63.4%
associate-*l*63.4%
associate-*l*63.4%
unpow263.4%
sqr-neg63.4%
distribute-frac-neg63.4%
distribute-frac-neg63.4%
unpow263.4%
Simplified87.0%
Taylor expanded in U around inf 26.7%
if 9.6000000000000005e-32 < J < 6.5999999999999995e-19Initial program 80.4%
associate-*l*80.4%
associate-*l*80.4%
unpow280.4%
sqr-neg80.4%
distribute-frac-neg80.4%
distribute-frac-neg80.4%
unpow280.4%
Simplified99.4%
Taylor expanded in U around -inf 22.6%
*-commutative22.6%
Simplified22.6%
if 5.2e14 < J Initial program 94.5%
associate-*l*94.5%
associate-*l*94.5%
unpow294.5%
sqr-neg94.5%
distribute-frac-neg94.5%
distribute-frac-neg94.5%
unpow294.5%
Simplified99.8%
Taylor expanded in U around 0 77.2%
Taylor expanded in K around 0 46.8%
Final simplification32.1%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= J 5.2e+14) (* -2.0 (* U_m 0.5)) (* -2.0 J)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (J <= 5.2e+14) {
tmp = -2.0 * (U_m * 0.5);
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = abs(U)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
real(8) :: tmp
if (j <= 5.2d+14) then
tmp = (-2.0d0) * (u_m * 0.5d0)
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double tmp;
if (J <= 5.2e+14) {
tmp = -2.0 * (U_m * 0.5);
} else {
tmp = -2.0 * J;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if J <= 5.2e+14: tmp = -2.0 * (U_m * 0.5) else: tmp = -2.0 * J return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (J <= 5.2e+14) tmp = Float64(-2.0 * Float64(U_m * 0.5)); else tmp = Float64(-2.0 * J); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (J <= 5.2e+14) tmp = -2.0 * (U_m * 0.5); else tmp = -2.0 * J; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[J, 5.2e+14], N[(-2.0 * N[(U$95$m * 0.5), $MachinePrecision]), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;J \leq 5.2 \cdot 10^{+14}:\\
\;\;\;\;-2 \cdot \left(U_m \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < 5.2e14Initial program 63.8%
associate-*l*63.8%
associate-*l*63.8%
unpow263.8%
sqr-neg63.8%
distribute-frac-neg63.8%
distribute-frac-neg63.8%
unpow263.8%
Simplified87.3%
Taylor expanded in U around inf 27.1%
if 5.2e14 < J Initial program 94.5%
associate-*l*94.5%
associate-*l*94.5%
unpow294.5%
sqr-neg94.5%
distribute-frac-neg94.5%
distribute-frac-neg94.5%
unpow294.5%
Simplified99.8%
Taylor expanded in U around 0 77.2%
Taylor expanded in K around 0 46.8%
Final simplification32.5%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (* -2.0 J))
U_m = fabs(U);
double code(double J, double K, double U_m) {
return -2.0 * J;
}
U_m = abs(U)
real(8) function code(j, k, u_m)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u_m
code = (-2.0d0) * j
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
return -2.0 * J;
}
U_m = math.fabs(U) def code(J, K, U_m): return -2.0 * J
U_m = abs(U) function code(J, K, U_m) return Float64(-2.0 * J) end
U_m = abs(U); function tmp = code(J, K, U_m) tmp = -2.0 * J; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := N[(-2.0 * J), $MachinePrecision]
\begin{array}{l}
U_m = \left|U\right|
\\
-2 \cdot J
\end{array}
Initial program 72.2%
associate-*l*72.2%
associate-*l*72.2%
unpow272.2%
sqr-neg72.2%
distribute-frac-neg72.2%
distribute-frac-neg72.2%
unpow272.2%
Simplified90.7%
Taylor expanded in U around 0 53.8%
Taylor expanded in K around 0 34.5%
Final simplification34.5%
herbie shell --seed 2024020
(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)))))