
(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 15 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 (* K 0.5))))))) U))
double code(double J, double l, double K, double U) {
return (2.0 * (J * log1p(expm1((l * cos((K * 0.5))))))) + U;
}
public static double code(double J, double l, double K, double U) {
return (2.0 * (J * Math.log1p(Math.expm1((l * Math.cos((K * 0.5))))))) + U;
}
def code(J, l, K, U): return (2.0 * (J * math.log1p(math.expm1((l * math.cos((K * 0.5))))))) + U
function code(J, l, K, U) return Float64(Float64(2.0 * Float64(J * log1p(expm1(Float64(l * cos(Float64(K * 0.5))))))) + U) end
code[J_, l_, K_, U_] := N[(N[(2.0 * N[(J * N[Log[1 + N[(Exp[N[(l * N[Cos[N[(K * 0.5), $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(K \cdot 0.5\right)\right)\right)\right) + U
\end{array}
Initial program 85.6%
Taylor expanded in l around 0 63.9%
log1p-expm1-u99.0%
*-commutative99.0%
Applied egg-rr99.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.16)
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))))
(+ U (* 2.0 (* J (log1p (expm1 l))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if (t_0 <= 0.16) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
} else {
tmp = U + (2.0 * (J * log1p(expm1(l))));
}
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.16) {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
} else {
tmp = U + (2.0 * (J * Math.log1p(Math.expm1(l))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.16: tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))) else: tmp = U + (2.0 * (J * math.log1p(math.expm1(l)))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= 0.16) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l))))))); else tmp = Float64(U + Float64(2.0 * Float64(J * log1p(expm1(l))))); 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.16], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $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}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.16:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\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.160000000000000003Initial program 88.6%
Taylor expanded in l around 0 89.7%
unpow289.7%
Applied egg-rr89.7%
if 0.160000000000000003 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 84.4%
Taylor expanded in l around 0 64.0%
log1p-expm1-u99.6%
*-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in K around 0 84.0%
expm1-define97.0%
Simplified97.0%
Final simplification94.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (exp (- l))))
(if (<= l -0.72)
(+ U (* (* J (- 0.3333333333333333 t_1)) t_0))
(if (<= l 1.4e-5)
(+ U (* l (* J (* 2.0 (cos (* K 0.5))))))
(if (<= l 1.6e+97)
(+ U (* J (- (exp l) t_1)))
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(-l);
double tmp;
if (l <= -0.72) {
tmp = U + ((J * (0.3333333333333333 - t_1)) * t_0);
} else if (l <= 1.4e-5) {
tmp = U + (l * (J * (2.0 * cos((K * 0.5)))));
} else if (l <= 1.6e+97) {
tmp = U + (J * (exp(l) - t_1));
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
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) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(-l)
if (l <= (-0.72d0)) then
tmp = u + ((j * (0.3333333333333333d0 - t_1)) * t_0)
else if (l <= 1.4d-5) then
tmp = u + (l * (j * (2.0d0 * cos((k * 0.5d0)))))
else if (l <= 1.6d+97) then
tmp = u + (j * (exp(l) - t_1))
else
tmp = u + (t_0 * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(-l);
double tmp;
if (l <= -0.72) {
tmp = U + ((J * (0.3333333333333333 - t_1)) * t_0);
} else if (l <= 1.4e-5) {
tmp = U + (l * (J * (2.0 * Math.cos((K * 0.5)))));
} else if (l <= 1.6e+97) {
tmp = U + (J * (Math.exp(l) - t_1));
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(-l) tmp = 0 if l <= -0.72: tmp = U + ((J * (0.3333333333333333 - t_1)) * t_0) elif l <= 1.4e-5: tmp = U + (l * (J * (2.0 * math.cos((K * 0.5))))) elif l <= 1.6e+97: tmp = U + (J * (math.exp(l) - t_1)) else: tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = exp(Float64(-l)) tmp = 0.0 if (l <= -0.72) tmp = Float64(U + Float64(Float64(J * Float64(0.3333333333333333 - t_1)) * t_0)); elseif (l <= 1.4e-5) tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 * cos(Float64(K * 0.5)))))); elseif (l <= 1.6e+97) tmp = Float64(U + Float64(J * Float64(exp(l) - t_1))); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l))))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(-l); tmp = 0.0; if (l <= -0.72) tmp = U + ((J * (0.3333333333333333 - t_1)) * t_0); elseif (l <= 1.4e-5) tmp = U + (l * (J * (2.0 * cos((K * 0.5))))); elseif (l <= 1.6e+97) tmp = U + (J * (exp(l) - t_1)); else tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-l)], $MachinePrecision]}, If[LessEqual[l, -0.72], N[(U + N[(N[(J * N[(0.3333333333333333 - t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.4e-5], N[(U + N[(l * N[(J * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.6e+97], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{-\ell}\\
\mathbf{if}\;\ell \leq -0.72:\\
\;\;\;\;U + \left(J \cdot \left(0.3333333333333333 - t\_1\right)\right) \cdot t\_0\\
\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{-5}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 1.6 \cdot 10^{+97}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)\\
\end{array}
\end{array}
if l < -0.71999999999999997Initial program 100.0%
Applied egg-rr99.9%
if -0.71999999999999997 < l < 1.39999999999999998e-5Initial program 71.7%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*l*99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
Simplified99.9%
if 1.39999999999999998e-5 < l < 1.60000000000000008e97Initial program 100.0%
Taylor expanded in K around 0 82.6%
if 1.60000000000000008e97 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
unpow2100.0%
Applied egg-rr100.0%
Final simplification98.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 0.75)
(+ U (* t_0 (* l (* 2.0 J))))
(+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (pow 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.75) {
tmp = U + (t_0 * (l * (2.0 * J)));
} 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) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= 0.75d0) then
tmp = u + (t_0 * (l * (2.0d0 * j)))
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 t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= 0.75) {
tmp = U + (t_0 * (l * (2.0 * J)));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= 0.75: tmp = U + (t_0 * (l * (2.0 * J))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * math.pow(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.75) tmp = Float64(U + Float64(t_0 * Float64(l * Float64(2.0 * J)))); 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) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= 0.75) tmp = U + (t_0 * (l * (2.0 * J))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))); end tmp_2 = 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.75], N[(U + N[(t$95$0 * N[(l * N[(2.0 * J), $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}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq 0.75:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.75Initial program 88.5%
Taylor expanded in l around 0 65.7%
associate-*r*65.7%
Simplified65.7%
if 0.75 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 83.8%
Taylor expanded in l around 0 86.8%
Taylor expanded in K around 0 85.4%
Final simplification77.8%
(FPCore (J l K U) :precision binary64 (+ U (* (cos (/ K 2.0)) (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
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 + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
end function
public static double code(double J, double l, double K, double U) {
return U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
def code(J, l, K, U): return U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))))
function code(J, l, K, U) return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l))))))) end
function tmp = code(J, l, K, U) tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))); end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\right)
\end{array}
Initial program 85.6%
Taylor expanded in l around 0 86.6%
unpow286.6%
Applied egg-rr86.6%
Final simplification86.6%
(FPCore (J l K U) :precision binary64 (if (or (<= l -3.8e+23) (not (<= l 8.5e+255))) (+ U (* 2.0 (* J (+ l (* -0.125 (* l (* K K))))))) (fma l (* 2.0 J) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3.8e+23) || !(l <= 8.5e+255)) {
tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K))))));
} else {
tmp = fma(l, (2.0 * J), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -3.8e+23) || !(l <= 8.5e+255)) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l + Float64(-0.125 * Float64(l * Float64(K * K))))))); else tmp = fma(l, Float64(2.0 * J), U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3.8e+23], N[Not[LessEqual[l, 8.5e+255]], $MachinePrecision]], N[(U + N[(2.0 * N[(J * N[(l + N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(l * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.8 \cdot 10^{+23} \lor \neg \left(\ell \leq 8.5 \cdot 10^{+255}\right):\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell, 2 \cdot J, U\right)\\
\end{array}
\end{array}
if l < -3.79999999999999975e23 or 8.49999999999999959e255 < l Initial program 100.0%
Taylor expanded in l around 0 28.5%
Taylor expanded in K around 0 37.8%
unpow237.8%
Applied egg-rr37.8%
if -3.79999999999999975e23 < l < 8.49999999999999959e255Initial program 81.2%
Taylor expanded in l around 0 74.7%
Taylor expanded in K around 0 50.1%
Taylor expanded in K around 0 67.9%
+-commutative67.9%
associate-*r*67.9%
*-commutative67.9%
*-commutative67.9%
fma-define67.9%
*-commutative67.9%
Simplified67.9%
Final simplification60.8%
(FPCore (J l K U) :precision binary64 (+ U (* (cos (/ K 2.0)) (* l (* 2.0 J)))))
double code(double J, double l, double K, double U) {
return U + (cos((K / 2.0)) * (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 + (cos((k / 2.0d0)) * (l * (2.0d0 * j)))
end function
public static double code(double J, double l, double K, double U) {
return U + (Math.cos((K / 2.0)) * (l * (2.0 * J)));
}
def code(J, l, K, U): return U + (math.cos((K / 2.0)) * (l * (2.0 * J)))
function code(J, l, K, U) return Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(l * Float64(2.0 * J)))) end
function tmp = code(J, l, K, U) tmp = U + (cos((K / 2.0)) * (l * (2.0 * J))); end
code[J_, l_, K_, U_] := N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * N[(2.0 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot \left(2 \cdot J\right)\right)
\end{array}
Initial program 85.6%
Taylor expanded in l around 0 64.2%
associate-*r*64.2%
Simplified64.2%
Final simplification64.2%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J (* 2.0 (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (l * (J * (2.0 * cos((K * 0.5)))));
}
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 * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * (2.0 * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (l * (J * (2.0 * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * Float64(2.0 * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * (2.0 * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 85.6%
Taylor expanded in l around 0 63.9%
*-commutative63.9%
associate-*r*63.9%
associate-*l*63.9%
*-commutative63.9%
*-commutative63.9%
associate-*l*63.9%
Simplified63.9%
Final simplification63.9%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * cos((K * 0.5)))));
}
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 + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (2.0 * (J * (l * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 85.6%
Taylor expanded in l around 0 63.9%
Final simplification63.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2e+23) (not (<= l 6.1e+255))) (+ U (* 2.0 (* J (+ l (* -0.125 (* l (* K K))))))) (+ U (* 2.0 (* J l)))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2e+23) || !(l <= 6.1e+255)) {
tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K))))));
} else {
tmp = U + (2.0 * (J * l));
}
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 <= (-2d+23)) .or. (.not. (l <= 6.1d+255))) then
tmp = u + (2.0d0 * (j * (l + ((-0.125d0) * (l * (k * k))))))
else
tmp = u + (2.0d0 * (j * l))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2e+23) || !(l <= 6.1e+255)) {
tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K))))));
} else {
tmp = U + (2.0 * (J * l));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2e+23) or not (l <= 6.1e+255): tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K)))))) else: tmp = U + (2.0 * (J * l)) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2e+23) || !(l <= 6.1e+255)) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l + Float64(-0.125 * Float64(l * Float64(K * K))))))); else tmp = Float64(U + Float64(2.0 * Float64(J * l))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2e+23) || ~((l <= 6.1e+255))) tmp = U + (2.0 * (J * (l + (-0.125 * (l * (K * K)))))); else tmp = U + (2.0 * (J * l)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2e+23], N[Not[LessEqual[l, 6.1e+255]], $MachinePrecision]], N[(U + N[(2.0 * N[(J * N[(l + N[(-0.125 * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2 \cdot 10^{+23} \lor \neg \left(\ell \leq 6.1 \cdot 10^{+255}\right):\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell + -0.125 \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \ell\right)\\
\end{array}
\end{array}
if l < -1.9999999999999998e23 or 6.09999999999999995e255 < l Initial program 100.0%
Taylor expanded in l around 0 28.5%
Taylor expanded in K around 0 37.8%
unpow237.8%
Applied egg-rr37.8%
if -1.9999999999999998e23 < l < 6.09999999999999995e255Initial program 81.2%
Taylor expanded in l around 0 74.7%
Taylor expanded in K around 0 67.9%
Final simplification60.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -1.8e-18) (not (<= l 0.75))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -1.8e-18) || !(l <= 0.75)) {
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 <= (-1.8d-18)) .or. (.not. (l <= 0.75d0))) 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 <= -1.8e-18) || !(l <= 0.75)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -1.8e-18) or not (l <= 0.75): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -1.8e-18) || !(l <= 0.75)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -1.8e-18) || ~((l <= 0.75))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -1.8e-18], N[Not[LessEqual[l, 0.75]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.8 \cdot 10^{-18} \lor \neg \left(\ell \leq 0.75\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -1.80000000000000005e-18 or 0.75 < l Initial program 98.5%
Applied egg-rr14.9%
if -1.80000000000000005e-18 < l < 0.75Initial program 73.0%
Taylor expanded in J around 0 72.7%
Final simplification44.0%
(FPCore (J l K U) :precision binary64 (if (<= l -3.2e-31) (* U (- U -4.0)) (if (<= l 0.75) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -3.2e-31) {
tmp = U * (U - -4.0);
} else if (l <= 0.75) {
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 <= (-3.2d-31)) then
tmp = u * (u - (-4.0d0))
else if (l <= 0.75d0) 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 <= -3.2e-31) {
tmp = U * (U - -4.0);
} else if (l <= 0.75) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -3.2e-31: tmp = U * (U - -4.0) elif l <= 0.75: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -3.2e-31) tmp = Float64(U * Float64(U - -4.0)); elseif (l <= 0.75) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -3.2e-31) tmp = U * (U - -4.0); elseif (l <= 0.75) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -3.2e-31], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.75], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.2 \cdot 10^{-31}:\\
\;\;\;\;U \cdot \left(U - -4\right)\\
\mathbf{elif}\;\ell \leq 0.75:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -3.20000000000000018e-31Initial program 92.9%
Applied egg-rr15.4%
if -3.20000000000000018e-31 < l < 0.75Initial program 74.5%
Taylor expanded in J around 0 74.3%
if 0.75 < l Initial program 100.0%
Applied egg-rr14.1%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J l))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * l));
}
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 + (2.0d0 * (j * l))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * l));
}
def code(J, l, K, U): return U + (2.0 * (J * l))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * l))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * l)); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \ell\right)
\end{array}
Initial program 85.6%
Taylor expanded in l around 0 63.9%
Taylor expanded in K around 0 56.4%
Final simplification56.4%
(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%
Taylor expanded in J around 0 37.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.6%
Applied egg-rr2.8%
Taylor expanded in U around 0 2.8%
herbie shell --seed 2024123
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))