
(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 12 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 (cos (/ K 2.0))) (t_1 (exp (- l))) (t_2 (- (exp l) t_1)))
(if (<= t_2 (- INFINITY))
(+ (* (* J (- 27.0 t_1)) t_0) U)
(if (<= t_2 5e-8)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(+ U (* t_0 (* t_2 J)))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(-l);
double t_2 = exp(l) - t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if (t_2 <= 5e-8) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U + (t_0 * (t_2 * J));
}
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 t_2 = Math.exp(l) - t_1;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = ((J * (27.0 - t_1)) * t_0) + U;
} else if (t_2 <= 5e-8) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U + (t_0 * (t_2 * J));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(-l) t_2 = math.exp(l) - t_1 tmp = 0 if t_2 <= -math.inf: tmp = ((J * (27.0 - t_1)) * t_0) + U elif t_2 <= 5e-8: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U + (t_0 * (t_2 * J)) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = exp(Float64(-l)) t_2 = Float64(exp(l) - t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(Float64(J * Float64(27.0 - t_1)) * t_0) + U); elseif (t_2 <= 5e-8) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(t_0 * Float64(t_2 * J))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(-l); t_2 = exp(l) - t_1; tmp = 0.0; if (t_2 <= -Inf) tmp = ((J * (27.0 - t_1)) * t_0) + U; elseif (t_2 <= 5e-8) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U + (t_0 * (t_2 * J)); 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]}, Block[{t$95$2 = N[(N[Exp[l], $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(N[(J * N[(27.0 - t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[t$95$2, 5e-8], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(t$95$0 * N[(t$95$2 * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{-\ell}\\
t_2 := e^{\ell} - t\_1\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\left(J \cdot \left(27 - t\_1\right)\right) \cdot t\_0 + U\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(t\_2 \cdot J\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))) < 4.9999999999999998e-8Initial program 69.4%
Taylor expanded in l around 0 99.9%
if 4.9999999999999998e-8 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= l -4.0)
(+ (* (* J (- 27.0 (exp (- l)))) t_0) U)
(+ 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 tmp;
if (l <= -4.0) {
tmp = ((J * (27.0 - exp(-l))) * t_0) + U;
} 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) :: tmp
t_0 = cos((k / 2.0d0))
if (l <= (-4.0d0)) then
tmp = ((j * (27.0d0 - exp(-l))) * t_0) + u
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 tmp;
if (l <= -4.0) {
tmp = ((J * (27.0 - Math.exp(-l))) * t_0) + U;
} 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)) tmp = 0 if l <= -4.0: tmp = ((J * (27.0 - math.exp(-l))) * t_0) + U 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)) tmp = 0.0 if (l <= -4.0) tmp = Float64(Float64(Float64(J * Float64(27.0 - exp(Float64(-l)))) * t_0) + U); 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)); tmp = 0.0; if (l <= -4.0) tmp = ((J * (27.0 - exp(-l))) * t_0) + U; 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]}, If[LessEqual[l, -4.0], N[(N[(N[(J * N[(27.0 - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $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)\\
\mathbf{if}\;\ell \leq -4:\\
\;\;\;\;\left(J \cdot \left(27 - e^{-\ell}\right)\right) \cdot t\_0 + U\\
\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 < -4Initial program 100.0%
Applied egg-rr100.0%
if -4 < l Initial program 80.0%
Taylor expanded in l around 0 93.9%
unpow293.9%
Applied egg-rr93.9%
Final simplification95.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l))))))))
(if (<= l -1.25e+127)
t_0
(if (<= l -660.0)
(+ U (+ (* -0.25 (* J (* l (* K K)))) (* 2.0 (* l J))))
(if (<= l 1.4e+94) (+ 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 <= -1.25e+127) {
tmp = t_0;
} else if (l <= -660.0) {
tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J)));
} else if (l <= 1.4e+94) {
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 <= (-1.25d+127)) then
tmp = t_0
else if (l <= (-660.0d0)) then
tmp = u + (((-0.25d0) * (j * (l * (k * k)))) + (2.0d0 * (l * j)))
else if (l <= 1.4d+94) 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 <= -1.25e+127) {
tmp = t_0;
} else if (l <= -660.0) {
tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J)));
} else if (l <= 1.4e+94) {
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 <= -1.25e+127: tmp = t_0 elif l <= -660.0: tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J))) elif l <= 1.4e+94: 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 <= -1.25e+127) tmp = t_0; elseif (l <= -660.0) tmp = Float64(U + Float64(Float64(-0.25 * Float64(J * Float64(l * Float64(K * K)))) + Float64(2.0 * Float64(l * J)))); elseif (l <= 1.4e+94) 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 <= -1.25e+127) tmp = t_0; elseif (l <= -660.0) tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J))); elseif (l <= 1.4e+94) 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, -1.25e+127], t$95$0, If[LessEqual[l, -660.0], N[(U + N[(N[(-0.25 * N[(J * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.4e+94], 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 -1.25 \cdot 10^{+127}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -660:\\
\;\;\;\;U + \left(-0.25 \cdot \left(J \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+94}:\\
\;\;\;\;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 < -1.2500000000000001e127 or 1.39999999999999999e94 < l Initial program 100.0%
Taylor expanded in l around 0 98.2%
unpow298.2%
Applied egg-rr98.2%
Taylor expanded in K around 0 74.9%
if -1.2500000000000001e127 < l < -660Initial program 100.0%
Taylor expanded in l around 0 17.7%
*-commutative17.7%
*-commutative17.7%
associate-*l*17.7%
*-commutative17.7%
associate-*r*17.7%
*-commutative17.7%
associate-*l*17.7%
Simplified17.7%
Taylor expanded in K around 0 65.7%
unpow265.7%
Applied egg-rr65.7%
if -660 < l < 1.39999999999999999e94Initial program 72.7%
Taylor expanded in l around 0 93.0%
Final simplification84.2%
(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.2%
Taylor expanded in l around 0 91.4%
unpow291.4%
Applied egg-rr91.4%
Final simplification91.4%
(FPCore (J l K U) :precision binary64 (if (<= K 1.5e+231) (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))) (+ U (* l (* (pow K 2.0) (* J -0.25))))))
double code(double J, double l, double K, double U) {
double tmp;
if (K <= 1.5e+231) {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
} else {
tmp = U + (l * (pow(K, 2.0) * (J * -0.25)));
}
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 <= 1.5d+231) then
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l)))))
else
tmp = u + (l * ((k ** 2.0d0) * (j * (-0.25d0))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (K <= 1.5e+231) {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
} else {
tmp = U + (l * (Math.pow(K, 2.0) * (J * -0.25)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if K <= 1.5e+231: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))) else: tmp = U + (l * (math.pow(K, 2.0) * (J * -0.25))) return tmp
function code(J, l, K, U) tmp = 0.0 if (K <= 1.5e+231) tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))); else tmp = Float64(U + Float64(l * Float64((K ^ 2.0) * Float64(J * -0.25)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (K <= 1.5e+231) tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))); else tmp = U + (l * ((K ^ 2.0) * (J * -0.25))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[K, 1.5e+231], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(N[Power[K, 2.0], $MachinePrecision] * N[(J * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 1.5 \cdot 10^{+231}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left({K}^{2} \cdot \left(J \cdot -0.25\right)\right)\\
\end{array}
\end{array}
if K < 1.5000000000000001e231Initial program 84.7%
Taylor expanded in l around 0 91.7%
unpow291.7%
Applied egg-rr91.7%
Taylor expanded in K around 0 76.0%
if 1.5000000000000001e231 < K Initial program 93.2%
Taylor expanded in l around 0 52.7%
*-commutative52.7%
*-commutative52.7%
associate-*l*52.6%
*-commutative52.6%
associate-*r*52.6%
*-commutative52.6%
associate-*l*52.6%
Simplified52.6%
Taylor expanded in K around 0 43.8%
Taylor expanded in K around inf 50.9%
associate-*r*50.9%
associate-*r*50.9%
*-commutative50.9%
*-commutative50.9%
*-commutative50.9%
associate-*l*50.9%
Simplified50.9%
Final simplification74.6%
(FPCore (J l K U) :precision binary64 (if (<= K 5.6e+231) (+ U (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))) (+ U (+ (* -0.25 (* J (* l (* K K)))) (* 2.0 (* l J))))))
double code(double J, double l, double K, double U) {
double tmp;
if (K <= 5.6e+231) {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
} else {
tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (k <= 5.6d+231) then
tmp = u + (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l)))))
else
tmp = u + (((-0.25d0) * (j * (l * (k * k)))) + (2.0d0 * (l * j)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (K <= 5.6e+231) {
tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l)))));
} else {
tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if K <= 5.6e+231: tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))) else: tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J))) return tmp
function code(J, l, K, U) tmp = 0.0 if (K <= 5.6e+231) tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l)))))); else tmp = Float64(U + Float64(Float64(-0.25 * Float64(J * Float64(l * Float64(K * K)))) + Float64(2.0 * Float64(l * J)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (K <= 5.6e+231) tmp = U + (J * (l * (2.0 + (0.3333333333333333 * (l * l))))); else tmp = U + ((-0.25 * (J * (l * (K * K)))) + (2.0 * (l * J))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[K, 5.6e+231], N[(U + N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[(l * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(-0.25 * N[(J * N[(l * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 5.6 \cdot 10^{+231}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot \left(\ell \cdot \ell\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(-0.25 \cdot \left(J \cdot \left(\ell \cdot \left(K \cdot K\right)\right)\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\end{array}
\end{array}
if K < 5.6e231Initial program 84.7%
Taylor expanded in l around 0 91.7%
unpow291.7%
Applied egg-rr91.7%
Taylor expanded in K around 0 76.0%
if 5.6e231 < K Initial program 93.2%
Taylor expanded in l around 0 52.7%
*-commutative52.7%
*-commutative52.7%
associate-*l*52.6%
*-commutative52.6%
associate-*r*52.6%
*-commutative52.6%
associate-*l*52.6%
Simplified52.6%
Taylor expanded in K around 0 43.8%
unpow243.8%
Applied egg-rr43.8%
Final simplification74.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -7.4e+77) (not (<= l 28000000000.0))) (* U (- U -4.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7.4e+77) || !(l <= 28000000000.0)) {
tmp = U * (U - -4.0);
} 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 <= (-7.4d+77)) .or. (.not. (l <= 28000000000.0d0))) then
tmp = u * (u - (-4.0d0))
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 <= -7.4e+77) || !(l <= 28000000000.0)) {
tmp = U * (U - -4.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -7.4e+77) or not (l <= 28000000000.0): tmp = U * (U - -4.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -7.4e+77) || !(l <= 28000000000.0)) tmp = Float64(U * Float64(U - -4.0)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -7.4e+77) || ~((l <= 28000000000.0))) tmp = U * (U - -4.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7.4e+77], N[Not[LessEqual[l, 28000000000.0]], $MachinePrecision]], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.4 \cdot 10^{+77} \lor \neg \left(\ell \leq 28000000000\right):\\
\;\;\;\;U \cdot \left(U - -4\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -7.3999999999999999e77 or 2.8e10 < l Initial program 100.0%
Applied egg-rr16.9%
if -7.3999999999999999e77 < l < 2.8e10Initial program 72.5%
Taylor expanded in J around 0 62.6%
Final simplification41.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -7.2e+77) (not (<= l 1050000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7.2e+77) || !(l <= 1050000.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 <= (-7.2d+77)) .or. (.not. (l <= 1050000.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 <= -7.2e+77) || !(l <= 1050000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -7.2e+77) or not (l <= 1050000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -7.2e+77) || !(l <= 1050000.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 <= -7.2e+77) || ~((l <= 1050000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7.2e+77], N[Not[LessEqual[l, 1050000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{+77} \lor \neg \left(\ell \leq 1050000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -7.1999999999999996e77 or 1.05e6 < l Initial program 100.0%
Applied egg-rr16.7%
if -7.1999999999999996e77 < l < 1.05e6Initial program 72.3%
Taylor expanded in J around 0 63.0%
Final simplification41.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 85.2%
Taylor expanded in l around 0 91.4%
unpow291.4%
Applied egg-rr91.4%
Taylor expanded in K around 0 74.2%
Final simplification74.2%
(FPCore (J l K U) :precision binary64 (+ U (* l (* J 2.0))))
double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (l * (j * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (l * (J * 2.0));
}
def code(J, l, K, U): return U + (l * (J * 2.0))
function code(J, l, K, U) return Float64(U + Float64(l * Float64(J * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (l * (J * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + \ell \cdot \left(J \cdot 2\right)
\end{array}
Initial program 85.2%
Taylor expanded in l around 0 66.5%
*-commutative66.5%
*-commutative66.5%
associate-*l*66.5%
*-commutative66.5%
associate-*r*66.5%
*-commutative66.5%
associate-*l*66.5%
Simplified66.5%
Taylor expanded in K around 0 56.1%
Final simplification56.1%
(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.2%
Taylor expanded in J around 0 34.9%
(FPCore (J l K U) :precision binary64 0.25)
double code(double J, double l, double K, double U) {
return 0.25;
}
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 = 0.25d0
end function
public static double code(double J, double l, double K, double U) {
return 0.25;
}
def code(J, l, K, U): return 0.25
function code(J, l, K, U) return 0.25 end
function tmp = code(J, l, K, U) tmp = 0.25; end
code[J_, l_, K_, U_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 85.2%
Applied egg-rr23.2%
Taylor expanded in U around 0 2.6%
herbie shell --seed 2024180
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))