
(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 (+ (* J (log1p (expm1 (* l (* 2.0 (cos (* K 0.5))))))) U))
double code(double J, double l, double K, double U) {
return (J * log1p(expm1((l * (2.0 * cos((K * 0.5))))))) + U;
}
public static double code(double J, double l, double K, double U) {
return (J * Math.log1p(Math.expm1((l * (2.0 * Math.cos((K * 0.5))))))) + U;
}
def code(J, l, K, U): return (J * math.log1p(math.expm1((l * (2.0 * math.cos((K * 0.5))))))) + U
function code(J, l, K, U) return Float64(Float64(J * log1p(expm1(Float64(l * Float64(2.0 * cos(Float64(K * 0.5))))))) + U) end
code[J_, l_, K_, U_] := N[(N[(J * N[Log[1 + N[(Exp[N[(l * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\right) + U
\end{array}
Initial program 85.6%
Taylor expanded in l around 0 90.7%
*-commutative90.7%
Simplified90.7%
Taylor expanded in l around 0 62.6%
*-commutative62.6%
associate-*l*62.6%
associate-*r*62.6%
*-commutative62.6%
*-commutative62.6%
*-commutative62.6%
*-commutative62.6%
*-commutative62.6%
associate-*l*62.6%
*-commutative62.6%
Simplified62.6%
log1p-expm1-u99.3%
*-commutative99.3%
*-commutative99.3%
metadata-eval99.3%
div-inv99.3%
associate-*l*99.3%
div-inv99.3%
metadata-eval99.3%
Applied egg-rr99.3%
Final simplification99.3%
(FPCore (J l K U)
:precision binary64
(if (<= (cos (/ K 2.0)) 0.999999999999999)
(+
U
(*
J
(* l (* (+ 2.0 (* 0.016666666666666666 (pow l 4.0))) (cos (* K 0.5))))))
(+ U (* J (log1p (expm1 (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.999999999999999) {
tmp = U + (J * (l * ((2.0 + (0.016666666666666666 * pow(l, 4.0))) * cos((K * 0.5)))));
} else {
tmp = U + (J * log1p(expm1((l * 2.0))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.999999999999999) {
tmp = U + (J * (l * ((2.0 + (0.016666666666666666 * Math.pow(l, 4.0))) * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * Math.log1p(Math.expm1((l * 2.0))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.999999999999999: tmp = U + (J * (l * ((2.0 + (0.016666666666666666 * math.pow(l, 4.0))) * math.cos((K * 0.5))))) else: tmp = U + (J * math.log1p(math.expm1((l * 2.0)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.999999999999999) tmp = Float64(U + Float64(J * Float64(l * Float64(Float64(2.0 + Float64(0.016666666666666666 * (l ^ 4.0))) * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(J * log1p(expm1(Float64(l * 2.0))))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.999999999999999], N[(U + N[(J * N[(l * N[(N[(2.0 + N[(0.016666666666666666 * N[Power[l, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.999999999999999:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(\left(2 + 0.016666666666666666 \cdot {\ell}^{4}\right) \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.999999999999999001Initial program 86.0%
Taylor expanded in l around 0 91.3%
*-commutative91.3%
Simplified91.3%
Taylor expanded in l around inf 91.3%
Taylor expanded in J around 0 91.3%
if 0.999999999999999001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.3%
Taylor expanded in l around 0 90.1%
*-commutative90.1%
Simplified90.1%
Taylor expanded in l around 0 61.8%
*-commutative61.8%
associate-*l*61.8%
associate-*r*61.8%
*-commutative61.8%
*-commutative61.8%
*-commutative61.8%
*-commutative61.8%
*-commutative61.8%
associate-*l*61.8%
*-commutative61.8%
Simplified61.8%
log1p-expm1-u99.4%
*-commutative99.4%
*-commutative99.4%
metadata-eval99.4%
div-inv99.4%
associate-*l*99.4%
div-inv99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in K around 0 84.8%
expm1-define99.4%
Simplified99.4%
Final simplification95.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.999999999999999)
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.016666666666666666 (pow l 4.0)))))))
(+ U (* J (log1p (expm1 (* l 2.0))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.999999999999999) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.016666666666666666 * pow(l, 4.0))))));
} else {
tmp = U + (J * log1p(expm1((l * 2.0))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.999999999999999) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.016666666666666666 * Math.pow(l, 4.0))))));
} else {
tmp = U + (J * Math.log1p(Math.expm1((l * 2.0))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.999999999999999: tmp = U + (t_0 * (J * (l * (2.0 + (0.016666666666666666 * math.pow(l, 4.0)))))) else: tmp = U + (J * math.log1p(math.expm1((l * 2.0)))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.999999999999999) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.016666666666666666 * (l ^ 4.0))))))); else tmp = Float64(U + Float64(J * log1p(expm1(Float64(l * 2.0))))); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.999999999999999], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.016666666666666666 * N[Power[l, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.999999999999999:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.016666666666666666 \cdot {\ell}^{4}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.999999999999999001Initial program 86.0%
Taylor expanded in l around 0 91.3%
*-commutative91.3%
Simplified91.3%
Taylor expanded in l around inf 91.3%
if 0.999999999999999001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.3%
Taylor expanded in l around 0 90.1%
*-commutative90.1%
Simplified90.1%
Taylor expanded in l around 0 61.8%
*-commutative61.8%
associate-*l*61.8%
associate-*r*61.8%
*-commutative61.8%
*-commutative61.8%
*-commutative61.8%
*-commutative61.8%
*-commutative61.8%
associate-*l*61.8%
*-commutative61.8%
Simplified61.8%
log1p-expm1-u99.4%
*-commutative99.4%
*-commutative99.4%
metadata-eval99.4%
div-inv99.4%
associate-*l*99.4%
div-inv99.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in K around 0 84.8%
expm1-define99.4%
Simplified99.4%
Final simplification95.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.07) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (* J (log1p (expm1 (* l 2.0)))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.07) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (J * log1p(expm1((l * 2.0))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.07) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * Math.log1p(Math.expm1((l * 2.0))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.07: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (J * math.log1p(math.expm1((l * 2.0)))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.07) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(J * log1p(expm1(Float64(l * 2.0))))); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.07], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.07:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.070000000000000007Initial program 90.2%
Taylor expanded in l around 0 66.7%
if -0.070000000000000007 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.5%
Taylor expanded in l around 0 90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in l around 0 61.5%
*-commutative61.5%
associate-*l*61.5%
associate-*r*61.5%
*-commutative61.5%
*-commutative61.5%
*-commutative61.5%
*-commutative61.5%
*-commutative61.5%
associate-*l*61.5%
*-commutative61.5%
Simplified61.5%
log1p-expm1-u99.5%
*-commutative99.5%
*-commutative99.5%
metadata-eval99.5%
div-inv99.5%
associate-*l*99.5%
div-inv99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Taylor expanded in K around 0 84.0%
expm1-define95.1%
Simplified95.1%
Final simplification89.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (pow l 5.0) (* J (* 0.016666666666666666 (cos (* K 0.5))))))))
(if (<= l -3.7e+58)
t_0
(if (<= l -460.0)
(+ U (* J (log1p (expm1 (* l 2.0)))))
(if (<= l 0.000155)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
(if (<= l 1.95e+60) (+ U (* J (- (exp l) (exp (- l))))) t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (pow(l, 5.0) * (J * (0.016666666666666666 * cos((K * 0.5)))));
double tmp;
if (l <= -3.7e+58) {
tmp = t_0;
} else if (l <= -460.0) {
tmp = U + (J * log1p(expm1((l * 2.0))));
} else if (l <= 0.000155) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 1.95e+60) {
tmp = U + (J * (exp(l) - exp(-l)));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = U + (Math.pow(l, 5.0) * (J * (0.016666666666666666 * Math.cos((K * 0.5)))));
double tmp;
if (l <= -3.7e+58) {
tmp = t_0;
} else if (l <= -460.0) {
tmp = U + (J * Math.log1p(Math.expm1((l * 2.0))));
} else if (l <= 0.000155) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 1.95e+60) {
tmp = U + (J * (Math.exp(l) - Math.exp(-l)));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.pow(l, 5.0) * (J * (0.016666666666666666 * math.cos((K * 0.5))))) tmp = 0 if l <= -3.7e+58: tmp = t_0 elif l <= -460.0: tmp = U + (J * math.log1p(math.expm1((l * 2.0)))) elif l <= 0.000155: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) elif l <= 1.95e+60: tmp = U + (J * (math.exp(l) - math.exp(-l))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64((l ^ 5.0) * Float64(J * Float64(0.016666666666666666 * cos(Float64(K * 0.5)))))) tmp = 0.0 if (l <= -3.7e+58) tmp = t_0; elseif (l <= -460.0) tmp = Float64(U + Float64(J * log1p(expm1(Float64(l * 2.0))))); elseif (l <= 0.000155) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); elseif (l <= 1.95e+60) tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l))))); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * N[(0.016666666666666666 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.7e+58], t$95$0, If[LessEqual[l, -460.0], N[(U + N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.000155], 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.95e+60], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + {\ell}^{5} \cdot \left(J \cdot \left(0.016666666666666666 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{if}\;\ell \leq -3.7 \cdot 10^{+58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -460:\\
\;\;\;\;U + J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 0.000155:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 1.95 \cdot 10^{+60}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -3.7000000000000002e58 or 1.95000000000000015e60 < l Initial program 100.0%
Taylor expanded in l around 0 99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in l around inf 99.0%
*-commutative99.0%
associate-*r*99.0%
*-commutative99.0%
associate-*l*99.0%
associate-*r*99.0%
associate-*l*99.0%
Simplified99.0%
if -3.7000000000000002e58 < l < -460Initial program 100.0%
Taylor expanded in l around 0 23.1%
*-commutative23.1%
Simplified23.1%
Taylor expanded in l around 0 3.2%
*-commutative3.2%
associate-*l*3.2%
associate-*r*3.2%
*-commutative3.2%
*-commutative3.2%
*-commutative3.2%
*-commutative3.2%
*-commutative3.2%
associate-*l*3.2%
*-commutative3.2%
Simplified3.2%
log1p-expm1-u100.0%
*-commutative100.0%
*-commutative100.0%
metadata-eval100.0%
div-inv100.0%
associate-*l*100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in K around 0 93.3%
expm1-define93.3%
Simplified93.3%
if -460 < l < 1.55e-4Initial program 70.8%
Taylor expanded in l around 0 99.9%
if 1.55e-4 < l < 1.95000000000000015e60Initial program 98.5%
Taylor expanded in K around 0 86.1%
Final simplification98.3%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.07) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (+ U (* J (* l (+ 2.0 (* 0.016666666666666666 (pow l 4.0))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.07) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (J * (l * (2.0 + (0.016666666666666666 * pow(l, 4.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.07d0)) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u + (j * (l * (2.0d0 + (0.016666666666666666d0 * (l ** 4.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.07) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * (l * (2.0 + (0.016666666666666666 * Math.pow(l, 4.0)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.07: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (J * (l * (2.0 + (0.016666666666666666 * math.pow(l, 4.0))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.07) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.016666666666666666 * (l ^ 4.0)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.07) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (J * (l * (2.0 + (0.016666666666666666 * (l ^ 4.0))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.07], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.016666666666666666 * N[Power[l, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.07:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.016666666666666666 \cdot {\ell}^{4}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.070000000000000007Initial program 90.2%
Taylor expanded in l around 0 66.7%
if -0.070000000000000007 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.5%
Taylor expanded in l around 0 90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in l around inf 89.8%
Taylor expanded in K around 0 85.3%
Final simplification81.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1950000000000.0) (not (<= l 15500.0))) (+ U (* (pow l 5.0) (* J 0.016666666666666666))) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1950000000000.0) || !(l <= 15500.0)) {
tmp = U + (pow(l, 5.0) * (J * 0.016666666666666666));
} else {
tmp = U + (2.0 * (J * (l * cos((K * 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 <= (-1950000000000.0d0)) .or. (.not. (l <= 15500.0d0))) then
tmp = u + ((l ** 5.0d0) * (j * 0.016666666666666666d0))
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1950000000000.0) || !(l <= 15500.0)) {
tmp = U + (Math.pow(l, 5.0) * (J * 0.016666666666666666));
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1950000000000.0) or not (l <= 15500.0): tmp = U + (math.pow(l, 5.0) * (J * 0.016666666666666666)) else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1950000000000.0) || !(l <= 15500.0)) tmp = Float64(U + Float64((l ^ 5.0) * Float64(J * 0.016666666666666666))); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1950000000000.0) || ~((l <= 15500.0))) tmp = U + ((l ^ 5.0) * (J * 0.016666666666666666)); else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1950000000000.0], N[Not[LessEqual[l, 15500.0]], $MachinePrecision]], N[(U + N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1950000000000 \lor \neg \left(\ell \leq 15500\right):\\
\;\;\;\;U + {\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -1.95e12 or 15500 < l Initial program 100.0%
Taylor expanded in l around 0 84.0%
*-commutative84.0%
Simplified84.0%
Taylor expanded in l around inf 84.0%
*-commutative84.0%
associate-*r*84.0%
*-commutative84.0%
associate-*l*84.0%
associate-*r*84.0%
associate-*l*84.0%
Simplified84.0%
Taylor expanded in K around 0 65.6%
*-commutative65.6%
*-commutative65.6%
associate-*l*65.6%
Simplified65.6%
if -1.95e12 < l < 15500Initial program 71.9%
Taylor expanded in l around 0 96.4%
Final simplification81.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -8400000000000.0) (not (<= l 460.0))) (+ U (* (pow l 5.0) (* J 0.016666666666666666))) (+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -8400000000000.0) || !(l <= 460.0)) {
tmp = U + (pow(l, 5.0) * (J * 0.016666666666666666));
} 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 <= (-8400000000000.0d0)) .or. (.not. (l <= 460.0d0))) then
tmp = u + ((l ** 5.0d0) * (j * 0.016666666666666666d0))
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 <= -8400000000000.0) || !(l <= 460.0)) {
tmp = U + (Math.pow(l, 5.0) * (J * 0.016666666666666666));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -8400000000000.0) or not (l <= 460.0): tmp = U + (math.pow(l, 5.0) * (J * 0.016666666666666666)) 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 <= -8400000000000.0) || !(l <= 460.0)) tmp = Float64(U + Float64((l ^ 5.0) * Float64(J * 0.016666666666666666))); 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 <= -8400000000000.0) || ~((l <= 460.0))) tmp = U + ((l ^ 5.0) * (J * 0.016666666666666666)); 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, -8400000000000.0], N[Not[LessEqual[l, 460.0]], $MachinePrecision]], N[(U + N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $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 -8400000000000 \lor \neg \left(\ell \leq 460\right):\\
\;\;\;\;U + {\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\\
\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 < -8.4e12 or 460 < l Initial program 100.0%
Taylor expanded in l around 0 84.0%
*-commutative84.0%
Simplified84.0%
Taylor expanded in l around inf 84.0%
*-commutative84.0%
associate-*r*84.0%
*-commutative84.0%
associate-*l*84.0%
associate-*r*84.0%
associate-*l*84.0%
Simplified84.0%
Taylor expanded in K around 0 65.6%
*-commutative65.6%
*-commutative65.6%
associate-*l*65.6%
Simplified65.6%
if -8.4e12 < l < 460Initial program 71.9%
Taylor expanded in l around 0 96.4%
Final simplification81.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1200000000000.0) (not (<= l 15.8))) (+ U (* (pow l 5.0) (* J 0.016666666666666666))) (+ U (* l (* J 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1200000000000.0) || !(l <= 15.8)) {
tmp = U + (pow(l, 5.0) * (J * 0.016666666666666666));
} 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 ((l <= (-1200000000000.0d0)) .or. (.not. (l <= 15.8d0))) then
tmp = u + ((l ** 5.0d0) * (j * 0.016666666666666666d0))
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 ((l <= -1200000000000.0) || !(l <= 15.8)) {
tmp = U + (Math.pow(l, 5.0) * (J * 0.016666666666666666));
} else {
tmp = U + (l * (J * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1200000000000.0) or not (l <= 15.8): tmp = U + (math.pow(l, 5.0) * (J * 0.016666666666666666)) else: tmp = U + (l * (J * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1200000000000.0) || !(l <= 15.8)) tmp = Float64(U + Float64((l ^ 5.0) * Float64(J * 0.016666666666666666))); 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 ((l <= -1200000000000.0) || ~((l <= 15.8))) tmp = U + ((l ^ 5.0) * (J * 0.016666666666666666)); else tmp = U + (l * (J * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1200000000000.0], N[Not[LessEqual[l, 15.8]], $MachinePrecision]], N[(U + N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1200000000000 \lor \neg \left(\ell \leq 15.8\right):\\
\;\;\;\;U + {\ell}^{5} \cdot \left(J \cdot 0.016666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\end{array}
\end{array}
if l < -1.2e12 or 15.800000000000001 < l Initial program 100.0%
Taylor expanded in l around 0 84.0%
*-commutative84.0%
Simplified84.0%
Taylor expanded in l around inf 84.0%
*-commutative84.0%
associate-*r*84.0%
*-commutative84.0%
associate-*l*84.0%
associate-*r*84.0%
associate-*l*84.0%
Simplified84.0%
Taylor expanded in K around 0 65.6%
*-commutative65.6%
*-commutative65.6%
associate-*l*65.6%
Simplified65.6%
if -1.2e12 < l < 15.800000000000001Initial program 71.9%
Taylor expanded in l around 0 97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in l around 0 96.4%
*-commutative96.4%
associate-*l*96.4%
associate-*r*96.4%
*-commutative96.4%
*-commutative96.4%
*-commutative96.4%
*-commutative96.4%
*-commutative96.4%
associate-*l*96.4%
*-commutative96.4%
Simplified96.4%
log1p-expm1-u98.6%
*-commutative98.6%
*-commutative98.6%
metadata-eval98.6%
div-inv98.6%
associate-*l*98.6%
div-inv98.6%
metadata-eval98.6%
Applied egg-rr98.6%
Taylor expanded in K around 0 85.4%
associate-*r*85.4%
Simplified85.4%
Final simplification75.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -235000.0) (not (<= l 3.1e-18))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -235000.0) || !(l <= 3.1e-18)) {
tmp = U * U;
} else {
tmp = 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 <= (-235000.0d0)) .or. (.not. (l <= 3.1d-18))) then
tmp = u * u
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -235000.0) || !(l <= 3.1e-18)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -235000.0) or not (l <= 3.1e-18): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -235000.0) || !(l <= 3.1e-18)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -235000.0) || ~((l <= 3.1e-18))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -235000.0], N[Not[LessEqual[l, 3.1e-18]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -235000 \lor \neg \left(\ell \leq 3.1 \cdot 10^{-18}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -235000 or 3.10000000000000007e-18 < l Initial program 98.1%
associate-*l*98.1%
fma-define98.1%
Simplified98.1%
Applied egg-rr18.1%
if -235000 < l < 3.10000000000000007e-18Initial program 72.1%
associate-*l*72.1%
fma-define72.1%
Simplified72.1%
Taylor expanded in J around 0 70.8%
Final simplification43.4%
(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.6%
Taylor expanded in l around 0 90.7%
*-commutative90.7%
Simplified90.7%
Taylor expanded in l around 0 62.6%
*-commutative62.6%
associate-*l*62.6%
associate-*r*62.6%
*-commutative62.6%
*-commutative62.6%
*-commutative62.6%
*-commutative62.6%
*-commutative62.6%
associate-*l*62.6%
*-commutative62.6%
Simplified62.6%
log1p-expm1-u99.3%
*-commutative99.3%
*-commutative99.3%
metadata-eval99.3%
div-inv99.3%
associate-*l*99.3%
div-inv99.3%
metadata-eval99.3%
Applied egg-rr99.3%
Taylor expanded in K around 0 53.3%
associate-*r*53.3%
Simplified53.3%
Final simplification53.3%
(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.6%
associate-*l*85.6%
fma-define85.6%
Simplified85.6%
Applied egg-rr2.6%
*-inverses2.6%
Simplified2.6%
Final simplification2.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 85.6%
associate-*l*85.6%
fma-define85.6%
Simplified85.6%
Taylor expanded in J around 0 35.3%
Final simplification35.3%
herbie shell --seed 2024082
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))