
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.0)))
(+ (* (cos (/ K 2.0)) (* t_0 J)) U)
(fma (* J (* l 2.0)) (cos (* K 0.5)) U))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.0)) {
tmp = (cos((K / 2.0)) * (t_0 * J)) + U;
} else {
tmp = fma((J * (l * 2.0)), cos((K * 0.5)), U);
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.0)) tmp = Float64(Float64(cos(Float64(K / 2.0)) * Float64(t_0 * J)) + U); else tmp = fma(Float64(J * Float64(l * 2.0)), cos(Float64(K * 0.5)), U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;\cos \left(\frac{K}{2}\right) \cdot \left(t_0 \cdot J\right) + U\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \left(\ell \cdot 2\right), \cos \left(K \cdot 0.5\right), U\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 71.4%
Taylor expanded in l around 0 99.9%
fma-def99.9%
*-commutative99.9%
div-inv99.9%
metadata-eval99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (- (exp l) (exp (- l))) J))
(t_1 (cos (* K 0.5)))
(t_2 (+ U (* t_1 (* (pow l 3.0) (* J 0.3333333333333333))))))
(if (<= l -7.5e+139)
t_2
(if (<= l -0.00084)
(+ U t_0)
(if (<= l 11.2)
(fma (* J (* l 2.0)) t_1 U)
(if (<= l 3.5e+82) (+ U (* t_0 (+ (* -0.125 (* K K)) 1.0))) t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = (exp(l) - exp(-l)) * J;
double t_1 = cos((K * 0.5));
double t_2 = U + (t_1 * (pow(l, 3.0) * (J * 0.3333333333333333)));
double tmp;
if (l <= -7.5e+139) {
tmp = t_2;
} else if (l <= -0.00084) {
tmp = U + t_0;
} else if (l <= 11.2) {
tmp = fma((J * (l * 2.0)), t_1, U);
} else if (l <= 3.5e+82) {
tmp = U + (t_0 * ((-0.125 * (K * K)) + 1.0));
} else {
tmp = t_2;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) t_1 = cos(Float64(K * 0.5)) t_2 = Float64(U + Float64(t_1 * Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))) tmp = 0.0 if (l <= -7.5e+139) tmp = t_2; elseif (l <= -0.00084) tmp = Float64(U + t_0); elseif (l <= 11.2) tmp = fma(Float64(J * Float64(l * 2.0)), t_1, U); elseif (l <= 3.5e+82) tmp = Float64(U + Float64(t_0 * Float64(Float64(-0.125 * Float64(K * K)) + 1.0))); else tmp = t_2; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(U + N[(t$95$1 * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.5e+139], t$95$2, If[LessEqual[l, -0.00084], N[(U + t$95$0), $MachinePrecision], If[LessEqual[l, 11.2], N[(N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] * t$95$1 + U), $MachinePrecision], If[LessEqual[l, 3.5e+82], N[(U + N[(t$95$0 * N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
t_1 := \cos \left(K \cdot 0.5\right)\\
t_2 := U + t_1 \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+139}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq -0.00084:\\
\;\;\;\;U + t_0\\
\mathbf{elif}\;\ell \leq 11.2:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \left(\ell \cdot 2\right), t_1, U\right)\\
\mathbf{elif}\;\ell \leq 3.5 \cdot 10^{+82}:\\
\;\;\;\;U + t_0 \cdot \left(-0.125 \cdot \left(K \cdot K\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if l < -7.49999999999999992e139 or 3.5e82 < l Initial program 100.0%
Taylor expanded in l around 0 98.9%
associate-*r*98.9%
associate-*r*98.9%
associate-*r*98.9%
associate-*r*98.9%
distribute-rgt-out98.9%
*-commutative98.9%
associate-*r*98.9%
*-commutative98.9%
associate-*r*98.9%
distribute-rgt-out98.9%
+-commutative98.9%
fma-def98.9%
Simplified98.9%
Taylor expanded in l around inf 98.9%
*-commutative98.9%
associate-*r*98.9%
associate-*l*98.9%
*-commutative98.9%
*-commutative98.9%
associate-*l*98.9%
Simplified98.9%
if -7.49999999999999992e139 < l < -8.4000000000000003e-4Initial program 100.0%
Taylor expanded in K around 0 85.2%
if -8.4000000000000003e-4 < l < 11.199999999999999Initial program 71.7%
Taylor expanded in l around 0 99.3%
fma-def99.3%
*-commutative99.3%
div-inv99.3%
metadata-eval99.3%
*-commutative99.3%
Applied egg-rr99.3%
if 11.199999999999999 < l < 3.5e82Initial program 100.0%
Taylor expanded in K around 0 0.0%
associate-*r*0.0%
distribute-rgt1-in83.3%
unpow283.3%
Simplified83.3%
Final simplification96.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* t_0 (* (pow l 3.0) (* J 0.3333333333333333)))))
(t_2 (+ U (* (- (exp l) (exp (- l))) J))))
(if (<= l -7.5e+139)
t_1
(if (<= l -0.0052)
t_2
(if (<= l 300000.0)
(fma (* J (* l 2.0)) t_0 U)
(if (<= l 1.22e+79) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U + (t_0 * (pow(l, 3.0) * (J * 0.3333333333333333)));
double t_2 = U + ((exp(l) - exp(-l)) * J);
double tmp;
if (l <= -7.5e+139) {
tmp = t_1;
} else if (l <= -0.0052) {
tmp = t_2;
} else if (l <= 300000.0) {
tmp = fma((J * (l * 2.0)), t_0, U);
} else if (l <= 1.22e+79) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U + Float64(t_0 * Float64((l ^ 3.0) * Float64(J * 0.3333333333333333)))) t_2 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)) tmp = 0.0 if (l <= -7.5e+139) tmp = t_1; elseif (l <= -0.0052) tmp = t_2; elseif (l <= 300000.0) tmp = fma(Float64(J * Float64(l * 2.0)), t_0, U); elseif (l <= 1.22e+79) tmp = t_2; else tmp = t_1; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(t$95$0 * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -7.5e+139], t$95$1, If[LessEqual[l, -0.0052], t$95$2, If[LessEqual[l, 300000.0], N[(N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] * t$95$0 + U), $MachinePrecision], If[LessEqual[l, 1.22e+79], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + t_0 \cdot \left({\ell}^{3} \cdot \left(J \cdot 0.3333333333333333\right)\right)\\
t_2 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+139}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -0.0052:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq 300000:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \left(\ell \cdot 2\right), t_0, U\right)\\
\mathbf{elif}\;\ell \leq 1.22 \cdot 10^{+79}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -7.49999999999999992e139 or 1.22000000000000002e79 < l Initial program 100.0%
Taylor expanded in l around 0 97.7%
associate-*r*97.7%
associate-*r*97.7%
associate-*r*97.7%
associate-*r*97.7%
distribute-rgt-out97.7%
*-commutative97.7%
associate-*r*97.7%
*-commutative97.7%
associate-*r*97.7%
distribute-rgt-out97.7%
+-commutative97.7%
fma-def97.7%
Simplified97.7%
Taylor expanded in l around inf 97.7%
*-commutative97.7%
associate-*r*97.7%
associate-*l*97.7%
*-commutative97.7%
*-commutative97.7%
associate-*l*97.7%
Simplified97.7%
if -7.49999999999999992e139 < l < -0.0051999999999999998 or 3e5 < l < 1.22000000000000002e79Initial program 100.0%
Taylor expanded in K around 0 83.3%
if -0.0051999999999999998 < l < 3e5Initial program 71.9%
Taylor expanded in l around 0 98.5%
fma-def98.6%
*-commutative98.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
Applied egg-rr98.6%
Final simplification95.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.0115) (not (<= l 300000.0))) (+ U (* (- (exp l) (exp (- l))) J)) (fma (* J (* l 2.0)) (cos (* K 0.5)) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.0115) || !(l <= 300000.0)) {
tmp = U + ((exp(l) - exp(-l)) * J);
} else {
tmp = fma((J * (l * 2.0)), cos((K * 0.5)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.0115) || !(l <= 300000.0)) tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)); else tmp = fma(Float64(J * Float64(l * 2.0)), cos(Float64(K * 0.5)), U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.0115], N[Not[LessEqual[l, 300000.0]], $MachinePrecision]], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision], N[(N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.0115 \lor \neg \left(\ell \leq 300000\right):\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J \cdot \left(\ell \cdot 2\right), \cos \left(K \cdot 0.5\right), U\right)\\
\end{array}
\end{array}
if l < -0.0115 or 3e5 < l Initial program 100.0%
Taylor expanded in K around 0 74.2%
if -0.0115 < l < 3e5Initial program 71.9%
Taylor expanded in l around 0 98.5%
fma-def98.6%
*-commutative98.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
Applied egg-rr98.6%
Final simplification86.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.042) (not (<= l 300000.0))) (+ U (* (- (exp l) (exp (- l))) J)) (+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.042) || !(l <= 300000.0)) {
tmp = U + ((exp(l) - exp(-l)) * J);
} else {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-0.042d0)) .or. (.not. (l <= 300000.0d0))) then
tmp = u + ((exp(l) - exp(-l)) * j)
else
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.042) || !(l <= 300000.0)) {
tmp = U + ((Math.exp(l) - Math.exp(-l)) * J);
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -0.042) or not (l <= 300000.0): tmp = U + ((math.exp(l) - math.exp(-l)) * J) else: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.042) || !(l <= 300000.0)) tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)); else tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -0.042) || ~((l <= 300000.0))) tmp = U + ((exp(l) - exp(-l)) * J); else tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.042], N[Not[LessEqual[l, 300000.0]], $MachinePrecision]], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.042 \lor \neg \left(\ell \leq 300000\right):\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{else}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if l < -0.0420000000000000026 or 3e5 < l Initial program 100.0%
Taylor expanded in K around 0 74.2%
if -0.0420000000000000026 < l < 3e5Initial program 71.9%
Taylor expanded in l around 0 98.5%
Final simplification86.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* J (+ (* l 2.0) (* (pow l 3.0) 0.3333333333333333))))))
(if (<= l -5.3e+67)
t_0
(if (<= l 1800000.0)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
(if (<= l 3.4e+101) (log1p (expm1 U)) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (J * ((l * 2.0) + (pow(l, 3.0) * 0.3333333333333333)));
double tmp;
if (l <= -5.3e+67) {
tmp = t_0;
} else if (l <= 1800000.0) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 3.4e+101) {
tmp = log1p(expm1(U));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = U + (J * ((l * 2.0) + (Math.pow(l, 3.0) * 0.3333333333333333)));
double tmp;
if (l <= -5.3e+67) {
tmp = t_0;
} else if (l <= 1800000.0) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 3.4e+101) {
tmp = Math.log1p(Math.expm1(U));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (J * ((l * 2.0) + (math.pow(l, 3.0) * 0.3333333333333333))) tmp = 0 if l <= -5.3e+67: tmp = t_0 elif l <= 1800000.0: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) elif l <= 3.4e+101: tmp = math.log1p(math.expm1(U)) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(J * Float64(Float64(l * 2.0) + Float64((l ^ 3.0) * 0.3333333333333333)))) tmp = 0.0 if (l <= -5.3e+67) tmp = t_0; elseif (l <= 1800000.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); elseif (l <= 3.4e+101) tmp = log1p(expm1(U)); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(N[Power[l, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5.3e+67], t$95$0, If[LessEqual[l, 1800000.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.4e+101], N[Log[1 + N[(Exp[U] - 1), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + J \cdot \left(\ell \cdot 2 + {\ell}^{3} \cdot 0.3333333333333333\right)\\
\mathbf{if}\;\ell \leq -5.3 \cdot 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 1800000:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 3.4 \cdot 10^{+101}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -5.3e67 or 3.40000000000000017e101 < l Initial program 100.0%
Taylor expanded in l around 0 95.8%
associate-*r*95.8%
associate-*r*95.8%
associate-*r*95.8%
associate-*r*95.8%
distribute-rgt-out95.8%
*-commutative95.8%
associate-*r*95.8%
*-commutative95.8%
associate-*r*95.8%
distribute-rgt-out95.8%
+-commutative95.8%
fma-def95.8%
Simplified95.8%
Taylor expanded in K around 0 69.9%
if -5.3e67 < l < 1.8e6Initial program 74.6%
Taylor expanded in l around 0 91.4%
if 1.8e6 < l < 3.40000000000000017e101Initial program 100.0%
Applied egg-rr57.5%
Final simplification81.1%
(FPCore (J l K U)
:precision binary64
(if (<= l -620.0)
(log1p (expm1 (- (/ -8.0 U) U)))
(if (<= l 300000.0)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
(if (<= l 1.8e+102)
(log1p (expm1 U))
(+ U (* J (+ (* l 2.0) (* (pow l 3.0) 0.3333333333333333))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -620.0) {
tmp = log1p(expm1(((-8.0 / U) - U)));
} else if (l <= 300000.0) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 1.8e+102) {
tmp = log1p(expm1(U));
} else {
tmp = U + (J * ((l * 2.0) + (pow(l, 3.0) * 0.3333333333333333)));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -620.0) {
tmp = Math.log1p(Math.expm1(((-8.0 / U) - U)));
} else if (l <= 300000.0) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 1.8e+102) {
tmp = Math.log1p(Math.expm1(U));
} else {
tmp = U + (J * ((l * 2.0) + (Math.pow(l, 3.0) * 0.3333333333333333)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -620.0: tmp = math.log1p(math.expm1(((-8.0 / U) - U))) elif l <= 300000.0: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) elif l <= 1.8e+102: tmp = math.log1p(math.expm1(U)) else: tmp = U + (J * ((l * 2.0) + (math.pow(l, 3.0) * 0.3333333333333333))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -620.0) tmp = log1p(expm1(Float64(Float64(-8.0 / U) - U))); elseif (l <= 300000.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); elseif (l <= 1.8e+102) tmp = log1p(expm1(U)); else tmp = Float64(U + Float64(J * Float64(Float64(l * 2.0) + Float64((l ^ 3.0) * 0.3333333333333333)))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -620.0], N[Log[1 + N[(Exp[N[(N[(-8.0 / U), $MachinePrecision] - U), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], If[LessEqual[l, 300000.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.8e+102], N[Log[1 + N[(Exp[U] - 1), $MachinePrecision]], $MachinePrecision], N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(N[Power[l, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -620:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-8}{U} - U\right)\right)\\
\mathbf{elif}\;\ell \leq 300000:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 1.8 \cdot 10^{+102}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2 + {\ell}^{3} \cdot 0.3333333333333333\right)\\
\end{array}
\end{array}
if l < -620Initial program 100.0%
Applied egg-rr3.0%
log1p-expm1-u57.1%
Applied egg-rr57.1%
if -620 < l < 3e5Initial program 71.9%
Taylor expanded in l around 0 98.5%
if 3e5 < l < 1.8000000000000001e102Initial program 100.0%
Applied egg-rr57.5%
if 1.8000000000000001e102 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
associate-*r*100.0%
associate-*r*100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in K around 0 78.7%
Final simplification82.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* J (+ (* l 2.0) (* (pow l 3.0) 0.3333333333333333))))))
(if (<= l -2e+67)
t_0
(if (<= l 1.26e+20)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
(if (<= l 5.2e+81) (/ (* U (fma U U -64.0)) (+ U -8.0)) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (J * ((l * 2.0) + (pow(l, 3.0) * 0.3333333333333333)));
double tmp;
if (l <= -2e+67) {
tmp = t_0;
} else if (l <= 1.26e+20) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 5.2e+81) {
tmp = (U * fma(U, U, -64.0)) / (U + -8.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(U + Float64(J * Float64(Float64(l * 2.0) + Float64((l ^ 3.0) * 0.3333333333333333)))) tmp = 0.0 if (l <= -2e+67) tmp = t_0; elseif (l <= 1.26e+20) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); elseif (l <= 5.2e+81) tmp = Float64(Float64(U * fma(U, U, -64.0)) / Float64(U + -8.0)); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(N[Power[l, 3.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2e+67], t$95$0, If[LessEqual[l, 1.26e+20], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.2e+81], N[(N[(U * N[(U * U + -64.0), $MachinePrecision]), $MachinePrecision] / N[(U + -8.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + J \cdot \left(\ell \cdot 2 + {\ell}^{3} \cdot 0.3333333333333333\right)\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 1.26 \cdot 10^{+20}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 5.2 \cdot 10^{+81}:\\
\;\;\;\;\frac{U \cdot \mathsf{fma}\left(U, U, -64\right)}{U + -8}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -1.99999999999999997e67 or 5.19999999999999984e81 < l Initial program 100.0%
Taylor expanded in l around 0 95.0%
associate-*r*95.0%
associate-*r*95.0%
associate-*r*95.0%
associate-*r*95.0%
distribute-rgt-out95.0%
*-commutative95.0%
associate-*r*95.0%
*-commutative95.0%
associate-*r*95.0%
distribute-rgt-out95.0%
+-commutative95.0%
fma-def95.0%
Simplified95.0%
Taylor expanded in K around 0 69.1%
if -1.99999999999999997e67 < l < 1.26e20Initial program 75.1%
Taylor expanded in l around 0 89.7%
if 1.26e20 < l < 5.19999999999999984e81Initial program 100.0%
Applied egg-rr37.0%
*-commutative37.0%
flip--37.0%
associate-*l/50.3%
fma-neg50.3%
metadata-eval50.3%
metadata-eval50.3%
Applied egg-rr50.3%
Final simplification80.1%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.04) (+ U (* (* l J) (+ 2.0 (* (* K K) -0.25)))) (+ U (* l (* J 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.04) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
} else {
tmp = U + (l * (J * 2.0));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (cos((k / 2.0d0)) <= (-0.04d0)) then
tmp = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
else
tmp = u + (l * (j * 2.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.04) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
} else {
tmp = U + (l * (J * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.04: tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25))) else: tmp = U + (l * (J * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.04) tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25)))); else tmp = Float64(U + Float64(l * Float64(J * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.04) tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25))); else tmp = U + (l * (J * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.04], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.04:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0400000000000000008Initial program 79.7%
Taylor expanded in l around 0 58.0%
Taylor expanded in K around 0 46.8%
+-commutative46.8%
associate-*r*46.8%
distribute-rgt-out51.1%
*-commutative51.1%
unpow251.1%
Simplified51.1%
if -0.0400000000000000008 < (cos.f64 (/.f64 K 2)) Initial program 87.7%
Taylor expanded in l around 0 65.8%
Taylor expanded in K around 0 61.8%
*-commutative61.8%
associate-*l*61.8%
Simplified61.8%
Final simplification59.0%
(FPCore (J l K U)
:precision binary64
(if (<= l 8.5e+19)
(+ U (* J (* (cos (* K 0.5)) (* l 2.0))))
(if (<= l 6.2e+81)
(/ (* U (fma U U -64.0)) (+ U -8.0))
(if (<= l 1.25e+179)
(+ U (* J (+ (* (* K K) 0.0625) -0.5)))
(+ U (* (* l J) (+ 2.0 (* (* K K) -0.25))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 8.5e+19) {
tmp = U + (J * (cos((K * 0.5)) * (l * 2.0)));
} else if (l <= 6.2e+81) {
tmp = (U * fma(U, U, -64.0)) / (U + -8.0);
} else if (l <= 1.25e+179) {
tmp = U + (J * (((K * K) * 0.0625) + -0.5));
} else {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= 8.5e+19) tmp = Float64(U + Float64(J * Float64(cos(Float64(K * 0.5)) * Float64(l * 2.0)))); elseif (l <= 6.2e+81) tmp = Float64(Float64(U * fma(U, U, -64.0)) / Float64(U + -8.0)); elseif (l <= 1.25e+179) tmp = Float64(U + Float64(J * Float64(Float64(Float64(K * K) * 0.0625) + -0.5))); else tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25)))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, 8.5e+19], N[(U + N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.2e+81], N[(N[(U * N[(U * U + -64.0), $MachinePrecision]), $MachinePrecision] / N[(U + -8.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.25e+179], N[(U + N[(J * N[(N[(N[(K * K), $MachinePrecision] * 0.0625), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 8.5 \cdot 10^{+19}:\\
\;\;\;\;U + J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 6.2 \cdot 10^{+81}:\\
\;\;\;\;\frac{U \cdot \mathsf{fma}\left(U, U, -64\right)}{U + -8}\\
\mathbf{elif}\;\ell \leq 1.25 \cdot 10^{+179}:\\
\;\;\;\;U + J \cdot \left(\left(K \cdot K\right) \cdot 0.0625 + -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\
\end{array}
\end{array}
if l < 8.5e19Initial program 80.6%
Taylor expanded in l around 0 90.1%
associate-*r*90.1%
associate-*r*90.1%
associate-*r*90.1%
associate-*r*90.1%
distribute-rgt-out90.1%
*-commutative90.1%
associate-*r*90.1%
*-commutative90.1%
associate-*r*90.1%
distribute-rgt-out90.1%
+-commutative90.1%
fma-def90.1%
Simplified90.1%
Taylor expanded in l around 0 77.3%
*-commutative77.3%
associate-*r*77.3%
Simplified77.3%
if 8.5e19 < l < 6.2e81Initial program 100.0%
Applied egg-rr37.0%
*-commutative37.0%
flip--37.0%
associate-*l/50.3%
fma-neg50.3%
metadata-eval50.3%
metadata-eval50.3%
Applied egg-rr50.3%
if 6.2e81 < l < 1.25e179Initial program 100.0%
Applied egg-rr2.3%
Taylor expanded in K around 0 37.6%
associate-*r*37.6%
distribute-rgt-out37.6%
*-commutative37.6%
unpow237.6%
Simplified37.6%
if 1.25e179 < l Initial program 100.0%
Taylor expanded in l around 0 45.0%
Taylor expanded in K around 0 20.2%
+-commutative20.2%
associate-*r*20.2%
distribute-rgt-out47.2%
*-commutative47.2%
unpow247.2%
Simplified47.2%
Final simplification68.9%
(FPCore (J l K U)
:precision binary64
(if (<= l 8.5e+19)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
(if (<= l 8.2e+81)
(/ (* U (fma U U -64.0)) (+ U -8.0))
(if (<= l 1.35e+182)
(+ U (* J (+ (* (* K K) 0.0625) -0.5)))
(+ U (* (* l J) (+ 2.0 (* (* K K) -0.25))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 8.5e+19) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 8.2e+81) {
tmp = (U * fma(U, U, -64.0)) / (U + -8.0);
} else if (l <= 1.35e+182) {
tmp = U + (J * (((K * K) * 0.0625) + -0.5));
} else {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= 8.5e+19) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); elseif (l <= 8.2e+81) tmp = Float64(Float64(U * fma(U, U, -64.0)) / Float64(U + -8.0)); elseif (l <= 1.35e+182) tmp = Float64(U + Float64(J * Float64(Float64(Float64(K * K) * 0.0625) + -0.5))); else tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25)))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, 8.5e+19], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8.2e+81], N[(N[(U * N[(U * U + -64.0), $MachinePrecision]), $MachinePrecision] / N[(U + -8.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.35e+182], N[(U + N[(J * N[(N[(N[(K * K), $MachinePrecision] * 0.0625), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 8.5 \cdot 10^{+19}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 8.2 \cdot 10^{+81}:\\
\;\;\;\;\frac{U \cdot \mathsf{fma}\left(U, U, -64\right)}{U + -8}\\
\mathbf{elif}\;\ell \leq 1.35 \cdot 10^{+182}:\\
\;\;\;\;U + J \cdot \left(\left(K \cdot K\right) \cdot 0.0625 + -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\
\end{array}
\end{array}
if l < 8.5e19Initial program 80.6%
Taylor expanded in l around 0 77.4%
if 8.5e19 < l < 8.20000000000000024e81Initial program 100.0%
Applied egg-rr37.0%
*-commutative37.0%
flip--37.0%
associate-*l/50.3%
fma-neg50.3%
metadata-eval50.3%
metadata-eval50.3%
Applied egg-rr50.3%
if 8.20000000000000024e81 < l < 1.3500000000000001e182Initial program 100.0%
Applied egg-rr2.3%
Taylor expanded in K around 0 37.6%
associate-*r*37.6%
distribute-rgt-out37.6%
*-commutative37.6%
unpow237.6%
Simplified37.6%
if 1.3500000000000001e182 < l Initial program 100.0%
Taylor expanded in l around 0 45.0%
Taylor expanded in K around 0 20.2%
+-commutative20.2%
associate-*r*20.2%
distribute-rgt-out47.2%
*-commutative47.2%
unpow247.2%
Simplified47.2%
Final simplification68.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l 1.16e+85) (not (<= l 1.55e+201))) (+ U (* l (* J 2.0))) (+ U (* J (+ (* (* K K) 0.0625) -0.5)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= 1.16e+85) || !(l <= 1.55e+201)) {
tmp = U + (l * (J * 2.0));
} else {
tmp = U + (J * (((K * K) * 0.0625) + -0.5));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= 1.16d+85) .or. (.not. (l <= 1.55d+201))) then
tmp = u + (l * (j * 2.0d0))
else
tmp = u + (j * (((k * k) * 0.0625d0) + (-0.5d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= 1.16e+85) || !(l <= 1.55e+201)) {
tmp = U + (l * (J * 2.0));
} else {
tmp = U + (J * (((K * K) * 0.0625) + -0.5));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= 1.16e+85) or not (l <= 1.55e+201): tmp = U + (l * (J * 2.0)) else: tmp = U + (J * (((K * K) * 0.0625) + -0.5)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= 1.16e+85) || !(l <= 1.55e+201)) tmp = Float64(U + Float64(l * Float64(J * 2.0))); else tmp = Float64(U + Float64(J * Float64(Float64(Float64(K * K) * 0.0625) + -0.5))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= 1.16e+85) || ~((l <= 1.55e+201))) tmp = U + (l * (J * 2.0)); else tmp = U + (J * (((K * K) * 0.0625) + -0.5)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, 1.16e+85], N[Not[LessEqual[l, 1.55e+201]], $MachinePrecision]], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(N[(N[(K * K), $MachinePrecision] * 0.0625), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.16 \cdot 10^{+85} \lor \neg \left(\ell \leq 1.55 \cdot 10^{+201}\right):\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\left(K \cdot K\right) \cdot 0.0625 + -0.5\right)\\
\end{array}
\end{array}
if l < 1.15999999999999995e85 or 1.5499999999999999e201 < l Initial program 83.9%
Taylor expanded in l around 0 69.9%
Taylor expanded in K around 0 59.0%
*-commutative59.0%
associate-*l*59.0%
Simplified59.0%
if 1.15999999999999995e85 < l < 1.5499999999999999e201Initial program 100.0%
Applied egg-rr2.3%
Taylor expanded in K around 0 36.2%
associate-*r*36.2%
distribute-rgt-out36.2%
*-commutative36.2%
unpow236.2%
Simplified36.2%
Final simplification56.7%
(FPCore (J l K U) :precision binary64 (if (<= l -1.28e+22) (* U U) (if (<= l 400000000000.0) U (* U (- U -8.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.28e+22) {
tmp = U * U;
} else if (l <= 400000000000.0) {
tmp = U;
} else {
tmp = U * (U - -8.0);
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-1.28d+22)) then
tmp = u * u
else if (l <= 400000000000.0d0) then
tmp = u
else
tmp = u * (u - (-8.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.28e+22) {
tmp = U * U;
} else if (l <= 400000000000.0) {
tmp = U;
} else {
tmp = U * (U - -8.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1.28e+22: tmp = U * U elif l <= 400000000000.0: tmp = U else: tmp = U * (U - -8.0) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1.28e+22) tmp = Float64(U * U); elseif (l <= 400000000000.0) tmp = U; else tmp = Float64(U * Float64(U - -8.0)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1.28e+22) tmp = U * U; elseif (l <= 400000000000.0) tmp = U; else tmp = U * (U - -8.0); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.28e+22], N[(U * U), $MachinePrecision], If[LessEqual[l, 400000000000.0], U, N[(U * N[(U - -8.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.28 \cdot 10^{+22}:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 400000000000:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(U - -8\right)\\
\end{array}
\end{array}
if l < -1.28e22Initial program 100.0%
Applied egg-rr13.5%
if -1.28e22 < l < 4e11Initial program 73.1%
Taylor expanded in J around 0 66.9%
if 4e11 < l Initial program 100.0%
Applied egg-rr20.9%
Final simplification44.2%
(FPCore (J l K U) :precision binary64 (if (<= l -7.5e+21) (* U U) (if (<= l 1.4e+19) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -7.5e+21) {
tmp = U * U;
} else if (l <= 1.4e+19) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (l <= (-7.5d+21)) then
tmp = u * u
else if (l <= 1.4d+19) then
tmp = u
else
tmp = u * u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -7.5e+21) {
tmp = U * U;
} else if (l <= 1.4e+19) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -7.5e+21: tmp = U * U elif l <= 1.4e+19: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -7.5e+21) tmp = Float64(U * U); elseif (l <= 1.4e+19) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -7.5e+21) tmp = U * U; elseif (l <= 1.4e+19) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -7.5e+21], N[(U * U), $MachinePrecision], If[LessEqual[l, 1.4e+19], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.5 \cdot 10^{+21}:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+19}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -7.5e21 or 1.4e19 < l Initial program 100.0%
Applied egg-rr17.9%
if -7.5e21 < l < 1.4e19Initial program 73.3%
Taylor expanded in J around 0 66.4%
Final simplification44.2%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J 2.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (l * (j * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
def code(J, l, K, U): return U + (l * (J * 2.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Initial program 85.5%
Taylor expanded in l around 0 63.7%
Taylor expanded in K around 0 53.8%
*-commutative53.8%
associate-*l*53.8%
Simplified53.8%
Final simplification53.8%
(FPCore (J l K U) :precision binary64 1.0)
double code(double J, double l, double K, double U) {
return 1.0;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = 1.0d0
end function
public static double code(double J, double l, double K, double U) {
return 1.0;
}
def code(J, l, K, U): return 1.0
function code(J, l, K, U) return 1.0 end
function tmp = code(J, l, K, U) tmp = 1.0; end
code[J_, l_, K_, U_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 85.5%
Applied egg-rr2.8%
*-inverses2.8%
Simplified2.8%
Final simplification2.8%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 85.5%
Taylor expanded in J around 0 37.2%
Final simplification37.2%
herbie shell --seed 2023200
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))