
(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 9 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 (- INFINITY)) (not (<= t_1 5e-11)))
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(*
J
(*
l
(+
2.0
(*
(pow l 2.0)
(+
0.3333333333333333
(*
(pow l 2.0)
(+
0.016666666666666666
(* (pow l 2.0) 0.0003968253968253968)))))))))))))
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 <= -((double) INFINITY)) || !(t_1 <= 5e-11)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (pow(l, 2.0) * (0.3333333333333333 + (pow(l, 2.0) * (0.016666666666666666 + (pow(l, 2.0) * 0.0003968253968253968)))))))));
}
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) - Math.exp(-l);
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e-11)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (Math.pow(l, 2.0) * (0.3333333333333333 + (Math.pow(l, 2.0) * (0.016666666666666666 + (Math.pow(l, 2.0) * 0.0003968253968253968)))))))));
}
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 <= -math.inf) or not (t_1 <= 5e-11): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * (l * (2.0 + (math.pow(l, 2.0) * (0.3333333333333333 + (math.pow(l, 2.0) * (0.016666666666666666 + (math.pow(l, 2.0) * 0.0003968253968253968))))))))) 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 <= Float64(-Inf)) || !(t_1 <= 5e-11)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64((l ^ 2.0) * Float64(0.3333333333333333 + Float64((l ^ 2.0) * Float64(0.016666666666666666 + Float64((l ^ 2.0) * 0.0003968253968253968)))))))))); 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 <= -Inf) || ~((t_1 <= 5e-11))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * (l * (2.0 + ((l ^ 2.0) * (0.3333333333333333 + ((l ^ 2.0) * (0.016666666666666666 + ((l ^ 2.0) * 0.0003968253968253968))))))))); 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, (-Infinity)], N[Not[LessEqual[t$95$1, 5e-11]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * N[(0.3333333333333333 + N[(N[Power[l, 2.0], $MachinePrecision] * N[(0.016666666666666666 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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} - e^{-\ell}\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot \left(0.3333333333333333 + {\ell}^{2} \cdot \left(0.016666666666666666 + {\ell}^{2} \cdot 0.0003968253968253968\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 5.00000000000000018e-11 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000018e-11Initial program 70.3%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -0.05) (not (<= t_0 5e-11)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -0.05) || !(t_0 <= 5e-11)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
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.05d0)) .or. (.not. (t_0 <= 5d-11))) then
tmp = ((t_0 * j) * cos((k / 2.0d0))) + u
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
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.05) || !(t_0 <= 5e-11)) {
tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -0.05) or not (t_0 <= 5e-11): tmp = ((t_0 * J) * math.cos((K / 2.0))) + U else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -0.05) || !(t_0 <= 5e-11)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); 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.05) || ~((t_0 <= 5e-11))) tmp = ((t_0 * J) * cos((K / 2.0))) + U; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); 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.05], N[Not[LessEqual[t$95$0, 5e-11]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_0 \leq -0.05 \lor \neg \left(t\_0 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.050000000000000003 or 5.00000000000000018e-11 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -0.050000000000000003 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000018e-11Initial program 69.9%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 -0.05) (not (<= t_0 5e-11)))
(+ (* t_0 J) U)
(+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -0.05) || !(t_0 <= 5e-11)) {
tmp = (t_0 * J) + U;
} else {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
}
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.05d0)) .or. (.not. (t_0 <= 5d-11))) then
tmp = (t_0 * j) + u
else
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
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.05) || !(t_0 <= 5e-11)) {
tmp = (t_0 * J) + U;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -0.05) or not (t_0 <= 5e-11): tmp = (t_0 * J) + U else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -0.05) || !(t_0 <= 5e-11)) tmp = Float64(Float64(t_0 * J) + U); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); 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.05) || ~((t_0 <= 5e-11))) tmp = (t_0 * J) + U; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); 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.05], N[Not[LessEqual[t$95$0, 5e-11]], $MachinePrecision]], N[(N[(t$95$0 * J), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_0 \leq -0.05 \lor \neg \left(t\_0 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;t\_0 \cdot J + U\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.050000000000000003 or 5.00000000000000018e-11 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in K around 0 71.4%
if -0.050000000000000003 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.00000000000000018e-11Initial program 69.9%
Taylor expanded in l around 0 99.9%
Final simplification86.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+
U
(* (cos (/ K 2.0)) (* (pow l 7.0) (* J 0.0003968253968253968))))))
(if (<= l -4.45e+46)
t_0
(if (<= l -0.0017)
(+ (* (- (exp l) (exp (- l))) J) U)
(if (<= l 4.2) (+ 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 + (cos((K / 2.0)) * (pow(l, 7.0) * (J * 0.0003968253968253968)));
double tmp;
if (l <= -4.45e+46) {
tmp = t_0;
} else if (l <= -0.0017) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else if (l <= 4.2) {
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 + (cos((k / 2.0d0)) * ((l ** 7.0d0) * (j * 0.0003968253968253968d0)))
if (l <= (-4.45d+46)) then
tmp = t_0
else if (l <= (-0.0017d0)) then
tmp = ((exp(l) - exp(-l)) * j) + u
else if (l <= 4.2d0) 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 + (Math.cos((K / 2.0)) * (Math.pow(l, 7.0) * (J * 0.0003968253968253968)));
double tmp;
if (l <= -4.45e+46) {
tmp = t_0;
} else if (l <= -0.0017) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else if (l <= 4.2) {
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 + (math.cos((K / 2.0)) * (math.pow(l, 7.0) * (J * 0.0003968253968253968))) tmp = 0 if l <= -4.45e+46: tmp = t_0 elif l <= -0.0017: tmp = ((math.exp(l) - math.exp(-l)) * J) + U elif l <= 4.2: 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(cos(Float64(K / 2.0)) * Float64((l ^ 7.0) * Float64(J * 0.0003968253968253968)))) tmp = 0.0 if (l <= -4.45e+46) tmp = t_0; elseif (l <= -0.0017) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); elseif (l <= 4.2) 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 + (cos((K / 2.0)) * ((l ^ 7.0) * (J * 0.0003968253968253968))); tmp = 0.0; if (l <= -4.45e+46) tmp = t_0; elseif (l <= -0.0017) tmp = ((exp(l) - exp(-l)) * J) + U; elseif (l <= 4.2) 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[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Power[l, 7.0], $MachinePrecision] * N[(J * 0.0003968253968253968), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.45e+46], t$95$0, If[LessEqual[l, -0.0017], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 4.2], 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 + \cos \left(\frac{K}{2}\right) \cdot \left({\ell}^{7} \cdot \left(J \cdot 0.0003968253968253968\right)\right)\\
\mathbf{if}\;\ell \leq -4.45 \cdot 10^{+46}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -0.0017:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{elif}\;\ell \leq 4.2:\\
\;\;\;\;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 < -4.4499999999999998e46 or 4.20000000000000018 < l Initial program 100.0%
Taylor expanded in l around 0 94.1%
*-commutative94.1%
Simplified94.1%
Taylor expanded in l around inf 94.1%
*-commutative94.1%
*-commutative94.1%
associate-*r*94.1%
Simplified94.1%
if -4.4499999999999998e46 < l < -0.00169999999999999991Initial program 99.4%
Taylor expanded in K around 0 99.4%
if -0.00169999999999999991 < l < 4.20000000000000018Initial program 69.9%
Taylor expanded in l around 0 99.9%
Final simplification97.3%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.02) (+ U (* J (* l (* (pow K 2.0) -0.25)))) (+ U (* l (* J 2.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.02) {
tmp = U + (J * (l * (pow(K, 2.0) * -0.25)));
} else {
tmp = U + (l * (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) :: tmp
if (cos((k / 2.0d0)) <= (-0.02d0)) then
tmp = u + (j * (l * ((k ** 2.0d0) * (-0.25d0))))
else
tmp = u + (l * (j * 2.0d0))
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.02) {
tmp = U + (J * (l * (Math.pow(K, 2.0) * -0.25)));
} else {
tmp = U + (l * (J * 2.0));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.02: tmp = U + (J * (l * (math.pow(K, 2.0) * -0.25))) else: tmp = U + (l * (J * 2.0)) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.02) tmp = Float64(U + Float64(J * Float64(l * Float64((K ^ 2.0) * -0.25)))); else tmp = Float64(U + Float64(l * Float64(J * 2.0))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.02) tmp = U + (J * (l * ((K ^ 2.0) * -0.25))); else tmp = U + (l * (J * 2.0)); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.02], N[(U + N[(J * N[(l * N[(N[Power[K, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.02:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left({K}^{2} \cdot -0.25\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0200000000000000004Initial program 86.0%
Taylor expanded in l around 0 68.7%
associate-*r*68.7%
associate-*r*68.7%
Simplified68.7%
Taylor expanded in K around 0 43.2%
Taylor expanded in K around inf 56.7%
*-commutative56.7%
*-commutative56.7%
associate-*r*56.7%
associate-*l*56.7%
Simplified56.7%
if -0.0200000000000000004 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 83.5%
Taylor expanded in l around 0 65.9%
associate-*r*65.9%
associate-*r*65.8%
Simplified65.8%
Taylor expanded in K around 0 42.5%
Taylor expanded in K around 0 58.6%
*-commutative58.6%
*-commutative58.6%
associate-*r*58.6%
Simplified58.6%
Final simplification58.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5))))
(if (<= J -4.7e+169)
(+ U (* l (* J (* 2.0 t_0))))
(if (<= J 1.46e-8)
(+ U (* J (* l (+ 2.0 (* (pow l 2.0) 0.3333333333333333)))))
(+ U (* 2.0 (* J (* l t_0))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double tmp;
if (J <= -4.7e+169) {
tmp = U + (l * (J * (2.0 * t_0)));
} else if (J <= 1.46e-8) {
tmp = U + (J * (l * (2.0 + (pow(l, 2.0) * 0.3333333333333333))));
} else {
tmp = U + (2.0 * (J * (l * 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 = cos((k * 0.5d0))
if (j <= (-4.7d+169)) then
tmp = u + (l * (j * (2.0d0 * t_0)))
else if (j <= 1.46d-8) then
tmp = u + (j * (l * (2.0d0 + ((l ** 2.0d0) * 0.3333333333333333d0))))
else
tmp = u + (2.0d0 * (j * (l * t_0)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K * 0.5));
double tmp;
if (J <= -4.7e+169) {
tmp = U + (l * (J * (2.0 * t_0)));
} else if (J <= 1.46e-8) {
tmp = U + (J * (l * (2.0 + (Math.pow(l, 2.0) * 0.3333333333333333))));
} else {
tmp = U + (2.0 * (J * (l * t_0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) tmp = 0 if J <= -4.7e+169: tmp = U + (l * (J * (2.0 * t_0))) elif J <= 1.46e-8: tmp = U + (J * (l * (2.0 + (math.pow(l, 2.0) * 0.3333333333333333)))) else: tmp = U + (2.0 * (J * (l * t_0))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) tmp = 0.0 if (J <= -4.7e+169) tmp = Float64(U + Float64(l * Float64(J * Float64(2.0 * t_0)))); elseif (J <= 1.46e-8) tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 + Float64((l ^ 2.0) * 0.3333333333333333))))); else tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K * 0.5)); tmp = 0.0; if (J <= -4.7e+169) tmp = U + (l * (J * (2.0 * t_0))); elseif (J <= 1.46e-8) tmp = U + (J * (l * (2.0 + ((l ^ 2.0) * 0.3333333333333333)))); else tmp = U + (2.0 * (J * (l * t_0))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[J, -4.7e+169], N[(U + N[(l * N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[J, 1.46e-8], N[(U + N[(J * N[(l * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
\mathbf{if}\;J \leq -4.7 \cdot 10^{+169}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot \left(2 \cdot t\_0\right)\right)\\
\mathbf{elif}\;J \leq 1.46 \cdot 10^{-8}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 + {\ell}^{2} \cdot 0.3333333333333333\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t\_0\right)\right)\\
\end{array}
\end{array}
if J < -4.6999999999999998e169Initial program 60.5%
Taylor expanded in l around 0 96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in l around 0 89.5%
associate-*r*89.5%
associate-*r*89.5%
*-commutative89.5%
associate-*r*89.5%
*-commutative89.5%
associate-*l*89.5%
Simplified89.5%
if -4.6999999999999998e169 < J < 1.46e-8Initial program 94.5%
Taylor expanded in K around 0 83.1%
Taylor expanded in l around 0 75.3%
if 1.46e-8 < J Initial program 70.1%
Taylor expanded in l around 0 82.8%
Final simplification78.8%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * cos((K * 0.5)))));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (2.0 * (J * (l * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 84.2%
Taylor expanded in l around 0 66.7%
Final simplification66.7%
(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 84.2%
Taylor expanded in l around 0 66.7%
associate-*r*66.7%
associate-*r*66.7%
Simplified66.7%
Taylor expanded in K around 0 42.7%
Taylor expanded in K around 0 53.2%
*-commutative53.2%
*-commutative53.2%
associate-*r*53.2%
Simplified53.2%
Final simplification53.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 84.2%
Applied egg-rr30.3%
Taylor expanded in J around 0 37.5%
herbie shell --seed 2024090
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))