
(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 10 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}
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY))
(- U)
(if (<= t_1 5e+300)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0)))))
U))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U;
} else if (t_1 <= 5e+300) {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U;
} else if (t_1 <= 5e+300) {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U elif t_1 <= 5e+300: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0)))) else: tmp = U return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U); elseif (t_1 <= 5e+300) tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U; elseif (t_1 <= 5e+300) tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); else tmp = U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U), If[LessEqual[t$95$1, 5e+300], N[(N[(J * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], U]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\left(-2 \cdot J\right) \cdot t_0\right) \cdot \sqrt{1 + {\left(\frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-U\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+300}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot t_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\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.3%
*-commutative6.3%
associate-*l*6.3%
associate-*r*6.3%
*-commutative6.3%
associate-*l*6.3%
*-commutative6.3%
unpow26.3%
hypot-1-def58.8%
*-commutative58.8%
associate-*l*58.8%
Simplified58.8%
Taylor expanded in J around 0 39.3%
neg-mul-139.3%
Simplified39.3%
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)))) < 5.00000000000000026e300Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 5.00000000000000026e300 < (*.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 8.5%
*-commutative8.5%
associate-*l*8.5%
associate-*r*8.5%
*-commutative8.5%
associate-*l*8.5%
*-commutative8.5%
unpow28.5%
hypot-1-def73.2%
*-commutative73.2%
associate-*l*73.2%
Simplified73.2%
Taylor expanded in U around -inf 46.8%
Final simplification84.3%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) return J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(J * N[(t$95$0 * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
J \cdot \left(t_0 \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)
\end{array}
\end{array}
Initial program 74.9%
*-commutative74.9%
associate-*l*74.9%
associate-*r*74.9%
*-commutative74.9%
associate-*l*74.8%
*-commutative74.8%
unpow274.8%
hypot-1-def90.3%
*-commutative90.3%
associate-*l*90.3%
Simplified90.3%
Final simplification90.3%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= U 2.65e+182) (* (* J (* -2.0 (cos (/ K 2.0)))) (hypot 1.0 (/ U (* J 2.0)))) (- (* -2.0 (* J (/ J U))) U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 2.65e+182) {
tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0)));
} else {
tmp = (-2.0 * (J * (J / U))) - U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 2.65e+182) {
tmp = (J * (-2.0 * Math.cos((K / 2.0)))) * Math.hypot(1.0, (U / (J * 2.0)));
} else {
tmp = (-2.0 * (J * (J / U))) - U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 2.65e+182: tmp = (J * (-2.0 * math.cos((K / 2.0)))) * math.hypot(1.0, (U / (J * 2.0))) else: tmp = (-2.0 * (J * (J / U))) - U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 2.65e+182) tmp = Float64(Float64(J * Float64(-2.0 * cos(Float64(K / 2.0)))) * hypot(1.0, Float64(U / Float64(J * 2.0)))); else tmp = Float64(Float64(-2.0 * Float64(J * Float64(J / U))) - U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 2.65e+182) tmp = (J * (-2.0 * cos((K / 2.0)))) * hypot(1.0, (U / (J * 2.0))); else tmp = (-2.0 * (J * (J / U))) - U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 2.65e+182], N[(N[(J * N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(J * N[(J / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - U), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 2.65 \cdot 10^{+182}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot \cos \left(\frac{K}{2}\right)\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot 2}\right)\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(J \cdot \frac{J}{U}\right) - U\\
\end{array}
\end{array}
if U < 2.65e182Initial program 78.0%
*-commutative78.0%
associate-*l*78.0%
unpow278.0%
hypot-1-def93.3%
*-commutative93.3%
associate-*l*93.3%
Simplified93.3%
Taylor expanded in K around 0 78.8%
if 2.65e182 < U Initial program 48.3%
*-commutative48.3%
associate-*l*48.3%
associate-*r*48.3%
*-commutative48.3%
associate-*l*48.2%
*-commutative48.2%
unpow248.2%
hypot-1-def65.3%
*-commutative65.3%
associate-*l*65.3%
Simplified65.3%
Taylor expanded in J around 0 45.5%
neg-mul-145.5%
unsub-neg45.5%
associate-/l*45.5%
associate-*r/45.5%
unpow245.5%
Simplified45.5%
Taylor expanded in K around 0 45.5%
unpow245.5%
associate-/l*52.2%
associate-/r/52.2%
Simplified52.2%
Final simplification76.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.52) (* J (* -2.0 (cos (* K 0.5)))) (* J (* -2.0 (hypot 1.0 (* 0.5 (/ U J)))))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.52) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else {
tmp = J * (-2.0 * hypot(1.0, (0.5 * (U / J))));
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.52) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else {
tmp = J * (-2.0 * Math.hypot(1.0, (0.5 * (U / J))));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.52: tmp = J * (-2.0 * math.cos((K * 0.5))) else: tmp = J * (-2.0 * math.hypot(1.0, (0.5 * (U / J)))) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.52) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); else tmp = Float64(J * Float64(-2.0 * hypot(1.0, Float64(0.5 * Float64(U / J))))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.52) tmp = J * (-2.0 * cos((K * 0.5))); else tmp = J * (-2.0 * hypot(1.0, (0.5 * (U / J)))); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.52], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.52:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(-2 \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < 0.52000000000000002Initial program 77.6%
*-commutative77.6%
associate-*l*77.6%
associate-*r*77.6%
*-commutative77.6%
associate-*l*77.6%
*-commutative77.6%
unpow277.6%
hypot-1-def91.5%
*-commutative91.5%
associate-*l*91.5%
Simplified91.5%
Taylor expanded in U around 0 58.9%
if 0.52000000000000002 < (cos.f64 (/.f64 K 2)) Initial program 73.6%
*-commutative73.6%
associate-*l*73.6%
associate-*r*73.6%
*-commutative73.6%
associate-*l*73.6%
*-commutative73.6%
unpow273.6%
hypot-1-def89.8%
*-commutative89.8%
associate-*l*89.8%
Simplified89.8%
Taylor expanded in K around 0 40.2%
associate-*r*40.2%
unpow240.2%
unpow240.2%
Simplified40.2%
add-sqr-sqrt40.2%
hypot-1-def40.2%
sqrt-prod40.2%
metadata-eval40.2%
times-frac64.5%
sqrt-prod46.9%
add-sqr-sqrt80.7%
Applied egg-rr80.7%
Final simplification73.8%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (/ J U))) (t_1 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -1.25e-24)
t_1
(if (<= J -2e-310)
(+ U (* 2.0 t_0))
(if (<= J 2.3e-10) (- (* -2.0 t_0) U) t_1)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (J / U);
double t_1 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -1.25e-24) {
tmp = t_1;
} else if (J <= -2e-310) {
tmp = U + (2.0 * t_0);
} else if (J <= 2.3e-10) {
tmp = (-2.0 * t_0) - U;
} else {
tmp = t_1;
}
return tmp;
}
NOTE: U should be positive before calling this function
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
real(8) :: t_1
real(8) :: tmp
t_0 = j * (j / u)
t_1 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-1.25d-24)) then
tmp = t_1
else if (j <= (-2d-310)) then
tmp = u + (2.0d0 * t_0)
else if (j <= 2.3d-10) then
tmp = ((-2.0d0) * t_0) - u
else
tmp = t_1
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * (J / U);
double t_1 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -1.25e-24) {
tmp = t_1;
} else if (J <= -2e-310) {
tmp = U + (2.0 * t_0);
} else if (J <= 2.3e-10) {
tmp = (-2.0 * t_0) - U;
} else {
tmp = t_1;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (J / U) t_1 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -1.25e-24: tmp = t_1 elif J <= -2e-310: tmp = U + (2.0 * t_0) elif J <= 2.3e-10: tmp = (-2.0 * t_0) - U else: tmp = t_1 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(J / U)) t_1 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -1.25e-24) tmp = t_1; elseif (J <= -2e-310) tmp = Float64(U + Float64(2.0 * t_0)); elseif (J <= 2.3e-10) tmp = Float64(Float64(-2.0 * t_0) - U); else tmp = t_1; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (J / U); t_1 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (J <= -1.25e-24) tmp = t_1; elseif (J <= -2e-310) tmp = U + (2.0 * t_0); elseif (J <= 2.3e-10) tmp = (-2.0 * t_0) - U; else tmp = t_1; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(J / U), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.25e-24], t$95$1, If[LessEqual[J, -2e-310], N[(U + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 2.3e-10], N[(N[(-2.0 * t$95$0), $MachinePrecision] - U), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \frac{J}{U}\\
t_1 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -1.25 \cdot 10^{-24}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U + 2 \cdot t_0\\
\mathbf{elif}\;J \leq 2.3 \cdot 10^{-10}:\\
\;\;\;\;-2 \cdot t_0 - U\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if J < -1.24999999999999995e-24 or 2.30000000000000007e-10 < J Initial program 93.1%
*-commutative93.1%
associate-*l*93.1%
associate-*r*93.1%
*-commutative93.1%
associate-*l*93.1%
*-commutative93.1%
unpow293.1%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 75.8%
if -1.24999999999999995e-24 < J < -1.999999999999994e-310Initial program 53.7%
*-commutative53.7%
associate-*l*53.7%
associate-*r*53.7%
*-commutative53.7%
associate-*l*53.6%
*-commutative53.6%
unpow253.6%
hypot-1-def78.8%
*-commutative78.8%
associate-*l*78.8%
Simplified78.8%
Taylor expanded in K around 0 23.1%
associate-*r*23.1%
unpow223.1%
unpow223.1%
Simplified23.1%
Taylor expanded in U around -inf 40.0%
fma-def40.0%
unpow240.0%
associate-/l*40.0%
Simplified40.0%
fma-udef40.0%
div-inv40.0%
clear-num40.0%
Applied egg-rr40.0%
if -1.999999999999994e-310 < J < 2.30000000000000007e-10Initial program 53.9%
*-commutative53.9%
associate-*l*53.9%
associate-*r*53.9%
*-commutative53.9%
associate-*l*53.9%
*-commutative53.9%
unpow253.9%
hypot-1-def79.8%
*-commutative79.8%
associate-*l*79.8%
Simplified79.8%
Taylor expanded in J around 0 38.8%
neg-mul-138.8%
unsub-neg38.8%
associate-/l*38.8%
associate-*r/38.8%
unpow238.8%
Simplified38.8%
Taylor expanded in K around 0 38.6%
unpow238.6%
associate-/l*38.6%
associate-/r/38.6%
Simplified38.6%
Final simplification58.7%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (/ J U))))
(if (<= J -1.8e-21)
(* -2.0 J)
(if (<= J -2e-310)
(+ U (* 2.0 t_0))
(if (<= J 1e+35) (- (* -2.0 t_0) U) (* -2.0 J))))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (J / U);
double tmp;
if (J <= -1.8e-21) {
tmp = -2.0 * J;
} else if (J <= -2e-310) {
tmp = U + (2.0 * t_0);
} else if (J <= 1e+35) {
tmp = (-2.0 * t_0) - U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
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
real(8) :: tmp
t_0 = j * (j / u)
if (j <= (-1.8d-21)) then
tmp = (-2.0d0) * j
else if (j <= (-2d-310)) then
tmp = u + (2.0d0 * t_0)
else if (j <= 1d+35) then
tmp = ((-2.0d0) * t_0) - u
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * (J / U);
double tmp;
if (J <= -1.8e-21) {
tmp = -2.0 * J;
} else if (J <= -2e-310) {
tmp = U + (2.0 * t_0);
} else if (J <= 1e+35) {
tmp = (-2.0 * t_0) - U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (J / U) tmp = 0 if J <= -1.8e-21: tmp = -2.0 * J elif J <= -2e-310: tmp = U + (2.0 * t_0) elif J <= 1e+35: tmp = (-2.0 * t_0) - U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(J / U)) tmp = 0.0 if (J <= -1.8e-21) tmp = Float64(-2.0 * J); elseif (J <= -2e-310) tmp = Float64(U + Float64(2.0 * t_0)); elseif (J <= 1e+35) tmp = Float64(Float64(-2.0 * t_0) - U); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (J / U); tmp = 0.0; if (J <= -1.8e-21) tmp = -2.0 * J; elseif (J <= -2e-310) tmp = U + (2.0 * t_0); elseif (J <= 1e+35) tmp = (-2.0 * t_0) - U; else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(J / U), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -1.8e-21], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -2e-310], N[(U + N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1e+35], N[(N[(-2.0 * t$95$0), $MachinePrecision] - U), $MachinePrecision], N[(-2.0 * J), $MachinePrecision]]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \frac{J}{U}\\
\mathbf{if}\;J \leq -1.8 \cdot 10^{-21}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U + 2 \cdot t_0\\
\mathbf{elif}\;J \leq 10^{+35}:\\
\;\;\;\;-2 \cdot t_0 - U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.79999999999999995e-21 or 9.9999999999999997e34 < J Initial program 96.2%
*-commutative96.2%
associate-*l*96.2%
associate-*r*96.2%
*-commutative96.2%
associate-*l*96.2%
*-commutative96.2%
unpow296.2%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 38.9%
associate-*r*38.9%
unpow238.9%
unpow238.9%
Simplified38.9%
Taylor expanded in U around 0 42.0%
if -1.79999999999999995e-21 < J < -1.999999999999994e-310Initial program 53.7%
*-commutative53.7%
associate-*l*53.7%
associate-*r*53.7%
*-commutative53.7%
associate-*l*53.6%
*-commutative53.6%
unpow253.6%
hypot-1-def78.8%
*-commutative78.8%
associate-*l*78.8%
Simplified78.8%
Taylor expanded in K around 0 23.1%
associate-*r*23.1%
unpow223.1%
unpow223.1%
Simplified23.1%
Taylor expanded in U around -inf 40.0%
fma-def40.0%
unpow240.0%
associate-/l*40.0%
Simplified40.0%
fma-udef40.0%
div-inv40.0%
clear-num40.0%
Applied egg-rr40.0%
if -1.999999999999994e-310 < J < 9.9999999999999997e34Initial program 55.5%
*-commutative55.5%
associate-*l*55.5%
associate-*r*55.5%
*-commutative55.5%
associate-*l*55.5%
*-commutative55.5%
unpow255.5%
hypot-1-def82.9%
*-commutative82.9%
associate-*l*82.9%
Simplified82.9%
Taylor expanded in J around 0 38.9%
neg-mul-138.9%
unsub-neg38.9%
associate-/l*38.9%
associate-*r/38.9%
unpow238.9%
Simplified38.9%
Taylor expanded in K around 0 38.8%
unpow238.8%
associate-/l*38.8%
associate-/r/38.8%
Simplified38.8%
Final simplification40.6%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -1.1e-21)
(* -2.0 J)
(if (<= J -2e-310)
(+ U (* 2.0 (* J (/ J U))))
(if (<= J 1.15e+35) (- U) (* -2.0 J)))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -1.1e-21) {
tmp = -2.0 * J;
} else if (J <= -2e-310) {
tmp = U + (2.0 * (J * (J / U)));
} else if (J <= 1.15e+35) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-1.1d-21)) then
tmp = (-2.0d0) * j
else if (j <= (-2d-310)) then
tmp = u + (2.0d0 * (j * (j / u)))
else if (j <= 1.15d+35) then
tmp = -u
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -1.1e-21) {
tmp = -2.0 * J;
} else if (J <= -2e-310) {
tmp = U + (2.0 * (J * (J / U)));
} else if (J <= 1.15e+35) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -1.1e-21: tmp = -2.0 * J elif J <= -2e-310: tmp = U + (2.0 * (J * (J / U))) elif J <= 1.15e+35: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -1.1e-21) tmp = Float64(-2.0 * J); elseif (J <= -2e-310) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(J / U)))); elseif (J <= 1.15e+35) tmp = Float64(-U); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -1.1e-21) tmp = -2.0 * J; elseif (J <= -2e-310) tmp = U + (2.0 * (J * (J / U))); elseif (J <= 1.15e+35) tmp = -U; else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -1.1e-21], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -2e-310], N[(U + N[(2.0 * N[(J * N[(J / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.15e+35], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -1.1 \cdot 10^{-21}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \frac{J}{U}\right)\\
\mathbf{elif}\;J \leq 1.15 \cdot 10^{+35}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -1.1e-21 or 1.1499999999999999e35 < J Initial program 96.2%
*-commutative96.2%
associate-*l*96.2%
associate-*r*96.2%
*-commutative96.2%
associate-*l*96.2%
*-commutative96.2%
unpow296.2%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 38.9%
associate-*r*38.9%
unpow238.9%
unpow238.9%
Simplified38.9%
Taylor expanded in U around 0 42.0%
if -1.1e-21 < J < -1.999999999999994e-310Initial program 53.7%
*-commutative53.7%
associate-*l*53.7%
associate-*r*53.7%
*-commutative53.7%
associate-*l*53.6%
*-commutative53.6%
unpow253.6%
hypot-1-def78.8%
*-commutative78.8%
associate-*l*78.8%
Simplified78.8%
Taylor expanded in K around 0 23.1%
associate-*r*23.1%
unpow223.1%
unpow223.1%
Simplified23.1%
Taylor expanded in U around -inf 40.0%
fma-def40.0%
unpow240.0%
associate-/l*40.0%
Simplified40.0%
fma-udef40.0%
div-inv40.0%
clear-num40.0%
Applied egg-rr40.0%
if -1.999999999999994e-310 < J < 1.1499999999999999e35Initial program 55.5%
*-commutative55.5%
associate-*l*55.5%
associate-*r*55.5%
*-commutative55.5%
associate-*l*55.5%
*-commutative55.5%
unpow255.5%
hypot-1-def82.9%
*-commutative82.9%
associate-*l*82.9%
Simplified82.9%
Taylor expanded in J around 0 38.7%
neg-mul-138.7%
Simplified38.7%
Final simplification40.6%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2.4e-15) (* -2.0 J) (if (<= J -2e-310) U (if (<= J 1.15e+35) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.4e-15) {
tmp = -2.0 * J;
} else if (J <= -2e-310) {
tmp = U;
} else if (J <= 1.15e+35) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-2.4d-15)) then
tmp = (-2.0d0) * j
else if (j <= (-2d-310)) then
tmp = u
else if (j <= 1.15d+35) then
tmp = -u
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -2.4e-15) {
tmp = -2.0 * J;
} else if (J <= -2e-310) {
tmp = U;
} else if (J <= 1.15e+35) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.4e-15: tmp = -2.0 * J elif J <= -2e-310: tmp = U elif J <= 1.15e+35: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.4e-15) tmp = Float64(-2.0 * J); elseif (J <= -2e-310) tmp = U; elseif (J <= 1.15e+35) tmp = Float64(-U); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -2.4e-15) tmp = -2.0 * J; elseif (J <= -2e-310) tmp = U; elseif (J <= 1.15e+35) tmp = -U; else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -2.4e-15], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -2e-310], U, If[LessEqual[J, 1.15e+35], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.4 \cdot 10^{-15}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.15 \cdot 10^{+35}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -2.39999999999999995e-15 or 1.1499999999999999e35 < J Initial program 96.9%
*-commutative96.9%
associate-*l*96.9%
associate-*r*96.9%
*-commutative96.9%
associate-*l*96.9%
*-commutative96.9%
unpow296.9%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in K around 0 39.6%
associate-*r*39.6%
unpow239.6%
unpow239.6%
Simplified39.6%
Taylor expanded in U around 0 42.7%
if -2.39999999999999995e-15 < J < -1.999999999999994e-310Initial program 53.6%
*-commutative53.6%
associate-*l*53.6%
associate-*r*53.6%
*-commutative53.6%
associate-*l*53.5%
*-commutative53.5%
unpow253.5%
hypot-1-def79.6%
*-commutative79.6%
associate-*l*79.6%
Simplified79.6%
Taylor expanded in U around -inf 40.5%
if -1.999999999999994e-310 < J < 1.1499999999999999e35Initial program 55.5%
*-commutative55.5%
associate-*l*55.5%
associate-*r*55.5%
*-commutative55.5%
associate-*l*55.5%
*-commutative55.5%
unpow255.5%
hypot-1-def82.9%
*-commutative82.9%
associate-*l*82.9%
Simplified82.9%
Taylor expanded in J around 0 38.7%
neg-mul-138.7%
Simplified38.7%
Final simplification41.0%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2e-310) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2e-310) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-2d-310)) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -2e-310) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2e-310: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2e-310) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -2e-310) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -2e-310], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -1.999999999999994e-310Initial program 77.6%
*-commutative77.6%
associate-*l*77.6%
associate-*r*77.6%
*-commutative77.6%
associate-*l*77.5%
*-commutative77.5%
unpow277.5%
hypot-1-def90.5%
*-commutative90.5%
associate-*l*90.5%
Simplified90.5%
Taylor expanded in U around -inf 26.3%
if -1.999999999999994e-310 < J Initial program 72.8%
*-commutative72.8%
associate-*l*72.8%
associate-*r*72.8%
*-commutative72.8%
associate-*l*72.8%
*-commutative72.8%
unpow272.8%
hypot-1-def90.2%
*-commutative90.2%
associate-*l*90.2%
Simplified90.2%
Taylor expanded in J around 0 25.6%
neg-mul-125.6%
Simplified25.6%
Final simplification25.9%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 U)
U = abs(U);
double code(double J, double K, double U) {
return U;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
return U;
}
U = abs(U) def code(J, K, U): return U
U = abs(U) function code(J, K, U) return U end
U = abs(U) function tmp = code(J, K, U) tmp = U; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := U
\begin{array}{l}
U = |U|\\
\\
U
\end{array}
Initial program 74.9%
*-commutative74.9%
associate-*l*74.9%
associate-*r*74.9%
*-commutative74.9%
associate-*l*74.8%
*-commutative74.8%
unpow274.8%
hypot-1-def90.3%
*-commutative90.3%
associate-*l*90.3%
Simplified90.3%
Taylor expanded in U around -inf 28.6%
Final simplification28.6%
herbie shell --seed 2023203
(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)))))