
(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 13 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 (+ (* 2.0 (* J (log1p (expm1 (* l (cos (* 0.5 K))))))) U))
double code(double J, double l, double K, double U) {
return (2.0 * (J * log1p(expm1((l * cos((0.5 * K))))))) + U;
}
public static double code(double J, double l, double K, double U) {
return (2.0 * (J * Math.log1p(Math.expm1((l * Math.cos((0.5 * K))))))) + U;
}
def code(J, l, K, U): return (2.0 * (J * math.log1p(math.expm1((l * math.cos((0.5 * K))))))) + U
function code(J, l, K, U) return Float64(Float64(2.0 * Float64(J * log1p(expm1(Float64(l * cos(Float64(0.5 * K))))))) + U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\right) + U
\end{array}
Initial program 86.8%
Taylor expanded in l around 0 60.1%
log1p-expm1-u99.3%
Applied egg-rr99.3%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (+ U (* 2.0 (* J (* l (cos (* 0.5 K)))))) (+ U (* 2.0 (* J (log1p (expm1 l)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.01) {
tmp = U + (2.0 * (J * (l * cos((0.5 * K)))));
} else {
tmp = U + (2.0 * (J * log1p(expm1(l))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.01) {
tmp = U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
} else {
tmp = U + (2.0 * (J * Math.log1p(Math.expm1(l))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.01: tmp = U + (2.0 * (J * (l * math.cos((0.5 * K))))) else: tmp = U + (2.0 * (J * math.log1p(math.expm1(l)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.01) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))); else tmp = Float64(U + Float64(2.0 * Float64(J * log1p(expm1(l))))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.01], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.01:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0100000000000000002Initial program 86.6%
Taylor expanded in l around 0 66.4%
if -0.0100000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.8%
Taylor expanded in l around 0 58.1%
log1p-expm1-u99.1%
Applied egg-rr99.1%
Taylor expanded in K around 0 95.0%
Final simplification88.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (log1p (expm1 (* J (* 2.0 l))))))
(t_1 (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l -3.5e+135)
t_1
(if (<= l -850000.0)
t_0
(if (<= l 290.0)
(+ U (* 2.0 (* J (* l (cos (* 0.5 K))))))
(if (<= l 8.8e+104) t_0 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = U + log1p(expm1((J * (2.0 * l))));
double t_1 = U + (0.3333333333333333 * (J * pow(l, 3.0)));
double tmp;
if (l <= -3.5e+135) {
tmp = t_1;
} else if (l <= -850000.0) {
tmp = t_0;
} else if (l <= 290.0) {
tmp = U + (2.0 * (J * (l * cos((0.5 * K)))));
} else if (l <= 8.8e+104) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = U + Math.log1p(Math.expm1((J * (2.0 * l))));
double t_1 = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
double tmp;
if (l <= -3.5e+135) {
tmp = t_1;
} else if (l <= -850000.0) {
tmp = t_0;
} else if (l <= 290.0) {
tmp = U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
} else if (l <= 8.8e+104) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + math.log1p(math.expm1((J * (2.0 * l)))) t_1 = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) tmp = 0 if l <= -3.5e+135: tmp = t_1 elif l <= -850000.0: tmp = t_0 elif l <= 290.0: tmp = U + (2.0 * (J * (l * math.cos((0.5 * K))))) elif l <= 8.8e+104: tmp = t_0 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = Float64(U + log1p(expm1(Float64(J * Float64(2.0 * l))))) t_1 = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))) tmp = 0.0 if (l <= -3.5e+135) tmp = t_1; elseif (l <= -850000.0) tmp = t_0; elseif (l <= 290.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))); elseif (l <= 8.8e+104) tmp = t_0; else tmp = t_1; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[Log[1 + N[(Exp[N[(J * N[(2.0 * l), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.5e+135], t$95$1, If[LessEqual[l, -850000.0], t$95$0, If[LessEqual[l, 290.0], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8.8e+104], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + \mathsf{log1p}\left(\mathsf{expm1}\left(J \cdot \left(2 \cdot \ell\right)\right)\right)\\
t_1 := U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{if}\;\ell \leq -3.5 \cdot 10^{+135}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -850000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 290:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 8.8 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -3.5000000000000003e135 or 8.80000000000000002e104 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in K around 0 71.6%
Taylor expanded in l around inf 71.6%
if -3.5000000000000003e135 < l < -8.5e5 or 290 < l < 8.80000000000000002e104Initial program 100.0%
Taylor expanded in K around 0 78.6%
Taylor expanded in l around 0 8.5%
associate-*r*8.5%
Simplified8.5%
log1p-expm1-u47.3%
*-commutative47.3%
associate-*l*47.3%
*-commutative47.3%
Applied egg-rr47.3%
if -8.5e5 < l < 290Initial program 73.1%
Taylor expanded in l around 0 98.5%
Final simplification79.6%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 1e-28)
(+ U (* 2.0 (* J (log1p (expm1 l)))))
(+
U
(*
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))
(cos (/ K 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 1e-28) {
tmp = U + (2.0 * (J * log1p(expm1(l))));
} else {
tmp = U + ((J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))) * cos((K / 2.0)));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 1e-28) {
tmp = U + (2.0 * (J * Math.log1p(Math.expm1(l))));
} else {
tmp = U + ((J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))) * Math.cos((K / 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (K / 2.0) <= 1e-28: tmp = U + (2.0 * (J * math.log1p(math.expm1(l)))) else: tmp = U + ((J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) * math.cos((K / 2.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 1e-28) tmp = Float64(U + Float64(2.0 * Float64(J * log1p(expm1(l))))); else tmp = Float64(U + Float64(Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))) * cos(Float64(K / 2.0)))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 1e-28], N[(U + N[(2.0 * N[(J * N[Log[1 + N[(Exp[l] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 10^{-28}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right)\\
\end{array}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 9.99999999999999971e-29Initial program 87.0%
Taylor expanded in l around 0 58.3%
log1p-expm1-u99.0%
Applied egg-rr99.0%
Taylor expanded in K around 0 83.9%
if 9.99999999999999971e-29 < (/.f64 K #s(literal 2 binary64)) Initial program 86.3%
Taylor expanded in l around 0 91.1%
Final simplification86.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.1) (+ U (* (* J -0.25) (* l (pow K 2.0)))) (+ U (* 0.3333333333333333 (* J (pow l 3.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.1) {
tmp = U + ((J * -0.25) * (l * pow(K, 2.0)));
} else {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.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.1d0)) then
tmp = u + ((j * (-0.25d0)) * (l * (k ** 2.0d0)))
else
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.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.1) {
tmp = U + ((J * -0.25) * (l * Math.pow(K, 2.0)));
} else {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.1: tmp = U + ((J * -0.25) * (l * math.pow(K, 2.0))) else: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.1) tmp = Float64(U + Float64(Float64(J * -0.25) * Float64(l * (K ^ 2.0)))); else tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.1) tmp = U + ((J * -0.25) * (l * (K ^ 2.0))); else tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.1], N[(U + N[(N[(J * -0.25), $MachinePrecision] * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.1:\\
\;\;\;\;U + \left(J \cdot -0.25\right) \cdot \left(\ell \cdot {K}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.10000000000000001Initial program 86.7%
Taylor expanded in l around 0 65.7%
associate-*r*35.4%
Simplified65.7%
Taylor expanded in K around 0 41.7%
Taylor expanded in K around inf 57.3%
associate-*r*57.3%
*-commutative57.3%
*-commutative57.3%
Simplified57.3%
if -0.10000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.8%
Taylor expanded in l around 0 84.0%
Taylor expanded in K around 0 78.0%
Taylor expanded in l around inf 69.0%
Final simplification66.3%
(FPCore (J l K U)
:precision binary64
(if (<= l -3.1e+56)
(+ U (* 0.3333333333333333 (* J (pow l 3.0))))
(if (<= l 3.7e-159)
(+ U (* 2.0 (* J (* l (cos (* 0.5 K))))))
(+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -3.1e+56) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else if (l <= 3.7e-159) {
tmp = U + (2.0 * (J * (l * cos((0.5 * K)))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * pow(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 <= (-3.1d+56)) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else if (l <= 3.7d-159) then
tmp = u + (2.0d0 * (j * (l * cos((0.5d0 * k)))))
else
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (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 <= -3.1e+56) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else if (l <= 3.7e-159) {
tmp = U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -3.1e+56: tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) elif l <= 3.7e-159: tmp = U + (2.0 * (J * (l * math.cos((0.5 * K))))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -3.1e+56) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); elseif (l <= 3.7e-159) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -3.1e+56) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); elseif (l <= 3.7e-159) tmp = U + (2.0 * (J * (l * cos((0.5 * K))))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -3.1e+56], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 3.7e-159], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.1 \cdot 10^{+56}:\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{elif}\;\ell \leq 3.7 \cdot 10^{-159}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if l < -3.10000000000000005e56Initial program 100.0%
Taylor expanded in l around 0 87.9%
Taylor expanded in K around 0 62.9%
Taylor expanded in l around inf 62.9%
if -3.10000000000000005e56 < l < 3.6999999999999999e-159Initial program 73.7%
Taylor expanded in l around 0 89.8%
if 3.6999999999999999e-159 < l Initial program 93.2%
Taylor expanded in l around 0 79.0%
Taylor expanded in K around 0 62.5%
Final simplification73.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -7.2e+117) (not (<= l 0.00182))) (+ U (* 0.3333333333333333 (* J (pow l 3.0)))) (+ U (* 2.0 (* J (* l (cos (* 0.5 K))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7.2e+117) || !(l <= 0.00182)) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else {
tmp = U + (2.0 * (J * (l * cos((0.5 * K)))));
}
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.2d+117)) .or. (.not. (l <= 0.00182d0))) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else
tmp = u + (2.0d0 * (j * (l * cos((0.5d0 * k)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7.2e+117) || !(l <= 0.00182)) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else {
tmp = U + (2.0 * (J * (l * Math.cos((0.5 * K)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -7.2e+117) or not (l <= 0.00182): tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) else: tmp = U + (2.0 * (J * (l * math.cos((0.5 * K))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -7.2e+117) || !(l <= 0.00182)) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(0.5 * K)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -7.2e+117) || ~((l <= 0.00182))) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); else tmp = U + (2.0 * (J * (l * cos((0.5 * K))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7.2e+117], N[Not[LessEqual[l, 0.00182]], $MachinePrecision]], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{+117} \lor \neg \left(\ell \leq 0.00182\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(0.5 \cdot K\right)\right)\right)\\
\end{array}
\end{array}
if l < -7.20000000000000025e117 or 0.00182 < l Initial program 100.0%
Taylor expanded in l around 0 80.9%
Taylor expanded in K around 0 58.0%
Taylor expanded in l around inf 58.0%
if -7.20000000000000025e117 < l < 0.00182Initial program 77.4%
Taylor expanded in l around 0 84.6%
Final simplification73.6%
(FPCore (J l K U)
:precision binary64
(if (<= l -2.3e+34)
(- U (* J (pow K 2.0)))
(if (<= l 2.05e-23)
(+ U (* l (* 2.0 J)))
(if (<= l 1.5e+137)
(* U (+ 1.0 (* J (/ 8.0 U))))
(* J (- 8.0 (pow K 2.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.3e+34) {
tmp = U - (J * pow(K, 2.0));
} else if (l <= 2.05e-23) {
tmp = U + (l * (2.0 * J));
} else if (l <= 1.5e+137) {
tmp = U * (1.0 + (J * (8.0 / U)));
} else {
tmp = J * (8.0 - pow(K, 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 <= (-2.3d+34)) then
tmp = u - (j * (k ** 2.0d0))
else if (l <= 2.05d-23) then
tmp = u + (l * (2.0d0 * j))
else if (l <= 1.5d+137) then
tmp = u * (1.0d0 + (j * (8.0d0 / u)))
else
tmp = j * (8.0d0 - (k ** 2.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -2.3e+34) {
tmp = U - (J * Math.pow(K, 2.0));
} else if (l <= 2.05e-23) {
tmp = U + (l * (2.0 * J));
} else if (l <= 1.5e+137) {
tmp = U * (1.0 + (J * (8.0 / U)));
} else {
tmp = J * (8.0 - Math.pow(K, 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -2.3e+34: tmp = U - (J * math.pow(K, 2.0)) elif l <= 2.05e-23: tmp = U + (l * (2.0 * J)) elif l <= 1.5e+137: tmp = U * (1.0 + (J * (8.0 / U))) else: tmp = J * (8.0 - math.pow(K, 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -2.3e+34) tmp = Float64(U - Float64(J * (K ^ 2.0))); elseif (l <= 2.05e-23) tmp = Float64(U + Float64(l * Float64(2.0 * J))); elseif (l <= 1.5e+137) tmp = Float64(U * Float64(1.0 + Float64(J * Float64(8.0 / U)))); else tmp = Float64(J * Float64(8.0 - (K ^ 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -2.3e+34) tmp = U - (J * (K ^ 2.0)); elseif (l <= 2.05e-23) tmp = U + (l * (2.0 * J)); elseif (l <= 1.5e+137) tmp = U * (1.0 + (J * (8.0 / U))); else tmp = J * (8.0 - (K ^ 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -2.3e+34], N[(U - N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.05e-23], N[(U + N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.5e+137], N[(U * N[(1.0 + N[(J * N[(8.0 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(J * N[(8.0 - N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{+34}:\\
\;\;\;\;U - J \cdot {K}^{2}\\
\mathbf{elif}\;\ell \leq 2.05 \cdot 10^{-23}:\\
\;\;\;\;U + \ell \cdot \left(2 \cdot J\right)\\
\mathbf{elif}\;\ell \leq 1.5 \cdot 10^{+137}:\\
\;\;\;\;U \cdot \left(1 + J \cdot \frac{8}{U}\right)\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(8 - {K}^{2}\right)\\
\end{array}
\end{array}
if l < -2.2999999999999998e34Initial program 100.0%
Applied egg-rr1.5%
Taylor expanded in K around 0 26.5%
+-commutative26.5%
mul-1-neg26.5%
unsub-neg26.5%
*-commutative26.5%
Simplified26.5%
Taylor expanded in K around inf 26.9%
mul-1-neg26.9%
distribute-rgt-neg-out26.9%
Simplified26.9%
if -2.2999999999999998e34 < l < 2.05000000000000015e-23Initial program 74.1%
Taylor expanded in K around 0 72.2%
Taylor expanded in l around 0 81.7%
associate-*r*81.0%
Simplified81.0%
if 2.05000000000000015e-23 < l < 1.5e137Initial program 98.4%
Applied egg-rr12.2%
Taylor expanded in U around inf 27.7%
associate-*r/27.7%
*-commutative27.7%
associate-*r*27.7%
Simplified27.7%
Taylor expanded in K around 0 24.9%
associate-*r/24.9%
*-commutative24.9%
associate-*r/24.9%
Simplified24.9%
if 1.5e137 < l Initial program 100.0%
Applied egg-rr3.3%
Taylor expanded in J around inf 17.2%
Taylor expanded in J around inf 3.1%
associate-*r*3.1%
*-commutative3.1%
*-commutative3.1%
Simplified3.1%
Taylor expanded in K around 0 27.5%
associate-*r*27.5%
+-commutative27.5%
mul-1-neg27.5%
cancel-sign-sub-inv27.5%
*-commutative27.5%
distribute-rgt-out--27.5%
Simplified27.5%
Final simplification53.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (- 8.0 (pow K 2.0)))))
(if (<= l -2.85e+20)
t_0
(if (<= l 2.05e-23)
(+ U (* l (* 2.0 J)))
(if (<= l 7.5e+137) (* U (+ 1.0 (* J (/ 8.0 U)))) t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = J * (8.0 - pow(K, 2.0));
double tmp;
if (l <= -2.85e+20) {
tmp = t_0;
} else if (l <= 2.05e-23) {
tmp = U + (l * (2.0 * J));
} else if (l <= 7.5e+137) {
tmp = U * (1.0 + (J * (8.0 / U)));
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = j * (8.0d0 - (k ** 2.0d0))
if (l <= (-2.85d+20)) then
tmp = t_0
else if (l <= 2.05d-23) then
tmp = u + (l * (2.0d0 * j))
else if (l <= 7.5d+137) then
tmp = u * (1.0d0 + (j * (8.0d0 / u)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = J * (8.0 - Math.pow(K, 2.0));
double tmp;
if (l <= -2.85e+20) {
tmp = t_0;
} else if (l <= 2.05e-23) {
tmp = U + (l * (2.0 * J));
} else if (l <= 7.5e+137) {
tmp = U * (1.0 + (J * (8.0 / U)));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = J * (8.0 - math.pow(K, 2.0)) tmp = 0 if l <= -2.85e+20: tmp = t_0 elif l <= 2.05e-23: tmp = U + (l * (2.0 * J)) elif l <= 7.5e+137: tmp = U * (1.0 + (J * (8.0 / U))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(J * Float64(8.0 - (K ^ 2.0))) tmp = 0.0 if (l <= -2.85e+20) tmp = t_0; elseif (l <= 2.05e-23) tmp = Float64(U + Float64(l * Float64(2.0 * J))); elseif (l <= 7.5e+137) tmp = Float64(U * Float64(1.0 + Float64(J * Float64(8.0 / U)))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = J * (8.0 - (K ^ 2.0)); tmp = 0.0; if (l <= -2.85e+20) tmp = t_0; elseif (l <= 2.05e-23) tmp = U + (l * (2.0 * J)); elseif (l <= 7.5e+137) tmp = U * (1.0 + (J * (8.0 / U))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[(8.0 - N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.85e+20], t$95$0, If[LessEqual[l, 2.05e-23], N[(U + N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7.5e+137], N[(U * N[(1.0 + N[(J * N[(8.0 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \left(8 - {K}^{2}\right)\\
\mathbf{if}\;\ell \leq -2.85 \cdot 10^{+20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 2.05 \cdot 10^{-23}:\\
\;\;\;\;U + \ell \cdot \left(2 \cdot J\right)\\
\mathbf{elif}\;\ell \leq 7.5 \cdot 10^{+137}:\\
\;\;\;\;U \cdot \left(1 + J \cdot \frac{8}{U}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -2.85e20 or 7.50000000000000025e137 < l Initial program 100.0%
Applied egg-rr2.0%
Taylor expanded in J around inf 10.4%
Taylor expanded in J around inf 1.4%
associate-*r*1.4%
*-commutative1.4%
*-commutative1.4%
Simplified1.4%
Taylor expanded in K around 0 26.8%
associate-*r*26.8%
+-commutative26.8%
mul-1-neg26.8%
cancel-sign-sub-inv26.8%
*-commutative26.8%
distribute-rgt-out--26.8%
Simplified26.8%
if -2.85e20 < l < 2.05000000000000015e-23Initial program 73.4%
Taylor expanded in K around 0 72.3%
Taylor expanded in l around 0 83.6%
associate-*r*82.8%
Simplified82.8%
if 2.05000000000000015e-23 < l < 7.50000000000000025e137Initial program 98.4%
Applied egg-rr12.2%
Taylor expanded in U around inf 27.7%
associate-*r/27.7%
*-commutative27.7%
associate-*r*27.7%
Simplified27.7%
Taylor expanded in K around 0 24.9%
associate-*r/24.9%
*-commutative24.9%
associate-*r/24.9%
Simplified24.9%
Final simplification53.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.1e+56) (not (<= l 2e-76))) (+ U (* 0.3333333333333333 (* J (pow l 3.0)))) (+ U (* l (* 2.0 J)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.1e+56) || !(l <= 2e-76)) {
tmp = U + (0.3333333333333333 * (J * pow(l, 3.0)));
} else {
tmp = U + (l * (2.0 * J));
}
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 <= (-2.1d+56)) .or. (.not. (l <= 2d-76))) then
tmp = u + (0.3333333333333333d0 * (j * (l ** 3.0d0)))
else
tmp = u + (l * (2.0d0 * j))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.1e+56) || !(l <= 2e-76)) {
tmp = U + (0.3333333333333333 * (J * Math.pow(l, 3.0)));
} else {
tmp = U + (l * (2.0 * J));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.1e+56) or not (l <= 2e-76): tmp = U + (0.3333333333333333 * (J * math.pow(l, 3.0))) else: tmp = U + (l * (2.0 * J)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.1e+56) || !(l <= 2e-76)) tmp = Float64(U + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))); else tmp = Float64(U + Float64(l * Float64(2.0 * J))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.1e+56) || ~((l <= 2e-76))) tmp = U + (0.3333333333333333 * (J * (l ^ 3.0))); else tmp = U + (l * (2.0 * J)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.1e+56], N[Not[LessEqual[l, 2e-76]], $MachinePrecision]], N[(U + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.1 \cdot 10^{+56} \lor \neg \left(\ell \leq 2 \cdot 10^{-76}\right):\\
\;\;\;\;U + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(2 \cdot J\right)\\
\end{array}
\end{array}
if l < -2.10000000000000017e56 or 1.99999999999999985e-76 < l Initial program 97.4%
Taylor expanded in l around 0 80.5%
Taylor expanded in K around 0 60.1%
Taylor expanded in l around inf 57.9%
if -2.10000000000000017e56 < l < 1.99999999999999985e-76Initial program 74.3%
Taylor expanded in K around 0 72.3%
Taylor expanded in l around 0 77.7%
associate-*r*76.9%
Simplified76.9%
Final simplification66.7%
(FPCore (J l K U) :precision binary64 (if (<= l 7.5e-20) U (* J (+ 8.0 (/ U J)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 7.5e-20) {
tmp = U;
} else {
tmp = J * (8.0 + (U / J));
}
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-20) then
tmp = u
else
tmp = j * (8.0d0 + (u / j))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= 7.5e-20) {
tmp = U;
} else {
tmp = J * (8.0 + (U / J));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= 7.5e-20: tmp = U else: tmp = J * (8.0 + (U / J)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= 7.5e-20) tmp = U; else tmp = Float64(J * Float64(8.0 + Float64(U / J))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= 7.5e-20) tmp = U; else tmp = J * (8.0 + (U / J)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, 7.5e-20], U, N[(J * N[(8.0 + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7.5 \cdot 10^{-20}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(8 + \frac{U}{J}\right)\\
\end{array}
\end{array}
if l < 7.49999999999999981e-20Initial program 82.3%
Applied egg-rr36.7%
Taylor expanded in J around 0 46.8%
if 7.49999999999999981e-20 < l Initial program 99.0%
Applied egg-rr7.3%
Taylor expanded in J around inf 14.3%
Taylor expanded in K around 0 13.6%
(FPCore (J l K U) :precision binary64 (+ U (* l (* 2.0 J))))
double code(double J, double l, double K, double U) {
return U + (l * (2.0 * J));
}
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 * (2.0d0 * j))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (2.0 * J));
}
def code(J, l, K, U): return U + (l * (2.0 * J))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(2.0 * J))) end
function tmp = code(J, l, K, U) tmp = U + (l * (2.0 * J)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(2 \cdot J\right)
\end{array}
Initial program 86.8%
Taylor expanded in K around 0 73.6%
Taylor expanded in l around 0 48.9%
associate-*r*48.6%
Simplified48.6%
Final simplification48.6%
(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 86.8%
Applied egg-rr28.5%
Taylor expanded in J around 0 36.1%
herbie shell --seed 2024105
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))