
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -0.5) (not (<= t_0 2e-16)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+ U (* l (* (cos (* K 0.5)) (* J 2.0)))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -0.5) || !(t_0 <= 2e-16)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (l * (cos((K * 0.5)) * (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) :: t_0
real(8) :: tmp
t_0 = exp(l) - exp(-l)
if ((t_0 <= (-0.5d0)) .or. (.not. (t_0 <= 2d-16))) then
tmp = ((t_0 * j) * cos((k / 2.0d0))) + u
else
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -0.5) || !(t_0 <= 2e-16)) {
tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -0.5) or not (t_0 <= 2e-16): tmp = ((t_0 * J) * math.cos((K / 2.0))) + U else: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -0.5) || !(t_0 <= 2e-16)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -0.5) || ~((t_0 <= 2e-16))) tmp = ((t_0 * J) * cos((K / 2.0))) + U; else tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.5], N[Not[LessEqual[t$95$0, 2e-16]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_0 \leq -0.5 \lor \neg \left(t\_0 \leq 2 \cdot 10^{-16}\right):\\
\;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.5 or 2e-16 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -0.5 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 2e-16Initial program 79.2%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
Simplified99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (exp (- l))))
(if (<= (- (exp l) t_1) (- INFINITY))
(+ U (* t_0 (* J (- 27.0 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 ((exp(l) - t_1) <= -((double) INFINITY)) {
tmp = U + (t_0 * (J * (27.0 - t_1)));
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
}
return tmp;
}
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 ((Math.exp(l) - t_1) <= -Double.POSITIVE_INFINITY) {
tmp = U + (t_0 * (J * (27.0 - 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 (math.exp(l) - t_1) <= -math.inf: tmp = U + (t_0 * (J * (27.0 - 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 (Float64(exp(l) - t_1) <= Float64(-Inf)) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(27.0 - 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 ((exp(l) - t_1) <= -Inf) tmp = U + (t_0 * (J * (27.0 - 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[N[(N[Exp[l], $MachinePrecision] - t$95$1), $MachinePrecision], (-Infinity)], N[(U + N[(t$95$0 * N[(J * N[(27.0 - t$95$1), $MachinePrecision]), $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}\;e^{\ell} - t\_1 \leq -\infty:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(27 - t\_1\right)\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 (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0Initial program 100.0%
Applied egg-rr100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 85.9%
Taylor expanded in l around 0 95.3%
unpow295.3%
Applied egg-rr95.3%
Final simplification96.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.005) (+ U (* (+ 2.0 (* -0.25 (pow K 2.0))) (* l J))) (+ 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.005) {
tmp = U + ((2.0 + (-0.25 * pow(K, 2.0))) * (l * J));
} 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.005d0)) then
tmp = u + ((2.0d0 + ((-0.25d0) * (k ** 2.0d0))) * (l * j))
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.005) {
tmp = U + ((2.0 + (-0.25 * Math.pow(K, 2.0))) * (l * J));
} 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.005: tmp = U + ((2.0 + (-0.25 * math.pow(K, 2.0))) * (l * J)) 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.005) tmp = Float64(U + Float64(Float64(2.0 + Float64(-0.25 * (K ^ 2.0))) * Float64(l * J))); 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.005) tmp = U + ((2.0 + (-0.25 * (K ^ 2.0))) * (l * J)); 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.005], N[(U + N[(N[(2.0 + N[(-0.25 * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(l * J), $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.005:\\
\;\;\;\;U + \left(2 + -0.25 \cdot {K}^{2}\right) \cdot \left(\ell \cdot J\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.0050000000000000001Initial program 88.3%
Taylor expanded in l around 0 51.5%
*-commutative51.5%
associate-*l*51.5%
Simplified51.5%
Taylor expanded in J around 0 51.4%
associate-*r*51.4%
*-commutative51.4%
Simplified51.4%
Taylor expanded in K around 0 50.8%
+-commutative50.8%
*-commutative50.8%
associate-*r*49.1%
associate-*l*49.1%
*-commutative49.1%
*-commutative49.1%
associate-*l*49.1%
distribute-lft-out57.8%
*-commutative57.8%
Simplified57.8%
if -0.0050000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.4%
Taylor expanded in l around 0 89.6%
unpow289.6%
Applied egg-rr89.6%
Taylor expanded in K around 0 86.2%
Final simplification79.8%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.75e+81) (not (<= l -0.0265))) (+ U (* (cos (/ K 2.0)) (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))) (+ (* (- (exp l) (exp (- l))) J) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.75e+81) || !(l <= -0.0265)) {
tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
} else {
tmp = ((exp(l) - exp(-l)) * J) + 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 <= (-2.75d+81)) .or. (.not. (l <= (-0.0265d0)))) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
else
tmp = ((exp(l) - exp(-l)) * j) + u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.75e+81) || !(l <= -0.0265)) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
} else {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.75e+81) or not (l <= -0.0265): tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))) else: tmp = ((math.exp(l) - math.exp(-l)) * J) + U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.75e+81) || !(l <= -0.0265)) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l))))))); else tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -2.75e+81) || ~((l <= -0.0265))) tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))); else tmp = ((exp(l) - exp(-l)) * J) + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.75e+81], N[Not[LessEqual[l, -0.0265]], $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], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.75 \cdot 10^{+81} \lor \neg \left(\ell \leq -0.0265\right):\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\end{array}
\end{array}
if l < -2.7500000000000002e81 or -0.0264999999999999993 < l Initial program 88.2%
Taylor expanded in l around 0 95.5%
unpow295.5%
Applied egg-rr95.5%
if -2.7500000000000002e81 < l < -0.0264999999999999993Initial program 99.9%
Taylor expanded in K around 0 68.1%
Final simplification93.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.005)
(+ U (* t_0 (* J (* l 2.0))))
(+ U (* 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 tmp;
if (t_0 <= -0.005) {
tmp = U + (t_0 * (J * (l * 2.0)));
} 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) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= (-0.005d0)) then
tmp = u + (t_0 * (j * (l * 2.0d0)))
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 t_0 = Math.cos((K / 2.0));
double tmp;
if (t_0 <= -0.005) {
tmp = U + (t_0 * (J * (l * 2.0)));
} else {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if t_0 <= -0.005: tmp = U + (t_0 * (J * (l * 2.0))) else: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (t_0 <= -0.005) tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * 2.0)))); 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) t_0 = cos((K / 2.0)); tmp = 0.0; if (t_0 <= -0.005) tmp = U + (t_0 * (J * (l * 2.0))); else tmp = U + (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]}, If[LessEqual[t$95$0, -0.005], N[(U + N[(t$95$0 * N[(J * N[(l * 2.0), $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}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.005:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot 2\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.0050000000000000001Initial program 88.3%
Taylor expanded in l around 0 51.5%
*-commutative51.5%
associate-*l*51.5%
Simplified51.5%
if -0.0050000000000000001 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 89.4%
Taylor expanded in l around 0 89.6%
unpow289.6%
Applied egg-rr89.6%
Taylor expanded in K around 0 86.2%
Final simplification78.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))
(if (<= l -2.35e+89)
t_0
(if (<= l -940.0)
(pow U -3.0)
(if (<= l 240000000.0)
(+ U (* l (* (cos (* K 0.5)) (* J 2.0))))
t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
double tmp;
if (l <= -2.35e+89) {
tmp = t_0;
} else if (l <= -940.0) {
tmp = pow(U, -3.0);
} else if (l <= 240000000.0) {
tmp = U + (l * (cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l)))))
if (l <= (-2.35d+89)) then
tmp = t_0
else if (l <= (-940.0d0)) then
tmp = u ** (-3.0d0)
else if (l <= 240000000.0d0) then
tmp = u + (l * (cos((k * 0.5d0)) * (j * 2.0d0)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
double tmp;
if (l <= -2.35e+89) {
tmp = t_0;
} else if (l <= -940.0) {
tmp = Math.pow(U, -3.0);
} else if (l <= 240000000.0) {
tmp = U + (l * (Math.cos((K * 0.5)) * (J * 2.0)));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))) tmp = 0 if l <= -2.35e+89: tmp = t_0 elif l <= -940.0: tmp = math.pow(U, -3.0) elif l <= 240000000.0: tmp = U + (l * (math.cos((K * 0.5)) * (J * 2.0))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))) tmp = 0.0 if (l <= -2.35e+89) tmp = t_0; elseif (l <= -940.0) tmp = U ^ -3.0; elseif (l <= 240000000.0) tmp = Float64(U + Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(J * 2.0)))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))); tmp = 0.0; if (l <= -2.35e+89) tmp = t_0; elseif (l <= -940.0) tmp = U ^ -3.0; elseif (l <= 240000000.0) tmp = U + (l * (cos((K * 0.5)) * (J * 2.0))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.35e+89], t$95$0, If[LessEqual[l, -940.0], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 240000000.0], N[(U + N[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\mathbf{if}\;\ell \leq -2.35 \cdot 10^{+89}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -940:\\
\;\;\;\;{U}^{-3}\\
\mathbf{elif}\;\ell \leq 240000000:\\
\;\;\;\;U + \ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -2.35000000000000011e89 or 2.4e8 < l Initial program 100.0%
Taylor expanded in l around 0 90.1%
unpow290.1%
Applied egg-rr90.1%
Taylor expanded in K around 0 66.1%
if -2.35000000000000011e89 < l < -940Initial program 100.0%
Applied egg-rr35.8%
if -940 < l < 2.4e8Initial program 79.8%
Taylor expanded in l around 0 98.7%
*-commutative98.7%
*-commutative98.7%
associate-*l*98.7%
*-commutative98.7%
associate-*r*98.7%
*-commutative98.7%
associate-*l*98.7%
Simplified98.7%
Final simplification80.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))
(if (<= l -3.1e+89)
t_0
(if (<= l -1200.0)
(pow U -3.0)
(if (<= l 950000000.0)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
t_0)))))
double code(double J, double l, double K, double U) {
double t_0 = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
double tmp;
if (l <= -3.1e+89) {
tmp = t_0;
} else if (l <= -1200.0) {
tmp = pow(U, -3.0);
} else if (l <= 950000000.0) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l)))))
if (l <= (-3.1d+89)) then
tmp = t_0
else if (l <= (-1200.0d0)) then
tmp = u ** (-3.0d0)
else if (l <= 950000000.0d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
double tmp;
if (l <= -3.1e+89) {
tmp = t_0;
} else if (l <= -1200.0) {
tmp = Math.pow(U, -3.0);
} else if (l <= 950000000.0) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))) tmp = 0 if l <= -3.1e+89: tmp = t_0 elif l <= -1200.0: tmp = math.pow(U, -3.0) elif l <= 950000000.0: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))) tmp = 0.0 if (l <= -3.1e+89) tmp = t_0; elseif (l <= -1200.0) tmp = U ^ -3.0; elseif (l <= 950000000.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))); tmp = 0.0; if (l <= -3.1e+89) tmp = t_0; elseif (l <= -1200.0) tmp = U ^ -3.0; elseif (l <= 950000000.0) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.1e+89], t$95$0, If[LessEqual[l, -1200.0], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 950000000.0], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\mathbf{if}\;\ell \leq -3.1 \cdot 10^{+89}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -1200:\\
\;\;\;\;{U}^{-3}\\
\mathbf{elif}\;\ell \leq 950000000:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -3.1e89 or 9.5e8 < l Initial program 100.0%
Taylor expanded in l around 0 90.1%
unpow290.1%
Applied egg-rr90.1%
Taylor expanded in K around 0 66.1%
if -3.1e89 < l < -1200Initial program 100.0%
Applied egg-rr35.8%
if -1200 < l < 9.5e8Initial program 79.8%
Taylor expanded in l around 0 98.7%
Final simplification80.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 89.2%
Taylor expanded in l around 0 88.5%
unpow288.5%
Applied egg-rr88.5%
Final simplification88.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -8.5e+79) (not (<= l 850.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -8.5e+79) || !(l <= 850.0)) {
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 <= (-8.5d+79)) .or. (.not. (l <= 850.0d0))) 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 <= -8.5e+79) || !(l <= 850.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -8.5e+79) or not (l <= 850.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -8.5e+79) || !(l <= 850.0)) tmp = Float64(U * U); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -8.5e+79) || ~((l <= 850.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -8.5e+79], N[Not[LessEqual[l, 850.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -8.5 \cdot 10^{+79} \lor \neg \left(\ell \leq 850\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -8.4999999999999998e79 or 850 < l Initial program 100.0%
Applied egg-rr16.7%
if -8.4999999999999998e79 < l < 850Initial program 82.2%
Taylor expanded in J around 0 68.2%
Final simplification48.1%
(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 89.2%
Taylor expanded in l around 0 88.5%
unpow288.5%
Applied egg-rr88.5%
Taylor expanded in K around 0 73.3%
Final simplification73.3%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* l J))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (l * 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 + (2.0d0 * (l * j))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (l * J));
}
def code(J, l, K, U): return U + (2.0 * (l * J))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(l * J))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (l * J)); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(\ell \cdot J\right)
\end{array}
Initial program 89.2%
Taylor expanded in l around 0 64.7%
*-commutative64.7%
associate-*l*64.7%
Simplified64.7%
Taylor expanded in K around 0 57.0%
Final simplification57.0%
(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 89.2%
Taylor expanded in J around 0 42.4%
(FPCore (J l K U) :precision binary64 16.0)
double code(double J, double l, double K, double U) {
return 16.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 = 16.0d0
end function
public static double code(double J, double l, double K, double U) {
return 16.0;
}
def code(J, l, K, U): return 16.0
function code(J, l, K, U) return 16.0 end
function tmp = code(J, l, K, U) tmp = 16.0; end
code[J_, l_, K_, U_] := 16.0
\begin{array}{l}
\\
16
\end{array}
Initial program 89.2%
Applied egg-rr28.6%
fma-undefine28.6%
+-commutative28.6%
metadata-eval28.6%
Simplified28.6%
Taylor expanded in U around 0 2.8%
(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 89.2%
Applied egg-rr2.3%
Taylor expanded in U around 0 2.6%
herbie shell --seed 2024191
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))