
(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
(let* ((t_0 (exp (- l))) (t_1 (cos (/ K 2.0))))
(if (<= l -0.74)
(+ U (* t_1 (* J (- 0.3333333333333333 t_0))))
(if (<= l 0.0039)
(+ U (* J (* 2.0 (* l (cos (* K 0.5))))))
(if (<= l 8e+102)
(+ U (* J (- (exp l) t_0)))
(+ U (* t_1 (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(-l);
double t_1 = cos((K / 2.0));
double tmp;
if (l <= -0.74) {
tmp = U + (t_1 * (J * (0.3333333333333333 - t_0)));
} else if (l <= 0.0039) {
tmp = U + (J * (2.0 * (l * cos((K * 0.5)))));
} else if (l <= 8e+102) {
tmp = U + (J * (exp(l) - t_0));
} else {
tmp = U + (t_1 * (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 = exp(-l)
t_1 = cos((k / 2.0d0))
if (l <= (-0.74d0)) then
tmp = u + (t_1 * (j * (0.3333333333333333d0 - t_0)))
else if (l <= 0.0039d0) then
tmp = u + (j * (2.0d0 * (l * cos((k * 0.5d0)))))
else if (l <= 8d+102) then
tmp = u + (j * (exp(l) - t_0))
else
tmp = u + (t_1 * (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.exp(-l);
double t_1 = Math.cos((K / 2.0));
double tmp;
if (l <= -0.74) {
tmp = U + (t_1 * (J * (0.3333333333333333 - t_0)));
} else if (l <= 0.0039) {
tmp = U + (J * (2.0 * (l * Math.cos((K * 0.5)))));
} else if (l <= 8e+102) {
tmp = U + (J * (Math.exp(l) - t_0));
} else {
tmp = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(-l) t_1 = math.cos((K / 2.0)) tmp = 0 if l <= -0.74: tmp = U + (t_1 * (J * (0.3333333333333333 - t_0))) elif l <= 0.0039: tmp = U + (J * (2.0 * (l * math.cos((K * 0.5))))) elif l <= 8e+102: tmp = U + (J * (math.exp(l) - t_0)) else: tmp = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))) return tmp
function code(J, l, K, U) t_0 = exp(Float64(-l)) t_1 = cos(Float64(K / 2.0)) tmp = 0.0 if (l <= -0.74) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(0.3333333333333333 - t_0)))); elseif (l <= 0.0039) tmp = Float64(U + Float64(J * Float64(2.0 * Float64(l * cos(Float64(K * 0.5)))))); elseif (l <= 8e+102) tmp = Float64(U + Float64(J * Float64(exp(l) - t_0))); else tmp = Float64(U + Float64(t_1 * 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 = exp(-l); t_1 = cos((K / 2.0)); tmp = 0.0; if (l <= -0.74) tmp = U + (t_1 * (J * (0.3333333333333333 - t_0))); elseif (l <= 0.0039) tmp = U + (J * (2.0 * (l * cos((K * 0.5))))); elseif (l <= 8e+102) tmp = U + (J * (exp(l) - t_0)); else tmp = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -0.74], N[(U + N[(t$95$1 * N[(J * N[(0.3333333333333333 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 0.0039], N[(U + N[(J * N[(2.0 * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 8e+102], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$1 * 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 := e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;\ell \leq -0.74:\\
\;\;\;\;U + t\_1 \cdot \left(J \cdot \left(0.3333333333333333 - t\_0\right)\right)\\
\mathbf{elif}\;\ell \leq 0.0039:\\
\;\;\;\;U + J \cdot \left(2 \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 8 \cdot 10^{+102}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;U + t\_1 \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.73999999999999999Initial program 100.0%
Applied egg-rr98.5%
if -0.73999999999999999 < l < 0.0038999999999999998Initial program 75.9%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
*-commutative99.9%
Simplified99.9%
if 0.0038999999999999998 < l < 7.99999999999999982e102Initial program 100.0%
Taylor expanded in K around 0 85.0%
if 7.99999999999999982e102 < 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 (+ (* (* J (log1p (expm1 (* l 2.0)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * log1p(expm1((l * 2.0)))) * cos((K / 2.0))) + 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 / 2.0))) + U;
}
def code(J, l, K, U): return ((J * math.log1p(math.expm1((l * 2.0)))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * log1p(expm1(Float64(l * 2.0)))) * cos(Float64(K / 2.0))) + U) end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[Log[1 + N[(Exp[N[(l * 2.0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\ell \cdot 2\right)\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Initial program 88.7%
Taylor expanded in l around 0 60.5%
*-commutative60.5%
associate-*l*60.5%
Simplified60.5%
log1p-expm1-u98.2%
Applied egg-rr98.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.325) (* U (+ 1.0 (* 2.0 (* J (/ (* l (cos (* K 0.5))) U))))) (* U (+ 1.0 (/ (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))) U)))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.325) {
tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U))));
} else {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))) / 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 (cos((k / 2.0d0)) <= 0.325d0) then
tmp = u * (1.0d0 + (2.0d0 * (j * ((l * cos((k * 0.5d0))) / u))))
else
tmp = u * (1.0d0 + ((j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))) / u))
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.325) {
tmp = U * (1.0 + (2.0 * (J * ((l * Math.cos((K * 0.5))) / U))));
} else {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))) / U));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.325: tmp = U * (1.0 + (2.0 * (J * ((l * math.cos((K * 0.5))) / U)))) else: tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) / U)) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.325) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(l * cos(Float64(K * 0.5))) / U))))); else tmp = Float64(U * Float64(1.0 + Float64(Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))) / U))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.325) tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U)))); else tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))) / U)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.325], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.325:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell \cdot \cos \left(K \cdot 0.5\right)}{U}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}{U}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.325000000000000011Initial program 86.5%
Taylor expanded in l around 0 62.1%
*-commutative62.1%
associate-*l*62.1%
Simplified62.1%
log1p-expm1-u99.0%
Applied egg-rr99.0%
Taylor expanded in U around inf 66.3%
associate-/l*75.1%
Simplified75.1%
if 0.325000000000000011 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.8%
Taylor expanded in l around 0 85.8%
Taylor expanded in K around 0 83.2%
Taylor expanded in U around inf 83.5%
Final simplification80.6%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.325) (* U (+ 1.0 (* 2.0 (* J (/ (* l (cos (* K 0.5))) U))))) (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.325) {
tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U))));
} else {
tmp = U + (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) :: tmp
if (cos((k / 2.0d0)) <= 0.325d0) then
tmp = u * (1.0d0 + (2.0d0 * (j * ((l * cos((k * 0.5d0))) / u))))
else
tmp = u + (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 tmp;
if (Math.cos((K / 2.0)) <= 0.325) {
tmp = U * (1.0 + (2.0 * (J * ((l * Math.cos((K * 0.5))) / U))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.325: tmp = U * (1.0 + (2.0 * (J * ((l * math.cos((K * 0.5))) / U)))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.325) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(Float64(l * cos(Float64(K * 0.5))) / U))))); else tmp = Float64(U + 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) tmp = 0.0; if (cos((K / 2.0)) <= 0.325) tmp = U * (1.0 + (2.0 * (J * ((l * cos((K * 0.5))) / U)))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.325], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.325:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell \cdot \cos \left(K \cdot 0.5\right)}{U}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.325000000000000011Initial program 86.5%
Taylor expanded in l around 0 62.1%
*-commutative62.1%
associate-*l*62.1%
Simplified62.1%
log1p-expm1-u99.0%
Applied egg-rr99.0%
Taylor expanded in U around inf 66.3%
associate-/l*75.1%
Simplified75.1%
if 0.325000000000000011 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.8%
Taylor expanded in l around 0 85.8%
Taylor expanded in K around 0 83.2%
unpow285.8%
Applied egg-rr83.2%
Final simplification80.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.325) (+ U (* J (* 2.0 (* l (cos (* K 0.5)))))) (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.325) {
tmp = U + (J * (2.0 * (l * cos((K * 0.5)))));
} else {
tmp = U + (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) :: tmp
if (cos((k / 2.0d0)) <= 0.325d0) then
tmp = u + (j * (2.0d0 * (l * cos((k * 0.5d0)))))
else
tmp = u + (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 tmp;
if (Math.cos((K / 2.0)) <= 0.325) {
tmp = U + (J * (2.0 * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.325: tmp = U + (J * (2.0 * (l * math.cos((K * 0.5))))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.325) tmp = Float64(U + Float64(J * Float64(2.0 * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + 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) tmp = 0.0; if (cos((K / 2.0)) <= 0.325) tmp = U + (J * (2.0 * (l * cos((K * 0.5))))); else tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.325], N[(U + N[(J * N[(2.0 * 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.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.325:\\
\;\;\;\;U + J \cdot \left(2 \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.325000000000000011Initial program 86.5%
Taylor expanded in l around 0 62.1%
*-commutative62.1%
associate-*l*62.1%
*-commutative62.1%
*-commutative62.1%
Simplified62.1%
if 0.325000000000000011 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.8%
Taylor expanded in l around 0 85.8%
Taylor expanded in K around 0 83.2%
unpow285.8%
Applied egg-rr83.2%
Final simplification75.9%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 5e-132)
(+ U (* J (- (exp l) (exp (- l)))))
(+
U
(* (cos (/ K 2.0)) (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((K / 2.0) <= 5e-132) {
tmp = U + (J * (exp(l) - exp(-l)));
} else {
tmp = U + (cos((K / 2.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) :: tmp
if ((k / 2.0d0) <= 5d-132) then
tmp = u + (j * (exp(l) - exp(-l)))
else
tmp = u + (cos((k / 2.0d0)) * (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 tmp;
if ((K / 2.0) <= 5e-132) {
tmp = U + (J * (Math.exp(l) - Math.exp(-l)));
} else {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (K / 2.0) <= 5e-132: tmp = U + (J * (math.exp(l) - math.exp(-l))) else: tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (Float64(K / 2.0) <= 5e-132) tmp = Float64(U + Float64(J * Float64(exp(l) - exp(Float64(-l))))); else tmp = Float64(U + Float64(cos(Float64(K / 2.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) tmp = 0.0; if ((K / 2.0) <= 5e-132) tmp = U + (J * (exp(l) - exp(-l))); else tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[(K / 2.0), $MachinePrecision], 5e-132], N[(U + N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;\frac{K}{2} \leq 5 \cdot 10^{-132}:\\
\;\;\;\;U + J \cdot \left(e^{\ell} - e^{-\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;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}
\end{array}
if (/.f64 K #s(literal 2 binary64)) < 4.9999999999999999e-132Initial program 87.6%
Taylor expanded in K around 0 70.5%
if 4.9999999999999999e-132 < (/.f64 K #s(literal 2 binary64)) Initial program 91.0%
Taylor expanded in l around 0 92.8%
unpow292.8%
Applied egg-rr92.8%
Final simplification77.6%
(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 88.7%
Taylor expanded in l around 0 89.2%
unpow289.2%
Applied egg-rr89.2%
Final simplification89.2%
(FPCore (J l K U) :precision binary64 (if (<= K 10500.0) (* U (+ 1.0 (* 2.0 (* J (/ l U))))) (+ U (* (* J l) -6.0))))
double code(double J, double l, double K, double U) {
double tmp;
if (K <= 10500.0) {
tmp = U * (1.0 + (2.0 * (J * (l / U))));
} else {
tmp = U + ((J * l) * -6.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 (k <= 10500.0d0) then
tmp = u * (1.0d0 + (2.0d0 * (j * (l / u))))
else
tmp = u + ((j * l) * (-6.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (K <= 10500.0) {
tmp = U * (1.0 + (2.0 * (J * (l / U))));
} else {
tmp = U + ((J * l) * -6.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if K <= 10500.0: tmp = U * (1.0 + (2.0 * (J * (l / U)))) else: tmp = U + ((J * l) * -6.0) return tmp
function code(J, l, K, U) tmp = 0.0 if (K <= 10500.0) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))); else tmp = Float64(U + Float64(Float64(J * l) * -6.0)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (K <= 10500.0) tmp = U * (1.0 + (2.0 * (J * (l / U)))); else tmp = U + ((J * l) * -6.0); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[K, 10500.0], N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * l), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 10500:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \ell\right) \cdot -6\\
\end{array}
\end{array}
if K < 10500Initial program 87.5%
Taylor expanded in l around 0 61.8%
*-commutative61.8%
associate-*l*61.8%
Simplified61.8%
log1p-expm1-u97.6%
Applied egg-rr97.6%
Taylor expanded in K around 0 49.2%
associate-*r*49.2%
Simplified49.2%
Taylor expanded in U around inf 53.3%
associate-/l*55.3%
Simplified55.3%
if 10500 < K Initial program 92.6%
Taylor expanded in l around 0 55.9%
*-commutative55.9%
associate-*l*55.9%
Simplified55.9%
Applied egg-rr46.1%
Taylor expanded in K around 0 44.5%
*-commutative44.5%
Simplified44.5%
Final simplification52.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -5.5) (not (<= l 120.0))) (/ (* U U) U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -5.5) || !(l <= 120.0)) {
tmp = (U * 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 <= (-5.5d0)) .or. (.not. (l <= 120.0d0))) then
tmp = (u * 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 <= -5.5) || !(l <= 120.0)) {
tmp = (U * U) / U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -5.5) or not (l <= 120.0): tmp = (U * U) / U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -5.5) || !(l <= 120.0)) tmp = Float64(Float64(U * U) / U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -5.5) || ~((l <= 120.0))) tmp = (U * U) / U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -5.5], N[Not[LessEqual[l, 120.0]], $MachinePrecision]], N[(N[(U * U), $MachinePrecision] / U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.5 \lor \neg \left(\ell \leq 120\right):\\
\;\;\;\;\frac{U \cdot U}{U}\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -5.5 or 120 < l Initial program 100.0%
Applied egg-rr3.3%
flip-+20.6%
metadata-eval20.6%
div-sub20.6%
sub0-neg20.6%
pow220.6%
sub0-neg20.6%
Applied egg-rr20.6%
div020.6%
neg-sub020.6%
distribute-frac-neg220.6%
remove-double-neg20.6%
Simplified20.6%
unpow220.6%
Applied egg-rr20.6%
if -5.5 < l < 120Initial program 76.3%
Applied egg-rr57.1%
Taylor expanded in U around inf 74.9%
Final simplification46.5%
(FPCore (J l K U) :precision binary64 (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))))
double code(double J, double l, double K, double U) {
return U + (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 + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
}
def code(J, l, K, U): return U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))) end
function tmp = code(J, l, K, U) tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)
\end{array}
Initial program 88.7%
Taylor expanded in l around 0 89.2%
Taylor expanded in K around 0 66.3%
unpow289.2%
Applied egg-rr66.3%
Final simplification66.3%
(FPCore (J l K U) :precision binary64 (if (<= K 10500.0) (+ U (* 2.0 (* J l))) (+ U (* (* J l) -6.0))))
double code(double J, double l, double K, double U) {
double tmp;
if (K <= 10500.0) {
tmp = U + (2.0 * (J * l));
} else {
tmp = U + ((J * l) * -6.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 (k <= 10500.0d0) then
tmp = u + (2.0d0 * (j * l))
else
tmp = u + ((j * l) * (-6.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (K <= 10500.0) {
tmp = U + (2.0 * (J * l));
} else {
tmp = U + ((J * l) * -6.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if K <= 10500.0: tmp = U + (2.0 * (J * l)) else: tmp = U + ((J * l) * -6.0) return tmp
function code(J, l, K, U) tmp = 0.0 if (K <= 10500.0) tmp = Float64(U + Float64(2.0 * Float64(J * l))); else tmp = Float64(U + Float64(Float64(J * l) * -6.0)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (K <= 10500.0) tmp = U + (2.0 * (J * l)); else tmp = U + ((J * l) * -6.0); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[K, 10500.0], N[(U + N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(J * l), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 10500:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \ell\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(J \cdot \ell\right) \cdot -6\\
\end{array}
\end{array}
if K < 10500Initial program 87.5%
Taylor expanded in l around 0 61.8%
*-commutative61.8%
associate-*l*61.8%
Simplified61.8%
Taylor expanded in K around 0 49.2%
if 10500 < K Initial program 92.6%
Taylor expanded in l around 0 55.9%
*-commutative55.9%
associate-*l*55.9%
Simplified55.9%
Applied egg-rr46.1%
Taylor expanded in K around 0 44.5%
*-commutative44.5%
Simplified44.5%
Final simplification48.1%
(FPCore (J l K U) :precision binary64 (if (<= K 10500.0) (+ U (* 2.0 (* J l))) (+ U (* J (* l -6.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (K <= 10500.0) {
tmp = U + (2.0 * (J * l));
} else {
tmp = U + (J * (l * -6.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 (k <= 10500.0d0) then
tmp = u + (2.0d0 * (j * l))
else
tmp = u + (j * (l * (-6.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (K <= 10500.0) {
tmp = U + (2.0 * (J * l));
} else {
tmp = U + (J * (l * -6.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if K <= 10500.0: tmp = U + (2.0 * (J * l)) else: tmp = U + (J * (l * -6.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (K <= 10500.0) tmp = Float64(U + Float64(2.0 * Float64(J * l))); else tmp = Float64(U + Float64(J * Float64(l * -6.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (K <= 10500.0) tmp = U + (2.0 * (J * l)); else tmp = U + (J * (l * -6.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[K, 10500.0], N[(U + N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 10500:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \ell\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot -6\right)\\
\end{array}
\end{array}
if K < 10500Initial program 87.5%
Taylor expanded in l around 0 61.8%
*-commutative61.8%
associate-*l*61.8%
Simplified61.8%
Taylor expanded in K around 0 49.2%
if 10500 < K Initial program 92.6%
Taylor expanded in l around 0 55.9%
*-commutative55.9%
associate-*l*55.9%
Simplified55.9%
Applied egg-rr46.1%
Taylor expanded in K around 0 44.5%
*-commutative44.5%
associate-*r*44.5%
Simplified44.5%
Final simplification48.1%
(FPCore (J l K U) :precision binary64 (if (<= l -1.16e+51) (/ (* U U) U) (+ U (* 2.0 (* J l)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.16e+51) {
tmp = (U * U) / U;
} 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 <= (-1.16d+51)) then
tmp = (u * u) / u
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 <= -1.16e+51) {
tmp = (U * U) / U;
} else {
tmp = U + (2.0 * (J * l));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1.16e+51: tmp = (U * U) / U else: tmp = U + (2.0 * (J * l)) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1.16e+51) tmp = Float64(Float64(U * U) / U); 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 <= -1.16e+51) tmp = (U * U) / U; else tmp = U + (2.0 * (J * l)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.16e+51], N[(N[(U * U), $MachinePrecision] / U), $MachinePrecision], N[(U + N[(2.0 * N[(J * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.16 \cdot 10^{+51}:\\
\;\;\;\;\frac{U \cdot U}{U}\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \ell\right)\\
\end{array}
\end{array}
if l < -1.16e51Initial program 100.0%
Applied egg-rr2.7%
flip-+25.1%
metadata-eval25.1%
div-sub25.1%
sub0-neg25.1%
pow225.1%
sub0-neg25.1%
Applied egg-rr25.1%
div025.1%
neg-sub025.1%
distribute-frac-neg225.1%
remove-double-neg25.1%
Simplified25.1%
unpow225.1%
Applied egg-rr25.1%
if -1.16e51 < l Initial program 85.7%
Taylor expanded in l around 0 68.9%
*-commutative68.9%
associate-*l*68.9%
Simplified68.9%
Taylor expanded in K around 0 57.4%
Final simplification50.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 88.7%
Applied egg-rr28.9%
Taylor expanded in U around inf 37.5%
(FPCore (J l K U) :precision binary64 -4.0)
double code(double J, double l, double K, double U) {
return -4.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 = -4.0d0
end function
public static double code(double J, double l, double K, double U) {
return -4.0;
}
def code(J, l, K, U): return -4.0
function code(J, l, K, U) return -4.0 end
function tmp = code(J, l, K, U) tmp = -4.0; end
code[J_, l_, K_, U_] := -4.0
\begin{array}{l}
\\
-4
\end{array}
Initial program 88.7%
Applied egg-rr28.9%
Taylor expanded in U around 0 3.1%
herbie shell --seed 2024148
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))