
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 0.0)))
(+ (* t_0 (* t_1 J)) U)
(+
U
(* t_0 (+ (* 2.0 (* l J)) (* 0.3333333333333333 (* J (pow l 3.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 <= -((double) INFINITY)) || !(t_1 <= 0.0)) {
tmp = (t_0 * (t_1 * J)) + U;
} else {
tmp = U + (t_0 * ((2.0 * (l * J)) + (0.3333333333333333 * (J * pow(l, 3.0)))));
}
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 <= 0.0)) {
tmp = (t_0 * (t_1 * J)) + U;
} else {
tmp = U + (t_0 * ((2.0 * (l * J)) + (0.3333333333333333 * (J * Math.pow(l, 3.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 <= -math.inf) or not (t_1 <= 0.0): tmp = (t_0 * (t_1 * J)) + U else: tmp = U + (t_0 * ((2.0 * (l * J)) + (0.3333333333333333 * (J * math.pow(l, 3.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 <= Float64(-Inf)) || !(t_1 <= 0.0)) tmp = Float64(Float64(t_0 * Float64(t_1 * J)) + U); else tmp = Float64(U + Float64(t_0 * Float64(Float64(2.0 * Float64(l * J)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.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 <= -Inf) || ~((t_1 <= 0.0))) tmp = (t_0 * (t_1 * J)) + U; else tmp = U + (t_0 * ((2.0 * (l * J)) + (0.3333333333333333 * (J * (l ^ 3.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, (-Infinity)], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], N[(N[(t$95$0 * N[(t$95$1 * J), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $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 0\right):\\
\;\;\;\;t_0 \cdot \left(t_1 \cdot J\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(2 \cdot \left(\ell \cdot J\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 0.0 < (-.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))) < 0.0Initial program 68.7%
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 (- INFINITY)) (not (<= t_0 0.0)))
(+ U (* t_0 J))
(+ U (* 2.0 (* l (* J (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 <= -((double) INFINITY)) || !(t_0 <= 0.0)) {
tmp = U + (t_0 * J);
} else {
tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
}
return tmp;
}
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 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 0.0)) {
tmp = U + (t_0 * J);
} else {
tmp = U + (2.0 * (l * (J * 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 <= -math.inf) or not (t_0 <= 0.0): tmp = U + (t_0 * J) else: tmp = U + (2.0 * (l * (J * 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 <= Float64(-Inf)) || !(t_0 <= 0.0)) tmp = Float64(U + Float64(t_0 * J)); else tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * 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 <= -Inf) || ~((t_0 <= 0.0))) tmp = U + (t_0 * J); else tmp = U + (2.0 * (l * (J * 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, (-Infinity)], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(U + N[(t$95$0 * J), $MachinePrecision]), $MachinePrecision], N[(U + N[(2.0 * N[(l * N[(J * 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 -\infty \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;U + t_0 \cdot J\\
\mathbf{else}:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 0.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Taylor expanded in K around 0 76.7%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 0.0Initial program 68.7%
Taylor expanded in l around 0 99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
Final simplification89.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (+ U (* 2.0 (* l (* J (cos (* K 0.5))))))))
(if (<= t_0 -0.55)
t_1
(if (<= t_0 -0.01)
(+ U (* (* l J) (+ 2.0 (* (* K K) -0.25))))
(if (<= t_0 0.25)
t_1
(+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U + (2.0 * (l * (J * cos((K * 0.5)))));
double tmp;
if (t_0 <= -0.55) {
tmp = t_1;
} else if (t_0 <= -0.01) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
} else if (t_0 <= 0.25) {
tmp = t_1;
} else {
tmp = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 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 = u + (2.0d0 * (l * (j * cos((k * 0.5d0)))))
if (t_0 <= (-0.55d0)) then
tmp = t_1
else if (t_0 <= (-0.01d0)) then
tmp = u + ((l * j) * (2.0d0 + ((k * k) * (-0.25d0))))
else if (t_0 <= 0.25d0) then
tmp = t_1
else
tmp = u + (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 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 = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
double tmp;
if (t_0 <= -0.55) {
tmp = t_1;
} else if (t_0 <= -0.01) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25)));
} else if (t_0 <= 0.25) {
tmp = t_1;
} else {
tmp = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U + (2.0 * (l * (J * math.cos((K * 0.5))))) tmp = 0 if t_0 <= -0.55: tmp = t_1 elif t_0 <= -0.01: tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25))) elif t_0 <= 0.25: tmp = t_1 else: tmp = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))) tmp = 0.0 if (t_0 <= -0.55) tmp = t_1; elseif (t_0 <= -0.01) tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -0.25)))); elseif (t_0 <= 0.25) tmp = t_1; else tmp = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K / 2.0)); t_1 = U + (2.0 * (l * (J * cos((K * 0.5))))); tmp = 0.0; if (t_0 <= -0.55) tmp = t_1; elseif (t_0 <= -0.01) tmp = U + ((l * J) * (2.0 + ((K * K) * -0.25))); elseif (t_0 <= 0.25) tmp = t_1; else tmp = U + (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 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[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.55], t$95$1, If[LessEqual[t$95$0, -0.01], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.25], t$95$1, N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{if}\;t_0 \leq -0.55:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -0.01:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\
\mathbf{elif}\;t_0 \leq 0.25:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.55000000000000004 or -0.0100000000000000002 < (cos.f64 (/.f64 K 2)) < 0.25Initial program 78.0%
Taylor expanded in l around 0 80.1%
*-commutative80.1%
associate-*l*80.2%
*-commutative80.2%
Simplified80.2%
if -0.55000000000000004 < (cos.f64 (/.f64 K 2)) < -0.0100000000000000002Initial program 87.2%
Taylor expanded in l around 0 88.2%
Taylor expanded in l around 0 46.6%
*-commutative46.6%
*-commutative46.6%
associate-*r*46.6%
associate-*r*46.6%
*-commutative46.6%
associate-*l*46.7%
*-commutative46.7%
associate-*l*46.7%
*-commutative46.7%
Simplified46.7%
Taylor expanded in K around 0 51.4%
associate-*r*51.4%
distribute-rgt-out68.1%
*-commutative68.1%
*-commutative68.1%
unpow268.1%
Simplified68.1%
if 0.25 < (cos.f64 (/.f64 K 2)) Initial program 83.3%
Taylor expanded in l around 0 90.1%
fma-def90.1%
+-commutative90.1%
associate-*r*90.1%
associate-*r*90.1%
distribute-rgt-out90.1%
*-commutative90.1%
*-commutative90.1%
div-inv90.1%
metadata-eval90.1%
Applied egg-rr90.1%
Taylor expanded in K around 0 87.3%
Final simplification84.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* 0.3333333333333333 (* (pow l 3.0) (* J (cos (* K 0.5)))))))
(t_1 (+ U (* (- (exp l) (exp (- l))) J))))
(if (<= l -6.6e+146)
t_0
(if (<= l -0.92)
t_1
(if (<= l 8.4e-16)
(+
U
(*
(cos (/ K 2.0))
(+ (* 2.0 (* l J)) (* 0.3333333333333333 (* J (pow l 3.0))))))
(if (<= l 6e+93) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (0.3333333333333333 * (pow(l, 3.0) * (J * cos((K * 0.5)))));
double t_1 = U + ((exp(l) - exp(-l)) * J);
double tmp;
if (l <= -6.6e+146) {
tmp = t_0;
} else if (l <= -0.92) {
tmp = t_1;
} else if (l <= 8.4e-16) {
tmp = U + (cos((K / 2.0)) * ((2.0 * (l * J)) + (0.3333333333333333 * (J * pow(l, 3.0)))));
} else if (l <= 6e+93) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = u + (0.3333333333333333d0 * ((l ** 3.0d0) * (j * cos((k * 0.5d0)))))
t_1 = u + ((exp(l) - exp(-l)) * j)
if (l <= (-6.6d+146)) then
tmp = t_0
else if (l <= (-0.92d0)) then
tmp = t_1
else if (l <= 8.4d-16) then
tmp = u + (cos((k / 2.0d0)) * ((2.0d0 * (l * j)) + (0.3333333333333333d0 * (j * (l ** 3.0d0)))))
else if (l <= 6d+93) then
tmp = t_1
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 + (0.3333333333333333 * (Math.pow(l, 3.0) * (J * Math.cos((K * 0.5)))));
double t_1 = U + ((Math.exp(l) - Math.exp(-l)) * J);
double tmp;
if (l <= -6.6e+146) {
tmp = t_0;
} else if (l <= -0.92) {
tmp = t_1;
} else if (l <= 8.4e-16) {
tmp = U + (Math.cos((K / 2.0)) * ((2.0 * (l * J)) + (0.3333333333333333 * (J * Math.pow(l, 3.0)))));
} else if (l <= 6e+93) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (0.3333333333333333 * (math.pow(l, 3.0) * (J * math.cos((K * 0.5))))) t_1 = U + ((math.exp(l) - math.exp(-l)) * J) tmp = 0 if l <= -6.6e+146: tmp = t_0 elif l <= -0.92: tmp = t_1 elif l <= 8.4e-16: tmp = U + (math.cos((K / 2.0)) * ((2.0 * (l * J)) + (0.3333333333333333 * (J * math.pow(l, 3.0))))) elif l <= 6e+93: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(0.3333333333333333 * Float64((l ^ 3.0) * Float64(J * cos(Float64(K * 0.5)))))) t_1 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)) tmp = 0.0 if (l <= -6.6e+146) tmp = t_0; elseif (l <= -0.92) tmp = t_1; elseif (l <= 8.4e-16) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(Float64(2.0 * Float64(l * J)) + Float64(0.3333333333333333 * Float64(J * (l ^ 3.0)))))); elseif (l <= 6e+93) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (0.3333333333333333 * ((l ^ 3.0) * (J * cos((K * 0.5))))); t_1 = U + ((exp(l) - exp(-l)) * J); tmp = 0.0; if (l <= -6.6e+146) tmp = t_0; elseif (l <= -0.92) tmp = t_1; elseif (l <= 8.4e-16) tmp = U + (cos((K / 2.0)) * ((2.0 * (l * J)) + (0.3333333333333333 * (J * (l ^ 3.0))))); elseif (l <= 6e+93) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(0.3333333333333333 * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -6.6e+146], t$95$0, If[LessEqual[l, -0.92], t$95$1, If[LessEqual[l, 8.4e-16], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[(2.0 * N[(l * J), $MachinePrecision]), $MachinePrecision] + N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e+93], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + 0.3333333333333333 \cdot \left({\ell}^{3} \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -6.6 \cdot 10^{+146}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.92:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 8.4 \cdot 10^{-16}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(2 \cdot \left(\ell \cdot J\right) + 0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right)\right)\\
\mathbf{elif}\;\ell \leq 6 \cdot 10^{+93}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -6.60000000000000032e146 or 5.99999999999999957e93 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
if -6.60000000000000032e146 < l < -0.92000000000000004 or 8.4000000000000004e-16 < l < 5.99999999999999957e93Initial program 100.0%
Taylor expanded in K around 0 92.9%
if -0.92000000000000004 < l < 8.4000000000000004e-16Initial program 68.7%
Taylor expanded in l around 0 99.9%
Final simplification98.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* 0.3333333333333333 (* (pow l 3.0) (* J (cos (* K 0.5)))))))
(t_1 (+ U (* (- (exp l) (exp (- l))) J))))
(if (<= l -6.6e+146)
t_0
(if (<= l -0.0305)
t_1
(if (<= l 8.4e-16)
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 1.95e+93) t_1 t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (0.3333333333333333 * (pow(l, 3.0) * (J * cos((K * 0.5)))));
double t_1 = U + ((exp(l) - exp(-l)) * J);
double tmp;
if (l <= -6.6e+146) {
tmp = t_0;
} else if (l <= -0.0305) {
tmp = t_1;
} else if (l <= 8.4e-16) {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 1.95e+93) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = u + (0.3333333333333333d0 * ((l ** 3.0d0) * (j * cos((k * 0.5d0)))))
t_1 = u + ((exp(l) - exp(-l)) * j)
if (l <= (-6.6d+146)) then
tmp = t_0
else if (l <= (-0.0305d0)) then
tmp = t_1
else if (l <= 8.4d-16) then
tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 1.95d+93) then
tmp = t_1
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 + (0.3333333333333333 * (Math.pow(l, 3.0) * (J * Math.cos((K * 0.5)))));
double t_1 = U + ((Math.exp(l) - Math.exp(-l)) * J);
double tmp;
if (l <= -6.6e+146) {
tmp = t_0;
} else if (l <= -0.0305) {
tmp = t_1;
} else if (l <= 8.4e-16) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 1.95e+93) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (0.3333333333333333 * (math.pow(l, 3.0) * (J * math.cos((K * 0.5))))) t_1 = U + ((math.exp(l) - math.exp(-l)) * J) tmp = 0 if l <= -6.6e+146: tmp = t_0 elif l <= -0.0305: tmp = t_1 elif l <= 8.4e-16: tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 1.95e+93: tmp = t_1 else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(0.3333333333333333 * Float64((l ^ 3.0) * Float64(J * cos(Float64(K * 0.5)))))) t_1 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)) tmp = 0.0 if (l <= -6.6e+146) tmp = t_0; elseif (l <= -0.0305) tmp = t_1; elseif (l <= 8.4e-16) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 1.95e+93) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = U + (0.3333333333333333 * ((l ^ 3.0) * (J * cos((K * 0.5))))); t_1 = U + ((exp(l) - exp(-l)) * J); tmp = 0.0; if (l <= -6.6e+146) tmp = t_0; elseif (l <= -0.0305) tmp = t_1; elseif (l <= 8.4e-16) tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 1.95e+93) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(0.3333333333333333 * N[(N[Power[l, 3.0], $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -6.6e+146], t$95$0, If[LessEqual[l, -0.0305], t$95$1, If[LessEqual[l, 8.4e-16], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.95e+93], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + 0.3333333333333333 \cdot \left({\ell}^{3} \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
t_1 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -6.6 \cdot 10^{+146}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -0.0305:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq 8.4 \cdot 10^{-16}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 1.95 \cdot 10^{+93}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if l < -6.60000000000000032e146 or 1.9500000000000001e93 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
if -6.60000000000000032e146 < l < -0.030499999999999999 or 8.4000000000000004e-16 < l < 1.9500000000000001e93Initial program 100.0%
Taylor expanded in K around 0 92.9%
if -0.030499999999999999 < l < 8.4000000000000004e-16Initial program 68.7%
Taylor expanded in l around 0 99.9%
Final simplification98.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* J (cos (* K 0.5))))
(t_1 (+ U (* 0.3333333333333333 (* (pow l 3.0) t_0))))
(t_2 (+ U (* (- (exp l) (exp (- l))) J))))
(if (<= l -5e+156)
t_1
(if (<= l -0.00072)
t_2
(if (<= l 8.4e-16) (fma (* l 2.0) t_0 U) (if (<= l 7e+93) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = J * cos((K * 0.5));
double t_1 = U + (0.3333333333333333 * (pow(l, 3.0) * t_0));
double t_2 = U + ((exp(l) - exp(-l)) * J);
double tmp;
if (l <= -5e+156) {
tmp = t_1;
} else if (l <= -0.00072) {
tmp = t_2;
} else if (l <= 8.4e-16) {
tmp = fma((l * 2.0), t_0, U);
} else if (l <= 7e+93) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(J * cos(Float64(K * 0.5))) t_1 = Float64(U + Float64(0.3333333333333333 * Float64((l ^ 3.0) * t_0))) t_2 = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)) tmp = 0.0 if (l <= -5e+156) tmp = t_1; elseif (l <= -0.00072) tmp = t_2; elseif (l <= 8.4e-16) tmp = fma(Float64(l * 2.0), t_0, U); elseif (l <= 7e+93) tmp = t_2; else tmp = t_1; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(0.3333333333333333 * N[(N[Power[l, 3.0], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5e+156], t$95$1, If[LessEqual[l, -0.00072], t$95$2, If[LessEqual[l, 8.4e-16], N[(N[(l * 2.0), $MachinePrecision] * t$95$0 + U), $MachinePrecision], If[LessEqual[l, 7e+93], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := J \cdot \cos \left(K \cdot 0.5\right)\\
t_1 := U + 0.3333333333333333 \cdot \left({\ell}^{3} \cdot t_0\right)\\
t_2 := U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{+156}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -0.00072:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq 8.4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot 2, t_0, U\right)\\
\mathbf{elif}\;\ell \leq 7 \cdot 10^{+93}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -4.99999999999999992e156 or 6.99999999999999996e93 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
*-commutative100.0%
*-commutative100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
if -4.99999999999999992e156 < l < -7.20000000000000045e-4 or 8.4000000000000004e-16 < l < 6.99999999999999996e93Initial program 100.0%
Taylor expanded in K around 0 92.9%
if -7.20000000000000045e-4 < l < 8.4000000000000004e-16Initial program 68.7%
Taylor expanded in l around 0 99.9%
Taylor expanded in l around 0 99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r*99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
associate-*r*99.7%
fma-def99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification98.7%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (log1p (expm1 (- (/ -8.0 U) U))))
(t_1 (+ U (* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))))))
(if (<= l -8e+73)
t_1
(if (<= l -480.0)
t_0
(if (<= l 460.0)
(+ U (* 2.0 (* l (* J (cos (* K 0.5))))))
(if (<= l 6.8e+129) t_0 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = log1p(expm1(((-8.0 / U) - U)));
double t_1 = U + (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)));
double tmp;
if (l <= -8e+73) {
tmp = t_1;
} else if (l <= -480.0) {
tmp = t_0;
} else if (l <= 460.0) {
tmp = U + (2.0 * (l * (J * cos((K * 0.5)))));
} else if (l <= 6.8e+129) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.log1p(Math.expm1(((-8.0 / U) - U)));
double t_1 = U + (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)));
double tmp;
if (l <= -8e+73) {
tmp = t_1;
} else if (l <= -480.0) {
tmp = t_0;
} else if (l <= 460.0) {
tmp = U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
} else if (l <= 6.8e+129) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.log1p(math.expm1(((-8.0 / U) - U))) t_1 = U + (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0))) tmp = 0 if l <= -8e+73: tmp = t_1 elif l <= -480.0: tmp = t_0 elif l <= 460.0: tmp = U + (2.0 * (l * (J * math.cos((K * 0.5))))) elif l <= 6.8e+129: tmp = t_0 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = log1p(expm1(Float64(Float64(-8.0 / U) - U))) t_1 = Float64(U + Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)))) tmp = 0.0 if (l <= -8e+73) tmp = t_1; elseif (l <= -480.0) tmp = t_0; elseif (l <= 460.0) tmp = Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))); elseif (l <= 6.8e+129) tmp = t_0; else tmp = t_1; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Log[1 + N[(Exp[N[(N[(-8.0 / U), $MachinePrecision] - U), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -8e+73], t$95$1, If[LessEqual[l, -480.0], t$95$0, If[LessEqual[l, 460.0], N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.8e+129], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-8}{U} - U\right)\right)\\
t_1 := U + J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\\
\mathbf{if}\;\ell \leq -8 \cdot 10^{+73}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -480:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 460:\\
\;\;\;\;U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 6.8 \cdot 10^{+129}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -7.99999999999999986e73 or 6.80000000000000036e129 < l Initial program 100.0%
Taylor expanded in l around 0 96.5%
fma-def96.5%
+-commutative96.5%
associate-*r*96.5%
associate-*r*96.5%
distribute-rgt-out96.5%
*-commutative96.5%
*-commutative96.5%
div-inv96.5%
metadata-eval96.5%
Applied egg-rr96.5%
Taylor expanded in K around 0 72.1%
if -7.99999999999999986e73 < l < -480 or 460 < l < 6.80000000000000036e129Initial program 100.0%
Applied egg-rr3.6%
log1p-expm1-u65.6%
Applied egg-rr65.6%
if -480 < l < 460Initial program 69.1%
Taylor expanded in l around 0 99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
Final simplification86.6%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.00255) (not (<= l 8.4e-16))) (+ U (* (- (exp l) (exp (- l))) J)) (fma (* l 2.0) (* J (cos (* K 0.5))) U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.00255) || !(l <= 8.4e-16)) {
tmp = U + ((exp(l) - exp(-l)) * J);
} else {
tmp = fma((l * 2.0), (J * cos((K * 0.5))), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.00255) || !(l <= 8.4e-16)) tmp = Float64(U + Float64(Float64(exp(l) - exp(Float64(-l))) * J)); else tmp = fma(Float64(l * 2.0), Float64(J * cos(Float64(K * 0.5))), U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.00255], N[Not[LessEqual[l, 8.4e-16]], $MachinePrecision]], N[(U + N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision], N[(N[(l * 2.0), $MachinePrecision] * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.00255 \lor \neg \left(\ell \leq 8.4 \cdot 10^{-16}\right):\\
\;\;\;\;U + \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot 2, J \cdot \cos \left(K \cdot 0.5\right), U\right)\\
\end{array}
\end{array}
if l < -0.0025500000000000002 or 8.4000000000000004e-16 < l Initial program 100.0%
Taylor expanded in K around 0 76.7%
if -0.0025500000000000002 < l < 8.4000000000000004e-16Initial program 68.7%
Taylor expanded in l around 0 99.9%
Taylor expanded in l around 0 99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r*99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
Simplified99.7%
associate-*r*99.7%
fma-def99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification89.3%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.01) (+ U (* (* l J) (+ 2.0 (* (* K K) -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.01) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -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.01d0)) then
tmp = u + ((l * j) * (2.0d0 + ((k * k) * (-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.01) {
tmp = U + ((l * J) * (2.0 + ((K * K) * -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.01: tmp = U + ((l * J) * (2.0 + ((K * K) * -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.01) tmp = Float64(U + Float64(Float64(l * J) * Float64(2.0 + Float64(Float64(K * K) * -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.01) tmp = U + ((l * J) * (2.0 + ((K * K) * -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.01], N[(U + N[(N[(l * J), $MachinePrecision] * N[(2.0 + N[(N[(K * K), $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.01:\\
\;\;\;\;U + \left(\ell \cdot J\right) \cdot \left(2 + \left(K \cdot K\right) \cdot -0.25\right)\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(J \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.0100000000000000002Initial program 83.9%
Taylor expanded in l around 0 94.8%
Taylor expanded in l around 0 62.7%
*-commutative62.7%
*-commutative62.7%
associate-*r*62.7%
associate-*r*62.7%
*-commutative62.7%
associate-*l*62.7%
*-commutative62.7%
associate-*l*62.7%
*-commutative62.7%
Simplified62.7%
Taylor expanded in K around 0 40.3%
associate-*r*40.3%
distribute-rgt-out51.2%
*-commutative51.2%
*-commutative51.2%
unpow251.2%
Simplified51.2%
if -0.0100000000000000002 < (cos.f64 (/.f64 K 2)) Initial program 82.6%
Taylor expanded in l around 0 90.5%
Taylor expanded in l around 0 70.5%
*-commutative70.5%
*-commutative70.5%
associate-*r*70.5%
associate-*r*70.5%
*-commutative70.5%
associate-*l*70.5%
*-commutative70.5%
associate-*l*70.5%
*-commutative70.5%
Simplified70.5%
Taylor expanded in K around 0 66.5%
Final simplification63.3%
(FPCore (J l K U) :precision binary64 (+ U (* 2.0 (* l (* J (cos (* K 0.5)))))))
double code(double J, double l, double K, double U) {
return U + (2.0 * (l * (J * 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 * (l * (j * cos((k * 0.5d0)))))
end function
public static double code(double J, double l, double K, double U) {
return U + (2.0 * (l * (J * Math.cos((K * 0.5)))));
}
def code(J, l, K, U): return U + (2.0 * (l * (J * math.cos((K * 0.5)))))
function code(J, l, K, U) return Float64(U + Float64(2.0 * Float64(l * Float64(J * cos(Float64(K * 0.5)))))) end
function tmp = code(J, l, K, U) tmp = U + (2.0 * (l * (J * cos((K * 0.5))))); end
code[J_, l_, K_, U_] := N[(U + N[(2.0 * N[(l * N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U + 2 \cdot \left(\ell \cdot \left(J \cdot \cos \left(K \cdot 0.5\right)\right)\right)
\end{array}
Initial program 82.9%
Taylor expanded in l around 0 68.8%
*-commutative68.8%
associate-*l*68.9%
*-commutative68.9%
Simplified68.9%
Final simplification68.9%
(FPCore (J l K U) :precision binary64 (if (<= l -4.45e+15) (* U U) (if (<= l 600000000.0) U (* U (- U -8.0)))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4.45e+15) {
tmp = U * U;
} else if (l <= 600000000.0) {
tmp = U;
} else {
tmp = U * (U - -8.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 (l <= (-4.45d+15)) then
tmp = u * u
else if (l <= 600000000.0d0) then
tmp = u
else
tmp = u * (u - (-8.0d0))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -4.45e+15) {
tmp = U * U;
} else if (l <= 600000000.0) {
tmp = U;
} else {
tmp = U * (U - -8.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -4.45e+15: tmp = U * U elif l <= 600000000.0: tmp = U else: tmp = U * (U - -8.0) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -4.45e+15) tmp = Float64(U * U); elseif (l <= 600000000.0) tmp = U; else tmp = Float64(U * Float64(U - -8.0)); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -4.45e+15) tmp = U * U; elseif (l <= 600000000.0) tmp = U; else tmp = U * (U - -8.0); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -4.45e+15], N[(U * U), $MachinePrecision], If[LessEqual[l, 600000000.0], U, N[(U * N[(U - -8.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.45 \cdot 10^{+15}:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 600000000:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(U - -8\right)\\
\end{array}
\end{array}
if l < -4.45e15Initial program 100.0%
Applied egg-rr17.2%
if -4.45e15 < l < 6e8Initial program 69.7%
Taylor expanded in J around 0 67.1%
if 6e8 < l Initial program 100.0%
Applied egg-rr16.9%
Final simplification45.4%
(FPCore (J l K U) :precision binary64 (if (<= l -1.45e+16) (* U U) (if (<= l 600000000.0) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.45e+16) {
tmp = U * U;
} else if (l <= 600000000.0) {
tmp = U;
} else {
tmp = U * 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 <= (-1.45d+16)) then
tmp = u * u
else if (l <= 600000000.0d0) then
tmp = u
else
tmp = u * u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (l <= -1.45e+16) {
tmp = U * U;
} else if (l <= 600000000.0) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -1.45e+16: tmp = U * U elif l <= 600000000.0: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -1.45e+16) tmp = Float64(U * U); elseif (l <= 600000000.0) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -1.45e+16) tmp = U * U; elseif (l <= 600000000.0) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -1.45e+16], N[(U * U), $MachinePrecision], If[LessEqual[l, 600000000.0], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.45 \cdot 10^{+16}:\\
\;\;\;\;U \cdot U\\
\mathbf{elif}\;\ell \leq 600000000:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -1.45e16 or 6e8 < l Initial program 100.0%
Applied egg-rr17.0%
if -1.45e16 < l < 6e8Initial program 69.7%
Taylor expanded in J around 0 67.1%
Final simplification45.4%
(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 82.9%
Taylor expanded in l around 0 91.4%
Taylor expanded in l around 0 68.8%
*-commutative68.8%
*-commutative68.8%
associate-*r*68.8%
associate-*r*68.8%
*-commutative68.8%
associate-*l*68.9%
*-commutative68.9%
associate-*l*68.9%
*-commutative68.9%
Simplified68.9%
Taylor expanded in K around 0 59.5%
Final simplification59.5%
(FPCore (J l K U) :precision binary64 1.0)
double code(double J, double l, double K, double U) {
return 1.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 = 1.0d0
end function
public static double code(double J, double l, double K, double U) {
return 1.0;
}
def code(J, l, K, U): return 1.0
function code(J, l, K, U) return 1.0 end
function tmp = code(J, l, K, U) tmp = 1.0; end
code[J_, l_, K_, U_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 82.9%
Applied egg-rr3.0%
*-inverses3.0%
Simplified3.0%
Final simplification3.0%
(FPCore (J l K U) :precision binary64 U)
double code(double J, double l, double K, double U) {
return U;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
public static double code(double J, double l, double K, double U) {
return U;
}
def code(J, l, K, U): return U
function code(J, l, K, U) return U end
function tmp = code(J, l, K, U) tmp = U; end
code[J_, l_, K_, U_] := U
\begin{array}{l}
\\
U
\end{array}
Initial program 82.9%
Taylor expanded in J around 0 38.9%
Final simplification38.9%
herbie shell --seed 2023266
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))