
(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 14 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
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U_m (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY)) (- U_m) (if (<= t_1 4e+298) t_1 U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U_m;
} else if (t_1 <= 4e+298) {
tmp = t_1;
} else {
tmp = U_m;
}
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 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U_m / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U_m;
} else if (t_1 <= 4e+298) {
tmp = t_1;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U_m / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U_m elif t_1 <= 4e+298: tmp = t_1 else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = 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_1 <= Float64(-Inf)) tmp = Float64(-U_m); elseif (t_1 <= 4e+298) tmp = t_1; else tmp = U_m; end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U_m / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U_m; elseif (t_1 <= 4e+298) tmp = t_1; else tmp = U_m; 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[(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$1, (-Infinity)], (-U$95$m), If[LessEqual[t$95$1, 4e+298], t$95$1, U$95$m]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\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\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+298}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\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.0%
Simplified49.1%
Taylor expanded in J around 0 18.7%
neg-mul-118.7%
Simplified18.7%
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)))) < 3.9999999999999998e298Initial program 99.8%
if 3.9999999999999998e298 < (*.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 6.1%
Simplified62.5%
expm1-log1p-u16.0%
expm1-undefine16.0%
Applied egg-rr16.0%
expm1-define16.0%
*-commutative16.0%
times-frac16.0%
*-commutative16.0%
associate-*r/16.0%
associate-/r*16.0%
*-commutative16.0%
*-commutative16.0%
*-commutative16.0%
Simplified16.0%
Taylor expanded in U around -inf 57.4%
Final simplification82.4%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1 (* J (* (* -2.0 t_0) (+ 1.0 (* (* (/ U_m J) (/ U_m J)) 0.125))))))
(if (<= t_0 -0.48)
U_m
(if (<= t_0 0.03)
t_1
(if (<= t_0 0.36)
(- U_m)
(if (<= t_0 0.75)
t_1
(* (* -2.0 J) (hypot 1.0 (/ (* U_m 0.5) J)))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = J * ((-2.0 * t_0) * (1.0 + (((U_m / J) * (U_m / J)) * 0.125)));
double tmp;
if (t_0 <= -0.48) {
tmp = U_m;
} else if (t_0 <= 0.03) {
tmp = t_1;
} else if (t_0 <= 0.36) {
tmp = -U_m;
} else if (t_0 <= 0.75) {
tmp = t_1;
} else {
tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J));
}
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 * ((-2.0 * t_0) * (1.0 + (((U_m / J) * (U_m / J)) * 0.125)));
double tmp;
if (t_0 <= -0.48) {
tmp = U_m;
} else if (t_0 <= 0.03) {
tmp = t_1;
} else if (t_0 <= 0.36) {
tmp = -U_m;
} else if (t_0 <= 0.75) {
tmp = t_1;
} else {
tmp = (-2.0 * J) * Math.hypot(1.0, ((U_m * 0.5) / J));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = J * ((-2.0 * t_0) * (1.0 + (((U_m / J) * (U_m / J)) * 0.125))) tmp = 0 if t_0 <= -0.48: tmp = U_m elif t_0 <= 0.03: tmp = t_1 elif t_0 <= 0.36: tmp = -U_m elif t_0 <= 0.75: tmp = t_1 else: tmp = (-2.0 * J) * math.hypot(1.0, ((U_m * 0.5) / J)) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(J * Float64(Float64(-2.0 * t_0) * Float64(1.0 + Float64(Float64(Float64(U_m / J) * Float64(U_m / J)) * 0.125)))) tmp = 0.0 if (t_0 <= -0.48) tmp = U_m; elseif (t_0 <= 0.03) tmp = t_1; elseif (t_0 <= 0.36) tmp = Float64(-U_m); elseif (t_0 <= 0.75) tmp = t_1; else tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(Float64(U_m * 0.5) / J))); 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 * ((-2.0 * t_0) * (1.0 + (((U_m / J) * (U_m / J)) * 0.125))); tmp = 0.0; if (t_0 <= -0.48) tmp = U_m; elseif (t_0 <= 0.03) tmp = t_1; elseif (t_0 <= 0.36) tmp = -U_m; elseif (t_0 <= 0.75) tmp = t_1; else tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J)); 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 * N[(N[(-2.0 * t$95$0), $MachinePrecision] * N[(1.0 + N[(N[(N[(U$95$m / J), $MachinePrecision] * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.48], U$95$m, If[LessEqual[t$95$0, 0.03], t$95$1, If[LessEqual[t$95$0, 0.36], (-U$95$m), If[LessEqual[t$95$0, 0.75], t$95$1, N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $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 \left(\left(-2 \cdot t\_0\right) \cdot \left(1 + \left(\frac{U\_m}{J} \cdot \frac{U\_m}{J}\right) \cdot 0.125\right)\right)\\
\mathbf{if}\;t\_0 \leq -0.48:\\
\;\;\;\;U\_m\\
\mathbf{elif}\;t\_0 \leq 0.03:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.36:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_0 \leq 0.75:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.47999999999999998Initial program 63.1%
Simplified81.5%
expm1-log1p-u77.6%
expm1-undefine77.5%
Applied egg-rr77.5%
expm1-define77.6%
*-commutative77.6%
times-frac77.6%
*-commutative77.6%
associate-*r/77.6%
associate-/r*77.6%
*-commutative77.6%
*-commutative77.6%
*-commutative77.6%
Simplified77.6%
Taylor expanded in U around -inf 40.8%
if -0.47999999999999998 < (cos.f64 (/.f64 K 2)) < 0.029999999999999999 or 0.35999999999999999 < (cos.f64 (/.f64 K 2)) < 0.75Initial program 76.1%
Simplified82.7%
Taylor expanded in K around 0 71.5%
*-commutative71.5%
Simplified71.5%
Taylor expanded in U around 0 57.9%
*-commutative57.9%
Simplified57.9%
unpow257.9%
unpow257.9%
frac-times69.6%
Applied egg-rr69.6%
if 0.029999999999999999 < (cos.f64 (/.f64 K 2)) < 0.35999999999999999Initial program 52.6%
Simplified89.9%
Taylor expanded in J around 0 15.2%
neg-mul-115.2%
Simplified15.2%
if 0.75 < (cos.f64 (/.f64 K 2)) Initial program 75.2%
Simplified89.7%
expm1-log1p-u0.0%
expm1-undefine0.0%
Applied egg-rr0.0%
expm1-define0.0%
*-commutative0.0%
times-frac0.0%
*-commutative0.0%
associate-*r/0.0%
associate-/r*0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
Simplified0.0%
expm1-undefine0.0%
sub-neg0.0%
Applied egg-rr89.7%
associate-+l+89.7%
metadata-eval89.7%
sub-neg89.7%
associate-*r*89.7%
*-commutative89.7%
fma-neg89.7%
associate-/l/89.7%
*-commutative89.7%
metadata-eval89.7%
Simplified89.7%
Taylor expanded in K around 0 50.3%
associate-*r*50.3%
metadata-eval50.3%
unpow250.3%
unpow250.3%
times-frac68.0%
swap-sqr68.0%
unpow268.0%
metadata-eval68.0%
unpow268.0%
hypot-undefine82.5%
associate-*r/82.5%
Simplified82.5%
Final simplification70.2%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= t_0 -0.48)
U_m
(if (<= t_0 0.03)
t_1
(if (<= t_0 0.36)
(- U_m)
(if (<= t_0 0.75)
t_1
(* (* -2.0 J) (hypot 1.0 (/ (* U_m 0.5) J)))))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double t_1 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (t_0 <= -0.48) {
tmp = U_m;
} else if (t_0 <= 0.03) {
tmp = t_1;
} else if (t_0 <= 0.36) {
tmp = -U_m;
} else if (t_0 <= 0.75) {
tmp = t_1;
} else {
tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J));
}
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 * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (t_0 <= -0.48) {
tmp = U_m;
} else if (t_0 <= 0.03) {
tmp = t_1;
} else if (t_0 <= 0.36) {
tmp = -U_m;
} else if (t_0 <= 0.75) {
tmp = t_1;
} else {
tmp = (-2.0 * J) * Math.hypot(1.0, ((U_m * 0.5) / J));
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) t_1 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if t_0 <= -0.48: tmp = U_m elif t_0 <= 0.03: tmp = t_1 elif t_0 <= 0.36: tmp = -U_m elif t_0 <= 0.75: tmp = t_1 else: tmp = (-2.0 * J) * math.hypot(1.0, ((U_m * 0.5) / J)) return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (t_0 <= -0.48) tmp = U_m; elseif (t_0 <= 0.03) tmp = t_1; elseif (t_0 <= 0.36) tmp = Float64(-U_m); elseif (t_0 <= 0.75) tmp = t_1; else tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(Float64(U_m * 0.5) / J))); 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 * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (t_0 <= -0.48) tmp = U_m; elseif (t_0 <= 0.03) tmp = t_1; elseif (t_0 <= 0.36) tmp = -U_m; elseif (t_0 <= 0.75) tmp = t_1; else tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J)); 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 * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.48], U$95$m, If[LessEqual[t$95$0, 0.03], t$95$1, If[LessEqual[t$95$0, 0.36], (-U$95$m), If[LessEqual[t$95$0, 0.75], t$95$1, N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $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 \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;t\_0 \leq -0.48:\\
\;\;\;\;U\_m\\
\mathbf{elif}\;t\_0 \leq 0.03:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0.36:\\
\;\;\;\;-U\_m\\
\mathbf{elif}\;t\_0 \leq 0.75:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.47999999999999998Initial program 63.1%
Simplified81.5%
expm1-log1p-u77.6%
expm1-undefine77.5%
Applied egg-rr77.5%
expm1-define77.6%
*-commutative77.6%
times-frac77.6%
*-commutative77.6%
associate-*r/77.6%
associate-/r*77.6%
*-commutative77.6%
*-commutative77.6%
*-commutative77.6%
Simplified77.6%
Taylor expanded in U around -inf 40.8%
if -0.47999999999999998 < (cos.f64 (/.f64 K 2)) < 0.029999999999999999 or 0.35999999999999999 < (cos.f64 (/.f64 K 2)) < 0.75Initial program 76.1%
Simplified82.7%
Taylor expanded in J around inf 68.4%
*-commutative68.4%
*-commutative68.4%
metadata-eval68.4%
distribute-rgt-neg-in68.4%
associate-*r*68.4%
distribute-rgt-neg-in68.4%
*-commutative68.4%
distribute-lft-neg-in68.4%
metadata-eval68.4%
*-commutative68.4%
Simplified68.4%
if 0.029999999999999999 < (cos.f64 (/.f64 K 2)) < 0.35999999999999999Initial program 52.6%
Simplified89.9%
Taylor expanded in J around 0 15.2%
neg-mul-115.2%
Simplified15.2%
if 0.75 < (cos.f64 (/.f64 K 2)) Initial program 75.2%
Simplified89.7%
expm1-log1p-u0.0%
expm1-undefine0.0%
Applied egg-rr0.0%
expm1-define0.0%
*-commutative0.0%
times-frac0.0%
*-commutative0.0%
associate-*r/0.0%
associate-/r*0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
Simplified0.0%
expm1-undefine0.0%
sub-neg0.0%
Applied egg-rr89.7%
associate-+l+89.7%
metadata-eval89.7%
sub-neg89.7%
associate-*r*89.7%
*-commutative89.7%
fma-neg89.7%
associate-/l/89.7%
*-commutative89.7%
metadata-eval89.7%
Simplified89.7%
Taylor expanded in K around 0 50.3%
associate-*r*50.3%
metadata-eval50.3%
unpow250.3%
unpow250.3%
times-frac68.0%
swap-sqr68.0%
unpow268.0%
metadata-eval68.0%
unpow268.0%
hypot-undefine82.5%
associate-*r/82.5%
Simplified82.5%
Final simplification70.0%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(if (<= U_m 220000000000.0)
(* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ U_m (* J 2.0)))))
(if (<= U_m 2.1e+170)
(* (* -2.0 J) (hypot 1.0 (/ (* U_m 0.5) J)))
(if (<= U_m 3.6e+186)
(*
J
(+
1.0
(fma -2.0 (* (cos (* K 0.5)) (hypot 1.0 (* 0.5 (/ U_m J)))) -1.0)))
(- U_m)))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 220000000000.0) {
tmp = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, (U_m / (J * 2.0))));
} else if (U_m <= 2.1e+170) {
tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J));
} else if (U_m <= 3.6e+186) {
tmp = J * (1.0 + fma(-2.0, (cos((K * 0.5)) * hypot(1.0, (0.5 * (U_m / J)))), -1.0));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 220000000000.0) tmp = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(U_m / Float64(J * 2.0))))); elseif (U_m <= 2.1e+170) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(Float64(U_m * 0.5) / J))); elseif (U_m <= 3.6e+186) tmp = Float64(J * Float64(1.0 + fma(-2.0, Float64(cos(Float64(K * 0.5)) * hypot(1.0, Float64(0.5 * Float64(U_m / J)))), -1.0))); else tmp = Float64(-U_m); end return tmp end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 220000000000.0], N[(J * N[(N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 2.1e+170], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 3.6e+186], N[(J * N[(1.0 + N[(-2.0 * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U$95$m / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 220000000000:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m}{J \cdot 2}\right)\right)\\
\mathbf{elif}\;U\_m \leq 2.1 \cdot 10^{+170}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J}\right)\\
\mathbf{elif}\;U\_m \leq 3.6 \cdot 10^{+186}:\\
\;\;\;\;J \cdot \left(1 + \mathsf{fma}\left(-2, \cos \left(K \cdot 0.5\right) \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U\_m}{J}\right), -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 2.2e11Initial program 77.6%
Simplified89.0%
Taylor expanded in K around 0 75.1%
*-commutative75.1%
Simplified75.1%
if 2.2e11 < U < 2.09999999999999998e170Initial program 60.0%
Simplified87.8%
expm1-log1p-u11.2%
expm1-undefine11.2%
Applied egg-rr11.2%
expm1-define11.2%
*-commutative11.2%
times-frac11.2%
*-commutative11.2%
associate-*r/11.2%
associate-/r*11.2%
*-commutative11.2%
*-commutative11.2%
*-commutative11.2%
Simplified11.2%
expm1-undefine11.2%
sub-neg11.2%
Applied egg-rr87.8%
associate-+l+87.8%
metadata-eval87.8%
sub-neg87.8%
associate-*r*87.8%
*-commutative87.8%
fma-neg87.8%
associate-/l/87.8%
*-commutative87.8%
metadata-eval87.8%
Simplified87.8%
Taylor expanded in K around 0 47.1%
associate-*r*47.1%
metadata-eval47.1%
unpow247.1%
unpow247.1%
times-frac55.3%
swap-sqr55.3%
unpow255.3%
metadata-eval55.3%
unpow255.3%
hypot-undefine71.2%
associate-*r/71.2%
Simplified71.2%
if 2.09999999999999998e170 < U < 3.6000000000000002e186Initial program 86.2%
Simplified99.6%
expm1-log1p-u53.8%
expm1-undefine53.4%
Applied egg-rr53.4%
expm1-define53.8%
*-commutative53.8%
times-frac53.8%
*-commutative53.8%
associate-*r/53.8%
associate-/r*53.8%
*-commutative53.8%
*-commutative53.8%
*-commutative53.8%
Simplified53.8%
expm1-undefine53.4%
sub-neg53.4%
Applied egg-rr99.3%
associate-+l+99.8%
metadata-eval99.8%
sub-neg99.8%
associate-*r*99.8%
*-commutative99.8%
fma-neg99.8%
associate-/l/99.8%
*-commutative99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in K around 0 77.5%
if 3.6000000000000002e186 < U Initial program 39.7%
Simplified68.1%
Taylor expanded in J around 0 36.1%
neg-mul-136.1%
Simplified36.1%
Final simplification70.8%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 1.95e+247)
(* -2.0 (* J (* t_0 (hypot 1.0 (* (/ U_m t_0) (/ 0.5 J))))))
(- U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (U_m <= 1.95e+247) {
tmp = -2.0 * (J * (t_0 * hypot(1.0, ((U_m / t_0) * (0.5 / J)))));
} else {
tmp = -U_m;
}
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 tmp;
if (U_m <= 1.95e+247) {
tmp = -2.0 * (J * (t_0 * Math.hypot(1.0, ((U_m / t_0) * (0.5 / J)))));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if U_m <= 1.95e+247: tmp = -2.0 * (J * (t_0 * math.hypot(1.0, ((U_m / t_0) * (0.5 / J))))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (U_m <= 1.95e+247) tmp = Float64(-2.0 * Float64(J * Float64(t_0 * hypot(1.0, Float64(Float64(U_m / t_0) * Float64(0.5 / J)))))); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = 0.0; if (U_m <= 1.95e+247) tmp = -2.0 * (J * (t_0 * hypot(1.0, ((U_m / t_0) * (0.5 / J))))); else tmp = -U_m; 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]}, If[LessEqual[U$95$m, 1.95e+247], N[(-2.0 * N[(J * N[(t$95$0 * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / t$95$0), $MachinePrecision] * N[(0.5 / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U\_m \leq 1.95 \cdot 10^{+247}:\\
\;\;\;\;-2 \cdot \left(J \cdot \left(t\_0 \cdot \mathsf{hypot}\left(1, \frac{U\_m}{t\_0} \cdot \frac{0.5}{J}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1.95000000000000001e247Initial program 74.3%
Simplified88.6%
if 1.95000000000000001e247 < U Initial program 32.0%
Simplified54.8%
Taylor expanded in J around 0 44.1%
neg-mul-144.1%
Simplified44.1%
Final simplification86.5%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 6.6e+247)
(* -2.0 (* (* J t_0) (hypot 1.0 (/ (/ U_m (* J 2.0)) t_0))))
(- U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (U_m <= 6.6e+247) {
tmp = -2.0 * ((J * t_0) * hypot(1.0, ((U_m / (J * 2.0)) / t_0)));
} else {
tmp = -U_m;
}
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 tmp;
if (U_m <= 6.6e+247) {
tmp = -2.0 * ((J * t_0) * Math.hypot(1.0, ((U_m / (J * 2.0)) / t_0)));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if U_m <= 6.6e+247: tmp = -2.0 * ((J * t_0) * math.hypot(1.0, ((U_m / (J * 2.0)) / t_0))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (U_m <= 6.6e+247) tmp = Float64(-2.0 * Float64(Float64(J * t_0) * hypot(1.0, Float64(Float64(U_m / Float64(J * 2.0)) / t_0)))); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = 0.0; if (U_m <= 6.6e+247) tmp = -2.0 * ((J * t_0) * hypot(1.0, ((U_m / (J * 2.0)) / t_0))); else tmp = -U_m; 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]}, If[LessEqual[U$95$m, 6.6e+247], N[(-2.0 * N[(N[(J * t$95$0), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U\_m \leq 6.6 \cdot 10^{+247}:\\
\;\;\;\;-2 \cdot \left(\left(J \cdot t\_0\right) \cdot \mathsf{hypot}\left(1, \frac{\frac{U\_m}{J \cdot 2}}{t\_0}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 6.60000000000000003e247Initial program 74.3%
Simplified88.7%
if 6.60000000000000003e247 < U Initial program 32.0%
Simplified54.8%
Taylor expanded in J around 0 44.1%
neg-mul-144.1%
Simplified44.1%
Final simplification86.6%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= U_m 5.8e+246)
(* J (* (* -2.0 t_0) (hypot 1.0 (/ U_m (* t_0 (* J 2.0))))))
(- U_m))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = cos((K / 2.0));
double tmp;
if (U_m <= 5.8e+246) {
tmp = J * ((-2.0 * t_0) * hypot(1.0, (U_m / (t_0 * (J * 2.0)))));
} else {
tmp = -U_m;
}
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 tmp;
if (U_m <= 5.8e+246) {
tmp = J * ((-2.0 * t_0) * Math.hypot(1.0, (U_m / (t_0 * (J * 2.0)))));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = math.cos((K / 2.0)) tmp = 0 if U_m <= 5.8e+246: tmp = J * ((-2.0 * t_0) * math.hypot(1.0, (U_m / (t_0 * (J * 2.0))))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (U_m <= 5.8e+246) tmp = Float64(J * Float64(Float64(-2.0 * t_0) * hypot(1.0, Float64(U_m / Float64(t_0 * Float64(J * 2.0)))))); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = cos((K / 2.0)); tmp = 0.0; if (U_m <= 5.8e+246) tmp = J * ((-2.0 * t_0) * hypot(1.0, (U_m / (t_0 * (J * 2.0))))); else tmp = -U_m; 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]}, If[LessEqual[U$95$m, 5.8e+246], N[(J * N[(N[(-2.0 * t$95$0), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U$95$m / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;U\_m \leq 5.8 \cdot 10^{+246}:\\
\;\;\;\;J \cdot \left(\left(-2 \cdot t\_0\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m}{t\_0 \cdot \left(J \cdot 2\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 5.80000000000000028e246Initial program 74.3%
Simplified88.7%
if 5.80000000000000028e246 < U Initial program 32.0%
Simplified54.8%
Taylor expanded in J around 0 44.1%
neg-mul-144.1%
Simplified44.1%
Final simplification86.6%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* J (* (* -2.0 (cos (/ K 2.0))) (hypot 1.0 (/ U_m (* J 2.0)))))))
(if (<= U_m 4.6e+14)
t_0
(if (<= U_m 1.3e+171)
(* (* -2.0 J) (hypot 1.0 (/ (* U_m 0.5) J)))
(if (<= U_m 3.8e+186) t_0 (- U_m))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, (U_m / (J * 2.0))));
double tmp;
if (U_m <= 4.6e+14) {
tmp = t_0;
} else if (U_m <= 1.3e+171) {
tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J));
} else if (U_m <= 3.8e+186) {
tmp = t_0;
} else {
tmp = -U_m;
}
return tmp;
}
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
double t_0 = J * ((-2.0 * Math.cos((K / 2.0))) * Math.hypot(1.0, (U_m / (J * 2.0))));
double tmp;
if (U_m <= 4.6e+14) {
tmp = t_0;
} else if (U_m <= 1.3e+171) {
tmp = (-2.0 * J) * Math.hypot(1.0, ((U_m * 0.5) / J));
} else if (U_m <= 3.8e+186) {
tmp = t_0;
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = J * ((-2.0 * math.cos((K / 2.0))) * math.hypot(1.0, (U_m / (J * 2.0)))) tmp = 0 if U_m <= 4.6e+14: tmp = t_0 elif U_m <= 1.3e+171: tmp = (-2.0 * J) * math.hypot(1.0, ((U_m * 0.5) / J)) elif U_m <= 3.8e+186: tmp = t_0 else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(J * Float64(Float64(-2.0 * cos(Float64(K / 2.0))) * hypot(1.0, Float64(U_m / Float64(J * 2.0))))) tmp = 0.0 if (U_m <= 4.6e+14) tmp = t_0; elseif (U_m <= 1.3e+171) tmp = Float64(Float64(-2.0 * J) * hypot(1.0, Float64(Float64(U_m * 0.5) / J))); elseif (U_m <= 3.8e+186) tmp = t_0; else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = J * ((-2.0 * cos((K / 2.0))) * hypot(1.0, (U_m / (J * 2.0)))); tmp = 0.0; if (U_m <= 4.6e+14) tmp = t_0; elseif (U_m <= 1.3e+171) tmp = (-2.0 * J) * hypot(1.0, ((U_m * 0.5) / J)); elseif (U_m <= 3.8e+186) tmp = t_0; else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[(J * N[(N[(-2.0 * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U$95$m / N[(J * 2.0), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U$95$m, 4.6e+14], t$95$0, If[LessEqual[U$95$m, 1.3e+171], N[(N[(-2.0 * J), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(N[(U$95$m * 0.5), $MachinePrecision] / J), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[U$95$m, 3.8e+186], t$95$0, (-U$95$m)]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := J \cdot \left(\left(-2 \cdot \cos \left(\frac{K}{2}\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m}{J \cdot 2}\right)\right)\\
\mathbf{if}\;U\_m \leq 4.6 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;U\_m \leq 1.3 \cdot 10^{+171}:\\
\;\;\;\;\left(-2 \cdot J\right) \cdot \mathsf{hypot}\left(1, \frac{U\_m \cdot 0.5}{J}\right)\\
\mathbf{elif}\;U\_m \leq 3.8 \cdot 10^{+186}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 4.6e14 or 1.3e171 < U < 3.7999999999999998e186Initial program 77.9%
Simplified89.4%
Taylor expanded in K around 0 75.2%
*-commutative75.2%
Simplified75.2%
if 4.6e14 < U < 1.3e171Initial program 60.0%
Simplified87.8%
expm1-log1p-u11.2%
expm1-undefine11.2%
Applied egg-rr11.2%
expm1-define11.2%
*-commutative11.2%
times-frac11.2%
*-commutative11.2%
associate-*r/11.2%
associate-/r*11.2%
*-commutative11.2%
*-commutative11.2%
*-commutative11.2%
Simplified11.2%
expm1-undefine11.2%
sub-neg11.2%
Applied egg-rr87.8%
associate-+l+87.8%
metadata-eval87.8%
sub-neg87.8%
associate-*r*87.8%
*-commutative87.8%
fma-neg87.8%
associate-/l/87.8%
*-commutative87.8%
metadata-eval87.8%
Simplified87.8%
Taylor expanded in K around 0 47.1%
associate-*r*47.1%
metadata-eval47.1%
unpow247.1%
unpow247.1%
times-frac55.3%
swap-sqr55.3%
unpow255.3%
metadata-eval55.3%
unpow255.3%
hypot-undefine71.2%
associate-*r/71.2%
Simplified71.2%
if 3.7999999999999998e186 < U Initial program 39.7%
Simplified68.1%
Taylor expanded in J around 0 36.1%
neg-mul-136.1%
Simplified36.1%
Final simplification70.8%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= U_m 0.0036) (and (not (<= U_m 6.9e+171)) (<= U_m 3.6e+186))) (* J (* -2.0 (cos (* K 0.5)))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((U_m <= 0.0036) || (!(U_m <= 6.9e+171) && (U_m <= 3.6e+186))) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else {
tmp = -U_m;
}
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 ((u_m <= 0.0036d0) .or. (.not. (u_m <= 6.9d+171)) .and. (u_m <= 3.6d+186)) then
tmp = j * ((-2.0d0) * cos((k * 0.5d0)))
else
tmp = -u_m
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 ((U_m <= 0.0036) || (!(U_m <= 6.9e+171) && (U_m <= 3.6e+186))) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if (U_m <= 0.0036) or (not (U_m <= 6.9e+171) and (U_m <= 3.6e+186)): tmp = J * (-2.0 * math.cos((K * 0.5))) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if ((U_m <= 0.0036) || (!(U_m <= 6.9e+171) && (U_m <= 3.6e+186))) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if ((U_m <= 0.0036) || (~((U_m <= 6.9e+171)) && (U_m <= 3.6e+186))) tmp = J * (-2.0 * cos((K * 0.5))); else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[Or[LessEqual[U$95$m, 0.0036], And[N[Not[LessEqual[U$95$m, 6.9e+171]], $MachinePrecision], LessEqual[U$95$m, 3.6e+186]]], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 0.0036 \lor \neg \left(U\_m \leq 6.9 \cdot 10^{+171}\right) \land U\_m \leq 3.6 \cdot 10^{+186}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 0.0035999999999999999 or 6.90000000000000009e171 < U < 3.6000000000000002e186Initial program 77.8%
Simplified89.1%
Taylor expanded in J around inf 61.7%
*-commutative61.7%
*-commutative61.7%
metadata-eval61.7%
distribute-rgt-neg-in61.7%
associate-*r*61.7%
distribute-rgt-neg-in61.7%
*-commutative61.7%
distribute-lft-neg-in61.7%
metadata-eval61.7%
*-commutative61.7%
Simplified61.7%
if 0.0035999999999999999 < U < 6.90000000000000009e171 or 3.6000000000000002e186 < U Initial program 52.2%
Simplified79.5%
Taylor expanded in J around 0 25.5%
neg-mul-125.5%
Simplified25.5%
Final simplification53.9%
U_m = (fabs.f64 U)
(FPCore (J K U_m)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= U_m 0.0031)
t_0
(if (<= U_m 6.6e+171)
(- (/ (* -2.0 (pow J 2.0)) U_m) U_m)
(if (<= U_m 3.6e+186) t_0 (- U_m))))))U_m = fabs(U);
double code(double J, double K, double U_m) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (U_m <= 0.0031) {
tmp = t_0;
} else if (U_m <= 6.6e+171) {
tmp = ((-2.0 * pow(J, 2.0)) / U_m) - U_m;
} else if (U_m <= 3.6e+186) {
tmp = t_0;
} else {
tmp = -U_m;
}
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 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (u_m <= 0.0031d0) then
tmp = t_0
else if (u_m <= 6.6d+171) then
tmp = (((-2.0d0) * (j ** 2.0d0)) / u_m) - u_m
else if (u_m <= 3.6d+186) then
tmp = t_0
else
tmp = -u_m
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 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (U_m <= 0.0031) {
tmp = t_0;
} else if (U_m <= 6.6e+171) {
tmp = ((-2.0 * Math.pow(J, 2.0)) / U_m) - U_m;
} else if (U_m <= 3.6e+186) {
tmp = t_0;
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if U_m <= 0.0031: tmp = t_0 elif U_m <= 6.6e+171: tmp = ((-2.0 * math.pow(J, 2.0)) / U_m) - U_m elif U_m <= 3.6e+186: tmp = t_0 else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (U_m <= 0.0031) tmp = t_0; elseif (U_m <= 6.6e+171) tmp = Float64(Float64(Float64(-2.0 * (J ^ 2.0)) / U_m) - U_m); elseif (U_m <= 3.6e+186) tmp = t_0; else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (U_m <= 0.0031) tmp = t_0; elseif (U_m <= 6.6e+171) tmp = ((-2.0 * (J ^ 2.0)) / U_m) - U_m; elseif (U_m <= 3.6e+186) tmp = t_0; else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision]
code[J_, K_, U$95$m_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U$95$m, 0.0031], t$95$0, If[LessEqual[U$95$m, 6.6e+171], N[(N[(N[(-2.0 * N[Power[J, 2.0], $MachinePrecision]), $MachinePrecision] / U$95$m), $MachinePrecision] - U$95$m), $MachinePrecision], If[LessEqual[U$95$m, 3.6e+186], t$95$0, (-U$95$m)]]]]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;U\_m \leq 0.0031:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;U\_m \leq 6.6 \cdot 10^{+171}:\\
\;\;\;\;\frac{-2 \cdot {J}^{2}}{U\_m} - U\_m\\
\mathbf{elif}\;U\_m \leq 3.6 \cdot 10^{+186}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 0.00309999999999999989 or 6.59999999999999982e171 < U < 3.6000000000000002e186Initial program 77.8%
Simplified89.1%
Taylor expanded in J around inf 61.7%
*-commutative61.7%
*-commutative61.7%
metadata-eval61.7%
distribute-rgt-neg-in61.7%
associate-*r*61.7%
distribute-rgt-neg-in61.7%
*-commutative61.7%
distribute-lft-neg-in61.7%
metadata-eval61.7%
*-commutative61.7%
Simplified61.7%
if 0.00309999999999999989 < U < 6.59999999999999982e171Initial program 63.5%
Simplified89.8%
expm1-log1p-u12.7%
expm1-undefine12.7%
Applied egg-rr12.7%
expm1-define12.7%
*-commutative12.7%
times-frac12.7%
*-commutative12.7%
associate-*r/12.7%
associate-/r*12.7%
*-commutative12.7%
*-commutative12.7%
*-commutative12.7%
Simplified12.7%
Taylor expanded in J around 0 17.2%
neg-mul-117.2%
unsub-neg17.2%
associate-*r/17.2%
*-commutative17.2%
unpow217.2%
unpow217.2%
swap-sqr17.2%
unpow217.2%
Simplified17.2%
Taylor expanded in K around 0 16.5%
if 3.6000000000000002e186 < U Initial program 39.7%
Simplified68.1%
Taylor expanded in J around 0 36.1%
neg-mul-136.1%
Simplified36.1%
Final simplification53.9%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= U_m 1e-99) (and (not (<= U_m 3.6e-53)) (<= U_m 3.8e-38))) (* J (+ (/ U_m J) -1.0)) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((U_m <= 1e-99) || (!(U_m <= 3.6e-53) && (U_m <= 3.8e-38))) {
tmp = J * ((U_m / J) + -1.0);
} else {
tmp = -U_m;
}
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 ((u_m <= 1d-99) .or. (.not. (u_m <= 3.6d-53)) .and. (u_m <= 3.8d-38)) then
tmp = j * ((u_m / j) + (-1.0d0))
else
tmp = -u_m
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 ((U_m <= 1e-99) || (!(U_m <= 3.6e-53) && (U_m <= 3.8e-38))) {
tmp = J * ((U_m / J) + -1.0);
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if (U_m <= 1e-99) or (not (U_m <= 3.6e-53) and (U_m <= 3.8e-38)): tmp = J * ((U_m / J) + -1.0) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if ((U_m <= 1e-99) || (!(U_m <= 3.6e-53) && (U_m <= 3.8e-38))) tmp = Float64(J * Float64(Float64(U_m / J) + -1.0)); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if ((U_m <= 1e-99) || (~((U_m <= 3.6e-53)) && (U_m <= 3.8e-38))) tmp = J * ((U_m / J) + -1.0); else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[Or[LessEqual[U$95$m, 1e-99], And[N[Not[LessEqual[U$95$m, 3.6e-53]], $MachinePrecision], LessEqual[U$95$m, 3.8e-38]]], N[(J * N[(N[(U$95$m / J), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 10^{-99} \lor \neg \left(U\_m \leq 3.6 \cdot 10^{-53}\right) \land U\_m \leq 3.8 \cdot 10^{-38}:\\
\;\;\;\;J \cdot \left(\frac{U\_m}{J} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 1e-99 or 3.5999999999999999e-53 < U < 3.8e-38Initial program 74.2%
Simplified86.8%
expm1-log1p-u24.5%
expm1-undefine24.3%
Applied egg-rr24.3%
expm1-define24.5%
*-commutative24.5%
times-frac24.5%
*-commutative24.5%
associate-*r/24.5%
associate-/r*24.5%
*-commutative24.5%
*-commutative24.5%
*-commutative24.5%
Simplified24.5%
expm1-undefine24.3%
Applied egg-rr86.7%
Taylor expanded in U around -inf 26.7%
if 1e-99 < U < 3.5999999999999999e-53 or 3.8e-38 < U Initial program 68.9%
Simplified87.5%
Taylor expanded in J around 0 19.7%
neg-mul-119.7%
Simplified19.7%
Final simplification24.2%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (or (<= K 4.5e+74) (and (not (<= K 6.4e+199)) (<= K 7e+224))) (- U_m) U_m))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if ((K <= 4.5e+74) || (!(K <= 6.4e+199) && (K <= 7e+224))) {
tmp = -U_m;
} else {
tmp = U_m;
}
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 ((k <= 4.5d+74) .or. (.not. (k <= 6.4d+199)) .and. (k <= 7d+224)) then
tmp = -u_m
else
tmp = u_m
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 ((K <= 4.5e+74) || (!(K <= 6.4e+199) && (K <= 7e+224))) {
tmp = -U_m;
} else {
tmp = U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if (K <= 4.5e+74) or (not (K <= 6.4e+199) and (K <= 7e+224)): tmp = -U_m else: tmp = U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if ((K <= 4.5e+74) || (!(K <= 6.4e+199) && (K <= 7e+224))) tmp = Float64(-U_m); else tmp = U_m; end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if ((K <= 4.5e+74) || (~((K <= 6.4e+199)) && (K <= 7e+224))) tmp = -U_m; else tmp = U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[Or[LessEqual[K, 4.5e+74], And[N[Not[LessEqual[K, 6.4e+199]], $MachinePrecision], LessEqual[K, 7e+224]]], (-U$95$m), U$95$m]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;K \leq 4.5 \cdot 10^{+74} \lor \neg \left(K \leq 6.4 \cdot 10^{+199}\right) \land K \leq 7 \cdot 10^{+224}:\\
\;\;\;\;-U\_m\\
\mathbf{else}:\\
\;\;\;\;U\_m\\
\end{array}
\end{array}
if K < 4.5e74 or 6.40000000000000011e199 < K < 7e224Initial program 72.0%
Simplified86.9%
Taylor expanded in J around 0 16.7%
neg-mul-116.7%
Simplified16.7%
if 4.5e74 < K < 6.40000000000000011e199 or 7e224 < K Initial program 73.7%
Simplified87.7%
expm1-log1p-u47.0%
expm1-undefine46.8%
Applied egg-rr46.8%
expm1-define47.0%
*-commutative47.0%
times-frac47.0%
*-commutative47.0%
associate-*r/47.0%
associate-/r*47.0%
*-commutative47.0%
*-commutative47.0%
*-commutative47.0%
Simplified47.0%
Taylor expanded in U around -inf 29.5%
Final simplification19.4%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 (if (<= U_m 2.25e+17) (* J (- -1.0 (/ U_m J))) (- U_m)))
U_m = fabs(U);
double code(double J, double K, double U_m) {
double tmp;
if (U_m <= 2.25e+17) {
tmp = J * (-1.0 - (U_m / J));
} else {
tmp = -U_m;
}
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 (u_m <= 2.25d+17) then
tmp = j * ((-1.0d0) - (u_m / j))
else
tmp = -u_m
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 (U_m <= 2.25e+17) {
tmp = J * (-1.0 - (U_m / J));
} else {
tmp = -U_m;
}
return tmp;
}
U_m = math.fabs(U) def code(J, K, U_m): tmp = 0 if U_m <= 2.25e+17: tmp = J * (-1.0 - (U_m / J)) else: tmp = -U_m return tmp
U_m = abs(U) function code(J, K, U_m) tmp = 0.0 if (U_m <= 2.25e+17) tmp = Float64(J * Float64(-1.0 - Float64(U_m / J))); else tmp = Float64(-U_m); end return tmp end
U_m = abs(U); function tmp_2 = code(J, K, U_m) tmp = 0.0; if (U_m <= 2.25e+17) tmp = J * (-1.0 - (U_m / J)); else tmp = -U_m; end tmp_2 = tmp; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := If[LessEqual[U$95$m, 2.25e+17], N[(J * N[(-1.0 - N[(U$95$m / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-U$95$m)]
\begin{array}{l}
U_m = \left|U\right|
\\
\begin{array}{l}
\mathbf{if}\;U\_m \leq 2.25 \cdot 10^{+17}:\\
\;\;\;\;J \cdot \left(-1 - \frac{U\_m}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;-U\_m\\
\end{array}
\end{array}
if U < 2.25e17Initial program 77.6%
Simplified89.0%
expm1-log1p-u24.8%
expm1-undefine24.7%
Applied egg-rr24.7%
expm1-define24.8%
*-commutative24.8%
times-frac24.8%
*-commutative24.8%
associate-*r/24.8%
associate-/r*24.8%
*-commutative24.8%
*-commutative24.8%
*-commutative24.8%
Simplified24.8%
expm1-undefine24.7%
Applied egg-rr88.9%
Taylor expanded in U around inf 18.7%
associate-*r/18.7%
mul-1-neg18.7%
Simplified18.7%
if 2.25e17 < U Initial program 53.9%
Simplified80.3%
Taylor expanded in J around 0 24.5%
neg-mul-124.5%
Simplified24.5%
Final simplification20.0%
U_m = (fabs.f64 U) (FPCore (J K U_m) :precision binary64 U_m)
U_m = fabs(U);
double code(double J, double K, double U_m) {
return U_m;
}
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 = u_m
end function
U_m = Math.abs(U);
public static double code(double J, double K, double U_m) {
return U_m;
}
U_m = math.fabs(U) def code(J, K, U_m): return U_m
U_m = abs(U) function code(J, K, U_m) return U_m end
U_m = abs(U); function tmp = code(J, K, U_m) tmp = U_m; end
U_m = N[Abs[U], $MachinePrecision] code[J_, K_, U$95$m_] := U$95$m
\begin{array}{l}
U_m = \left|U\right|
\\
U\_m
\end{array}
Initial program 72.3%
Simplified87.1%
expm1-log1p-u23.3%
expm1-undefine23.2%
Applied egg-rr23.2%
expm1-define23.3%
*-commutative23.3%
times-frac23.3%
*-commutative23.3%
associate-*r/23.3%
associate-/r*23.3%
*-commutative23.3%
*-commutative23.3%
*-commutative23.3%
Simplified23.3%
Taylor expanded in U around -inf 31.9%
Final simplification31.9%
herbie shell --seed 2024043
(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)))))