
(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 17 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) (exp (- l)))))
(if (or (<= t_1 -50.0) (not (<= t_1 0.0)))
(+ (* (* t_1 J) t_0) U)
(+
U
(* t_0 (* l (+ (* 0.3333333333333333 (* J (pow l 2.0))) (* J 2.0))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -50.0) || !(t_1 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * pow(l, 2.0))) + (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) :: t_1
real(8) :: tmp
t_0 = cos((k / 2.0d0))
t_1 = exp(l) - exp(-l)
if ((t_1 <= (-50.0d0)) .or. (.not. (t_1 <= 0.0d0))) then
tmp = ((t_1 * j) * t_0) + u
else
tmp = u + (t_0 * (l * ((0.3333333333333333d0 * (j * (l ** 2.0d0))) + (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.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -50.0) || !(t_1 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * Math.pow(l, 2.0))) + (J * 2.0))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -50.0) or not (t_1 <= 0.0): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * math.pow(l, 2.0))) + (J * 2.0)))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= -50.0) || !(t_1 <= 0.0)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 2.0))) + Float64(J * 2.0))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -50.0) || ~((t_1 <= 0.0))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (l * ((0.3333333333333333 * (J * (l ^ 2.0))) + (J * 2.0)))); 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[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -50.0], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(l * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_1 \leq -50 \lor \neg \left(t\_1 \leq 0\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + J \cdot 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -50 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -50 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 72.8%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(if (or (<= l -3.5e+115)
(not (or (<= l -0.08) (and (not (<= l 4.3e-10)) (<= l 4.5e+98)))))
(+ 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 <= -3.5e+115) || !((l <= -0.08) || (!(l <= 4.3e-10) && (l <= 4.5e+98)))) {
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 <= (-3.5d+115)) .or. (.not. (l <= (-0.08d0)) .or. (.not. (l <= 4.3d-10)) .and. (l <= 4.5d+98))) 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 <= -3.5e+115) || !((l <= -0.08) || (!(l <= 4.3e-10) && (l <= 4.5e+98)))) {
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 <= -3.5e+115) or not ((l <= -0.08) or (not (l <= 4.3e-10) and (l <= 4.5e+98))): 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 <= -3.5e+115) || !((l <= -0.08) || (!(l <= 4.3e-10) && (l <= 4.5e+98)))) 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 <= -3.5e+115) || ~(((l <= -0.08) || (~((l <= 4.3e-10)) && (l <= 4.5e+98))))) 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, -3.5e+115], N[Not[Or[LessEqual[l, -0.08], And[N[Not[LessEqual[l, 4.3e-10]], $MachinePrecision], LessEqual[l, 4.5e+98]]]], $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 -3.5 \cdot 10^{+115} \lor \neg \left(\ell \leq -0.08 \lor \neg \left(\ell \leq 4.3 \cdot 10^{-10}\right) \land \ell \leq 4.5 \cdot 10^{+98}\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 < -3.50000000000000005e115 or -0.0800000000000000017 < l < 4.30000000000000014e-10 or 4.5000000000000002e98 < l Initial program 82.8%
Taylor expanded in l around 0 99.5%
unpow299.5%
Applied egg-rr99.5%
if -3.50000000000000005e115 < l < -0.0800000000000000017 or 4.30000000000000014e-10 < l < 4.5000000000000002e98Initial program 100.0%
Taylor expanded in K around 0 89.1%
Final simplification97.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (exp (- l))) (t_1 (cos (/ K 2.0))))
(if (<= l -4.1)
(+ U (* t_1 (* J (- 27.0 t_0))))
(if (<= l 4.3e-10)
(+
U
(* t_1 (* l (+ (* 0.3333333333333333 (* J (pow l 2.0))) (* J 2.0)))))
(if (<= l 4.8e+98)
(+ (* (- (exp l) t_0) J) U)
(+ 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 <= -4.1) {
tmp = U + (t_1 * (J * (27.0 - t_0)));
} else if (l <= 4.3e-10) {
tmp = U + (t_1 * (l * ((0.3333333333333333 * (J * pow(l, 2.0))) + (J * 2.0))));
} else if (l <= 4.8e+98) {
tmp = ((exp(l) - t_0) * J) + U;
} 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 <= (-4.1d0)) then
tmp = u + (t_1 * (j * (27.0d0 - t_0)))
else if (l <= 4.3d-10) then
tmp = u + (t_1 * (l * ((0.3333333333333333d0 * (j * (l ** 2.0d0))) + (j * 2.0d0))))
else if (l <= 4.8d+98) then
tmp = ((exp(l) - t_0) * j) + u
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 <= -4.1) {
tmp = U + (t_1 * (J * (27.0 - t_0)));
} else if (l <= 4.3e-10) {
tmp = U + (t_1 * (l * ((0.3333333333333333 * (J * Math.pow(l, 2.0))) + (J * 2.0))));
} else if (l <= 4.8e+98) {
tmp = ((Math.exp(l) - t_0) * J) + U;
} 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 <= -4.1: tmp = U + (t_1 * (J * (27.0 - t_0))) elif l <= 4.3e-10: tmp = U + (t_1 * (l * ((0.3333333333333333 * (J * math.pow(l, 2.0))) + (J * 2.0)))) elif l <= 4.8e+98: tmp = ((math.exp(l) - t_0) * J) + U 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 <= -4.1) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(27.0 - t_0)))); elseif (l <= 4.3e-10) tmp = Float64(U + Float64(t_1 * Float64(l * Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 2.0))) + Float64(J * 2.0))))); elseif (l <= 4.8e+98) tmp = Float64(Float64(Float64(exp(l) - t_0) * J) + U); 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 <= -4.1) tmp = U + (t_1 * (J * (27.0 - t_0))); elseif (l <= 4.3e-10) tmp = U + (t_1 * (l * ((0.3333333333333333 * (J * (l ^ 2.0))) + (J * 2.0)))); elseif (l <= 4.8e+98) tmp = ((exp(l) - t_0) * J) + U; 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, -4.1], N[(U + N[(t$95$1 * N[(J * N[(27.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.3e-10], N[(U + N[(t$95$1 * N[(l * N[(N[(0.3333333333333333 * N[(J * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.8e+98], N[(N[(N[(N[Exp[l], $MachinePrecision] - t$95$0), $MachinePrecision] * J), $MachinePrecision] + U), $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 -4.1:\\
\;\;\;\;U + t\_1 \cdot \left(J \cdot \left(27 - t\_0\right)\right)\\
\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-10}:\\
\;\;\;\;U + t\_1 \cdot \left(\ell \cdot \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{2}\right) + J \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 4.8 \cdot 10^{+98}:\\
\;\;\;\;\left(e^{\ell} - t\_0\right) \cdot J + U\\
\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 < -4.0999999999999996Initial program 100.0%
Applied egg-rr100.0%
if -4.0999999999999996 < l < 4.30000000000000014e-10Initial program 73.0%
Taylor expanded in l around 0 99.3%
if 4.30000000000000014e-10 < l < 4.7999999999999997e98Initial program 100.0%
Taylor expanded in K around 0 91.3%
if 4.7999999999999997e98 < l Initial program 100.0%
Taylor expanded in l around 0 96.7%
unpow296.7%
Applied egg-rr96.7%
Final simplification98.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (exp (- l))) (t_1 (cos (/ K 2.0))))
(if (<= l -4.1)
(+ U (* t_1 (* J (- 27.0 t_0))))
(if (<= l 4.3e-10)
(+ U (* t_1 (* J (+ (* l 2.0) (* 0.3333333333333333 (pow l 3.0))))))
(if (<= l 5.1e+98)
(+ (* (- (exp l) t_0) J) U)
(+ 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 <= -4.1) {
tmp = U + (t_1 * (J * (27.0 - t_0)));
} else if (l <= 4.3e-10) {
tmp = U + (t_1 * (J * ((l * 2.0) + (0.3333333333333333 * pow(l, 3.0)))));
} else if (l <= 5.1e+98) {
tmp = ((exp(l) - t_0) * J) + U;
} 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 <= (-4.1d0)) then
tmp = u + (t_1 * (j * (27.0d0 - t_0)))
else if (l <= 4.3d-10) then
tmp = u + (t_1 * (j * ((l * 2.0d0) + (0.3333333333333333d0 * (l ** 3.0d0)))))
else if (l <= 5.1d+98) then
tmp = ((exp(l) - t_0) * j) + u
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 <= -4.1) {
tmp = U + (t_1 * (J * (27.0 - t_0)));
} else if (l <= 4.3e-10) {
tmp = U + (t_1 * (J * ((l * 2.0) + (0.3333333333333333 * Math.pow(l, 3.0)))));
} else if (l <= 5.1e+98) {
tmp = ((Math.exp(l) - t_0) * J) + U;
} 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 <= -4.1: tmp = U + (t_1 * (J * (27.0 - t_0))) elif l <= 4.3e-10: tmp = U + (t_1 * (J * ((l * 2.0) + (0.3333333333333333 * math.pow(l, 3.0))))) elif l <= 5.1e+98: tmp = ((math.exp(l) - t_0) * J) + U 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 <= -4.1) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(27.0 - t_0)))); elseif (l <= 4.3e-10) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(Float64(l * 2.0) + Float64(0.3333333333333333 * (l ^ 3.0)))))); elseif (l <= 5.1e+98) tmp = Float64(Float64(Float64(exp(l) - t_0) * J) + U); 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 <= -4.1) tmp = U + (t_1 * (J * (27.0 - t_0))); elseif (l <= 4.3e-10) tmp = U + (t_1 * (J * ((l * 2.0) + (0.3333333333333333 * (l ^ 3.0))))); elseif (l <= 5.1e+98) tmp = ((exp(l) - t_0) * J) + U; 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, -4.1], N[(U + N[(t$95$1 * N[(J * N[(27.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.3e-10], N[(U + N[(t$95$1 * N[(J * N[(N[(l * 2.0), $MachinePrecision] + N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.1e+98], N[(N[(N[(N[Exp[l], $MachinePrecision] - t$95$0), $MachinePrecision] * J), $MachinePrecision] + U), $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 -4.1:\\
\;\;\;\;U + t\_1 \cdot \left(J \cdot \left(27 - t\_0\right)\right)\\
\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-10}:\\
\;\;\;\;U + t\_1 \cdot \left(J \cdot \left(\ell \cdot 2 + 0.3333333333333333 \cdot {\ell}^{3}\right)\right)\\
\mathbf{elif}\;\ell \leq 5.1 \cdot 10^{+98}:\\
\;\;\;\;\left(e^{\ell} - t\_0\right) \cdot J + U\\
\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 < -4.0999999999999996Initial program 100.0%
Applied egg-rr100.0%
if -4.0999999999999996 < l < 4.30000000000000014e-10Initial program 73.0%
Taylor expanded in l around 0 99.3%
distribute-rgt-in99.3%
*-commutative99.3%
associate-*l*99.3%
unpow299.3%
pow399.3%
Applied egg-rr99.3%
if 4.30000000000000014e-10 < l < 5.09999999999999988e98Initial program 100.0%
Taylor expanded in K around 0 91.3%
if 5.09999999999999988e98 < l Initial program 100.0%
Taylor expanded in l around 0 96.7%
unpow296.7%
Applied egg-rr96.7%
Final simplification98.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (exp (- l))) (t_1 (cos (/ K 2.0))))
(if (<= l -4.1)
(+ U (* t_1 (* J (- 27.0 t_0))))
(if (or (<= l 4.3e-10) (not (<= l 5.1e+98)))
(+ U (* t_1 (* J (* l (+ 2.0 (* 0.3333333333333333 (* l l)))))))
(+ (* (- (exp l) t_0) J) U)))))
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 <= -4.1) {
tmp = U + (t_1 * (J * (27.0 - t_0)));
} else if ((l <= 4.3e-10) || !(l <= 5.1e+98)) {
tmp = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
} else {
tmp = ((exp(l) - t_0) * 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(-l)
t_1 = cos((k / 2.0d0))
if (l <= (-4.1d0)) then
tmp = u + (t_1 * (j * (27.0d0 - t_0)))
else if ((l <= 4.3d-10) .or. (.not. (l <= 5.1d+98))) then
tmp = u + (t_1 * (j * (l * (2.0d0 + (0.3333333333333333d0 * (l * l))))))
else
tmp = ((exp(l) - t_0) * j) + u
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 <= -4.1) {
tmp = U + (t_1 * (J * (27.0 - t_0)));
} else if ((l <= 4.3e-10) || !(l <= 5.1e+98)) {
tmp = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l))))));
} else {
tmp = ((Math.exp(l) - t_0) * J) + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(-l) t_1 = math.cos((K / 2.0)) tmp = 0 if l <= -4.1: tmp = U + (t_1 * (J * (27.0 - t_0))) elif (l <= 4.3e-10) or not (l <= 5.1e+98): tmp = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))) else: tmp = ((math.exp(l) - t_0) * J) + U 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 <= -4.1) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(27.0 - t_0)))); elseif ((l <= 4.3e-10) || !(l <= 5.1e+98)) tmp = Float64(U + Float64(t_1 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * Float64(l * l))))))); else tmp = Float64(Float64(Float64(exp(l) - t_0) * J) + U); 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 <= -4.1) tmp = U + (t_1 * (J * (27.0 - t_0))); elseif ((l <= 4.3e-10) || ~((l <= 5.1e+98))) tmp = U + (t_1 * (J * (l * (2.0 + (0.3333333333333333 * (l * l)))))); else tmp = ((exp(l) - t_0) * J) + U; 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, -4.1], N[(U + N[(t$95$1 * N[(J * N[(27.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[l, 4.3e-10], N[Not[LessEqual[l, 5.1e+98]], $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], N[(N[(N[(N[Exp[l], $MachinePrecision] - t$95$0), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
t_1 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;\ell \leq -4.1:\\
\;\;\;\;U + t\_1 \cdot \left(J \cdot \left(27 - t\_0\right)\right)\\
\mathbf{elif}\;\ell \leq 4.3 \cdot 10^{-10} \lor \neg \left(\ell \leq 5.1 \cdot 10^{+98}\right):\\
\;\;\;\;U + t\_1 \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} - t\_0\right) \cdot J + U\\
\end{array}
\end{array}
if l < -4.0999999999999996Initial program 100.0%
Applied egg-rr100.0%
if -4.0999999999999996 < l < 4.30000000000000014e-10 or 5.09999999999999988e98 < l Initial program 77.8%
Taylor expanded in l around 0 98.8%
unpow298.8%
Applied egg-rr98.8%
if 4.30000000000000014e-10 < l < 5.09999999999999988e98Initial program 100.0%
Taylor expanded in K around 0 91.3%
Final simplification98.5%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.52) (* U (+ 1.0 (* (* J 2.0) (* (/ l U) (cos (* K 0.5)))))) (* 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.52) {
tmp = U * (1.0 + ((J * 2.0) * ((l / U) * cos((K * 0.5)))));
} 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.52d0) then
tmp = u * (1.0d0 + ((j * 2.0d0) * ((l / u) * cos((k * 0.5d0)))))
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.52) {
tmp = U * (1.0 + ((J * 2.0) * ((l / U) * Math.cos((K * 0.5)))));
} 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.52: tmp = U * (1.0 + ((J * 2.0) * ((l / U) * math.cos((K * 0.5))))) 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.52) tmp = Float64(U * Float64(1.0 + Float64(Float64(J * 2.0) * Float64(Float64(l / U) * cos(Float64(K * 0.5)))))); 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.52) tmp = U * (1.0 + ((J * 2.0) * ((l / U) * cos((K * 0.5))))); 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.52], N[(U * N[(1.0 + N[(N[(J * 2.0), $MachinePrecision] * N[(N[(l / U), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $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.52:\\
\;\;\;\;U \cdot \left(1 + \left(J \cdot 2\right) \cdot \left(\frac{\ell}{U} \cdot \cos \left(K \cdot 0.5\right)\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.52000000000000002Initial program 86.3%
Taylor expanded in l around 0 68.5%
*-commutative68.5%
associate-*l*68.5%
Simplified68.5%
Taylor expanded in U around inf 74.9%
clear-num74.9%
un-div-inv74.9%
Applied egg-rr74.9%
associate-/r/74.9%
associate-*l/74.9%
associate-*r*74.9%
associate-/l*80.1%
*-commutative80.1%
associate-/l*80.2%
*-commutative80.2%
Simplified80.2%
if 0.52000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.6%
Taylor expanded in l around 0 82.1%
Taylor expanded in K around 0 80.3%
Taylor expanded in U around inf 83.0%
Final simplification82.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.52) (* U (+ 1.0 (* (* J 2.0) (* (/ l U) (cos (* K 0.5)))))) (+ U (+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.52) {
tmp = U * (1.0 + ((J * 2.0) * ((l / U) * cos((K * 0.5)))));
} else {
tmp = U + ((0.3333333333333333 * (J * pow(l, 3.0))) + (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 (cos((k / 2.0d0)) <= 0.52d0) then
tmp = u * (1.0d0 + ((j * 2.0d0) * ((l / u) * cos((k * 0.5d0)))))
else
tmp = u + ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (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 (Math.cos((K / 2.0)) <= 0.52) {
tmp = U * (1.0 + ((J * 2.0) * ((l / U) * Math.cos((K * 0.5)))));
} else {
tmp = U + ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.52: tmp = U * (1.0 + ((J * 2.0) * ((l / U) * math.cos((K * 0.5))))) else: tmp = U + ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.52) tmp = Float64(U * Float64(1.0 + Float64(Float64(J * 2.0) * Float64(Float64(l / U) * cos(Float64(K * 0.5)))))); else tmp = Float64(U + Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.52) tmp = U * (1.0 + ((J * 2.0) * ((l / U) * cos((K * 0.5))))); else tmp = U + ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.52], N[(U * N[(1.0 + N[(N[(J * 2.0), $MachinePrecision] * N[(N[(l / U), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.52:\\
\;\;\;\;U \cdot \left(1 + \left(J \cdot 2\right) \cdot \left(\frac{\ell}{U} \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.52000000000000002Initial program 86.3%
Taylor expanded in l around 0 68.5%
*-commutative68.5%
associate-*l*68.5%
Simplified68.5%
Taylor expanded in U around inf 74.9%
clear-num74.9%
un-div-inv74.9%
Applied egg-rr74.9%
associate-/r/74.9%
associate-*l/74.9%
associate-*r*74.9%
associate-/l*80.1%
*-commutative80.1%
associate-/l*80.2%
*-commutative80.2%
Simplified80.2%
if 0.52000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.6%
Taylor expanded in l around 0 82.1%
distribute-lft-in82.1%
distribute-rgt-in82.1%
associate-*l*82.1%
*-commutative82.1%
associate-*l*82.1%
unpow282.1%
pow382.1%
Applied egg-rr82.1%
Taylor expanded in K around 0 80.3%
Final simplification80.2%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.52) (* U (+ 1.0 (* 2.0 (/ (* J (* l (cos (* K 0.5)))) U)))) (+ U (+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.52) {
tmp = U * (1.0 + (2.0 * ((J * (l * cos((K * 0.5)))) / U)));
} else {
tmp = U + ((0.3333333333333333 * (J * pow(l, 3.0))) + (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 (cos((k / 2.0d0)) <= 0.52d0) then
tmp = u * (1.0d0 + (2.0d0 * ((j * (l * cos((k * 0.5d0)))) / u)))
else
tmp = u + ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (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 (Math.cos((K / 2.0)) <= 0.52) {
tmp = U * (1.0 + (2.0 * ((J * (l * Math.cos((K * 0.5)))) / U)));
} else {
tmp = U + ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.52: tmp = U * (1.0 + (2.0 * ((J * (l * math.cos((K * 0.5)))) / U))) else: tmp = U + ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.52) tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(Float64(J * Float64(l * cos(Float64(K * 0.5)))) / U)))); else tmp = Float64(U + Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.52) tmp = U * (1.0 + (2.0 * ((J * (l * cos((K * 0.5)))) / U))); else tmp = U + ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.52], N[(U * N[(1.0 + N[(2.0 * N[(N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.52:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \frac{J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)}{U}\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.52000000000000002Initial program 86.3%
Taylor expanded in l around 0 68.5%
*-commutative68.5%
associate-*l*68.5%
Simplified68.5%
Taylor expanded in U around inf 74.9%
if 0.52000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.6%
Taylor expanded in l around 0 82.1%
distribute-lft-in82.1%
distribute-rgt-in82.1%
associate-*l*82.1%
*-commutative82.1%
associate-*l*82.1%
unpow282.1%
pow382.1%
Applied egg-rr82.1%
Taylor expanded in K around 0 80.3%
Final simplification78.4%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.52) (+ U (* J (* (* l 2.0) (cos (* K 0.5))))) (+ U (+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.52) {
tmp = U + (J * ((l * 2.0) * cos((K * 0.5))));
} else {
tmp = U + ((0.3333333333333333 * (J * pow(l, 3.0))) + (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 (cos((k / 2.0d0)) <= 0.52d0) then
tmp = u + (j * ((l * 2.0d0) * cos((k * 0.5d0))))
else
tmp = u + ((0.3333333333333333d0 * (j * (l ** 3.0d0))) + (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 (Math.cos((K / 2.0)) <= 0.52) {
tmp = U + (J * ((l * 2.0) * Math.cos((K * 0.5))));
} else {
tmp = U + ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.52: tmp = U + (J * ((l * 2.0) * math.cos((K * 0.5)))) else: tmp = U + ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.52) tmp = Float64(U + Float64(J * Float64(Float64(l * 2.0) * cos(Float64(K * 0.5))))); else tmp = Float64(U + Float64(Float64(0.3333333333333333 * Float64(J * (l ^ 3.0))) + Float64(2.0 * Float64(l * J)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.52) tmp = U + (J * ((l * 2.0) * cos((K * 0.5)))); else tmp = U + ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.52], N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.52:\\
\;\;\;\;U + J \cdot \left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.52000000000000002Initial program 86.3%
Taylor expanded in l around 0 68.5%
*-commutative68.5%
associate-*l*68.5%
*-commutative68.5%
associate-*l*68.5%
Simplified68.5%
if 0.52000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.6%
Taylor expanded in l around 0 82.1%
distribute-lft-in82.1%
distribute-rgt-in82.1%
associate-*l*82.1%
*-commutative82.1%
associate-*l*82.1%
unpow282.1%
pow382.1%
Applied egg-rr82.1%
Taylor expanded in K around 0 80.3%
Final simplification76.1%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.52) (+ U (* J (* (* l 2.0) (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.52) {
tmp = U + (J * ((l * 2.0) * 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.52d0) then
tmp = u + (j * ((l * 2.0d0) * 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.52) {
tmp = U + (J * ((l * 2.0) * 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.52: tmp = U + (J * ((l * 2.0) * 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.52) tmp = Float64(U + Float64(J * Float64(Float64(l * 2.0) * 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.52) tmp = U + (J * ((l * 2.0) * 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.52], N[(U + N[(J * N[(N[(l * 2.0), $MachinePrecision] * N[Cos[N[(K * 0.5), $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.52:\\
\;\;\;\;U + J \cdot \left(\left(\ell \cdot 2\right) \cdot \cos \left(K \cdot 0.5\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.52000000000000002Initial program 86.3%
Taylor expanded in l around 0 68.5%
*-commutative68.5%
associate-*l*68.5%
*-commutative68.5%
associate-*l*68.5%
Simplified68.5%
if 0.52000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 85.6%
Taylor expanded in l around 0 82.1%
Taylor expanded in K around 0 80.3%
unpow282.1%
Applied egg-rr80.3%
Final simplification76.1%
(FPCore (J l K U)
:precision binary64
(if (<= (/ K 2.0) 1e-155)
(* U (+ 1.0 (/ (* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0))))) U)))
(+
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) <= 1e-155) {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))) / U));
} 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) <= 1d-155) then
tmp = u * (1.0d0 + ((j * (l * (2.0d0 + (0.3333333333333333d0 * (l ** 2.0d0))))) / u))
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) <= 1e-155) {
tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))) / U));
} 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) <= 1e-155: tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0))))) / U)) 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) <= 1e-155) tmp = Float64(U * Float64(1.0 + Float64(Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))) / U))); 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) <= 1e-155) tmp = U * (1.0 + ((J * (l * (2.0 + (0.3333333333333333 * (l ^ 2.0))))) / U)); 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], 1e-155], 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], 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 10^{-155}:\\
\;\;\;\;U \cdot \left(1 + \frac{J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)}{U}\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)) < 1.00000000000000001e-155Initial program 84.9%
Taylor expanded in l around 0 85.3%
Taylor expanded in K around 0 69.9%
Taylor expanded in U around inf 73.0%
if 1.00000000000000001e-155 < (/.f64 K #s(literal 2 binary64)) Initial program 87.9%
Taylor expanded in l around 0 87.2%
unpow287.2%
Applied egg-rr87.2%
Final simplification77.6%
(FPCore (J l K U) :precision binary64 (if (or (<= l -3.1e+21) (not (<= l 3900000000000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3.1e+21) || !(l <= 3900000000000.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 <= (-3.1d+21)) .or. (.not. (l <= 3900000000000.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 <= -3.1e+21) || !(l <= 3900000000000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -3.1e+21) or not (l <= 3900000000000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -3.1e+21) || !(l <= 3900000000000.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 <= -3.1e+21) || ~((l <= 3900000000000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3.1e+21], N[Not[LessEqual[l, 3900000000000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.1 \cdot 10^{+21} \lor \neg \left(\ell \leq 3900000000000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -3.1e21 or 3.9e12 < l Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
Applied egg-rr14.4%
if -3.1e21 < l < 3.9e12Initial program 75.2%
associate-*l*75.2%
fma-define75.2%
Simplified75.2%
Taylor expanded in J around 0 66.3%
Final simplification44.0%
(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.9%
Taylor expanded in l around 0 85.9%
Taylor expanded in K around 0 68.8%
unpow285.9%
Applied egg-rr68.8%
Final simplification68.8%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* 2.0 (* J (/ l U))))))
double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (l / 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 * (1.0d0 + (2.0d0 * (j * (l / u))))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * (J * (l / U))));
}
def code(J, l, K, U): return U * (1.0 + (2.0 * (J * (l / U))))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(2.0 * Float64(J * Float64(l / U))))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + (2.0 * (J * (l / U)))); end
code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(2.0 * N[(J * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U \cdot \left(1 + 2 \cdot \left(J \cdot \frac{\ell}{U}\right)\right)
\end{array}
Initial program 85.9%
Taylor expanded in l around 0 64.6%
*-commutative64.6%
associate-*l*64.6%
Simplified64.6%
Taylor expanded in U around inf 70.2%
Taylor expanded in K around 0 59.5%
associate-/l*61.7%
Simplified61.7%
(FPCore (J l K U) :precision binary64 (+ U (* J (* l 2.0))))
double code(double J, double l, double K, double U) {
return U + (J * (l * 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 + (j * (l * 2.0d0))
end function
public static double code(double J, double l, double K, double U) {
return U + (J * (l * 2.0));
}
def code(J, l, K, U): return U + (J * (l * 2.0))
function code(J, l, K, U) return Float64(U + Float64(J * Float64(l * 2.0))) end
function tmp = code(J, l, K, U) tmp = U + (J * (l * 2.0)); end
code[J_, l_, K_, U_] := N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + J \cdot \left(\ell \cdot 2\right)
\end{array}
Initial program 85.9%
Taylor expanded in l around 0 64.6%
*-commutative64.6%
associate-*l*64.6%
Simplified64.6%
Taylor expanded in K around 0 55.2%
associate-*r*55.2%
*-commutative55.2%
associate-*l*55.2%
Simplified55.2%
Final simplification55.2%
(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.9%
associate-*l*85.9%
fma-define85.9%
Simplified85.9%
Taylor expanded in J around 0 38.8%
(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.9%
Applied egg-rr25.8%
Taylor expanded in U around 0 3.0%
herbie shell --seed 2024136
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))