
(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 2e-5)))
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(+
(* 0.016666666666666666 (* J (pow l 5.0)))
(+ (* 0.3333333333333333 (* J (pow l 3.0))) (* 2.0 (* l J)))))))))
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 <= 2e-5)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * ((0.016666666666666666 * (J * pow(l, 5.0))) + ((0.3333333333333333 * (J * pow(l, 3.0))) + (2.0 * (l * J)))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e-5)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * ((0.016666666666666666 * (J * Math.pow(l, 5.0))) + ((0.3333333333333333 * (J * Math.pow(l, 3.0))) + (2.0 * (l * J)))));
}
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 <= 2e-5): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * ((0.016666666666666666 * (J * math.pow(l, 5.0))) + ((0.3333333333333333 * (J * math.pow(l, 3.0))) + (2.0 * (l * J))))) 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 <= 2e-5)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(Float64(0.016666666666666666 * Float64(J * (l ^ 5.0))) + 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) t_0 = cos((K / 2.0)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 2e-5))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * ((0.016666666666666666 * (J * (l ^ 5.0))) + ((0.3333333333333333 * (J * (l ^ 3.0))) + (2.0 * (l * J))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e-5]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(J * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(l * J), $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 2 \cdot 10^{-5}\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right) + \left(0.3333333333333333 \cdot \left(J \cdot {\ell}^{3}\right) + 2 \cdot \left(\ell \cdot J\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 2.00000000000000016e-5 < (-.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))) < 2.00000000000000016e-5Initial program 71.3%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(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 2e-5)))
(+ (* (* t_1 J) t_0) U)
(+
U
(*
t_0
(*
J
(+
(* 0.016666666666666666 (pow l 5.0))
(+ (* 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 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e-5)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.016666666666666666 * pow(l, 5.0)) + ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.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 <= 2e-5)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((0.016666666666666666 * Math.pow(l, 5.0)) + ((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 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 2e-5): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * ((0.016666666666666666 * math.pow(l, 5.0)) + ((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(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e-5)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(Float64(0.016666666666666666 * (l ^ 5.0)) + 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 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 2e-5))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * ((0.016666666666666666 * (l ^ 5.0)) + ((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[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e-5]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.016666666666666666 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.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 2 \cdot 10^{-5}\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.016666666666666666 \cdot {\ell}^{5} + \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 2.00000000000000016e-5 < (-.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))) < 2.00000000000000016e-5Initial program 71.3%
Taylor expanded in l around 0 99.9%
Final simplification100.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e-5)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+
U
(*
J
(*
(+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0))
(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 <= 2e-5)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (J * (((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)) * 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 <= 2e-5)) {
tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + (J * (((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)) * 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 <= 2e-5): tmp = ((t_0 * J) * math.cos((K / 2.0))) + U else: tmp = U + (J * (((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)) * 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 <= 2e-5)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(J * Float64(Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)) * 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 <= 2e-5))) tmp = ((t_0 * J) * cos((K / 2.0))) + U; else tmp = U + (J * (((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)) * 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, 2e-5]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(J * N[(N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K * 0.5), $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 2 \cdot 10^{-5}\right):\\
\;\;\;\;\left(t_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right) \cdot \cos \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 2.00000000000000016e-5 < (-.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))) < 2.00000000000000016e-5Initial program 71.3%
Taylor expanded in l around 0 99.8%
Taylor expanded in J around 0 99.8%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))) (t_1 (+ U (* (* J (* l (pow K 2.0))) -0.25))))
(if (<= t_0 -0.96)
t_1
(if (<= t_0 -0.85) U (if (<= t_0 -0.35) t_1 (+ U (* J (* l 2.0))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = U + ((J * (l * pow(K, 2.0))) * -0.25);
double tmp;
if (t_0 <= -0.96) {
tmp = t_1;
} else if (t_0 <= -0.85) {
tmp = U;
} else if (t_0 <= -0.35) {
tmp = t_1;
} else {
tmp = U + (J * (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 + ((j * (l * (k ** 2.0d0))) * (-0.25d0))
if (t_0 <= (-0.96d0)) then
tmp = t_1
else if (t_0 <= (-0.85d0)) then
tmp = u
else if (t_0 <= (-0.35d0)) then
tmp = t_1
else
tmp = u + (j * (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 + ((J * (l * Math.pow(K, 2.0))) * -0.25);
double tmp;
if (t_0 <= -0.96) {
tmp = t_1;
} else if (t_0 <= -0.85) {
tmp = U;
} else if (t_0 <= -0.35) {
tmp = t_1;
} else {
tmp = U + (J * (l * 2.0));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K / 2.0)) t_1 = U + ((J * (l * math.pow(K, 2.0))) * -0.25) tmp = 0 if t_0 <= -0.96: tmp = t_1 elif t_0 <= -0.85: tmp = U elif t_0 <= -0.35: tmp = t_1 else: tmp = U + (J * (l * 2.0)) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(U + Float64(Float64(J * Float64(l * (K ^ 2.0))) * -0.25)) tmp = 0.0 if (t_0 <= -0.96) tmp = t_1; elseif (t_0 <= -0.85) tmp = U; elseif (t_0 <= -0.35) tmp = t_1; else tmp = Float64(U + Float64(J * 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 + ((J * (l * (K ^ 2.0))) * -0.25); tmp = 0.0; if (t_0 <= -0.96) tmp = t_1; elseif (t_0 <= -0.85) tmp = U; elseif (t_0 <= -0.35) tmp = t_1; else tmp = U + (J * (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[(N[(J * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.96], t$95$1, If[LessEqual[t$95$0, -0.85], U, If[LessEqual[t$95$0, -0.35], t$95$1, N[(U + N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := U + \left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\
\mathbf{if}\;t_0 \leq -0.96:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -0.85:\\
\;\;\;\;U\\
\mathbf{elif}\;t_0 \leq -0.35:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot 2\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K 2)) < -0.95999999999999996 or -0.849999999999999978 < (cos.f64 (/.f64 K 2)) < -0.34999999999999998Initial program 80.8%
Taylor expanded in l around 0 53.4%
*-commutative53.4%
associate-*l*53.3%
*-commutative53.3%
Simplified53.3%
Taylor expanded in K around 0 44.5%
Taylor expanded in K around inf 57.7%
*-commutative57.7%
*-commutative57.7%
Simplified57.7%
if -0.95999999999999996 < (cos.f64 (/.f64 K 2)) < -0.849999999999999978Initial program 73.9%
Taylor expanded in J around 0 54.9%
if -0.34999999999999998 < (cos.f64 (/.f64 K 2)) Initial program 88.8%
Taylor expanded in l around 0 60.2%
*-commutative60.2%
associate-*l*60.2%
*-commutative60.2%
Simplified60.2%
Taylor expanded in K around 0 55.9%
*-commutative55.9%
associate-*r*56.4%
Simplified56.4%
Final simplification56.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<= t_0 -0.96)
(+ U (* (* J (* l (pow K 2.0))) -0.25))
(if (<= t_0 0.21)
(+ U (* 2.0 (* J (* l (cos (* K 0.5))))))
(+ 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 tmp;
if (t_0 <= -0.96) {
tmp = U + ((J * (l * pow(K, 2.0))) * -0.25);
} else if (t_0 <= 0.21) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} 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) :: tmp
t_0 = cos((k / 2.0d0))
if (t_0 <= (-0.96d0)) then
tmp = u + ((j * (l * (k ** 2.0d0))) * (-0.25d0))
else if (t_0 <= 0.21d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
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 tmp;
if (t_0 <= -0.96) {
tmp = U + ((J * (l * Math.pow(K, 2.0))) * -0.25);
} else if (t_0 <= 0.21) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} 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)) tmp = 0 if t_0 <= -0.96: tmp = U + ((J * (l * math.pow(K, 2.0))) * -0.25) elif t_0 <= 0.21: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) 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)) tmp = 0.0 if (t_0 <= -0.96) tmp = Float64(U + Float64(Float64(J * Float64(l * (K ^ 2.0))) * -0.25)); elseif (t_0 <= 0.21) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); 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)); tmp = 0.0; if (t_0 <= -0.96) tmp = U + ((J * (l * (K ^ 2.0))) * -0.25); elseif (t_0 <= 0.21) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); 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]}, If[LessEqual[t$95$0, -0.96], N[(U + N[(N[(J * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.21], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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)\\
\mathbf{if}\;t_0 \leq -0.96:\\
\;\;\;\;U + \left(J \cdot \left(\ell \cdot {K}^{2}\right)\right) \cdot -0.25\\
\mathbf{elif}\;t_0 \leq 0.21:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\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.95999999999999996Initial program 80.7%
Taylor expanded in l around 0 32.4%
*-commutative32.4%
associate-*l*32.6%
*-commutative32.6%
Simplified32.6%
Taylor expanded in K around 0 61.3%
Taylor expanded in K around inf 80.5%
*-commutative80.5%
*-commutative80.5%
Simplified80.5%
if -0.95999999999999996 < (cos.f64 (/.f64 K 2)) < 0.209999999999999992Initial program 83.2%
Taylor expanded in l around 0 68.5%
if 0.209999999999999992 < (cos.f64 (/.f64 K 2)) Initial program 88.3%
Taylor expanded in l around 0 89.3%
Taylor expanded in K around 0 85.9%
Final simplification81.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* (* J 0.016666666666666666) (* (pow l 5.0) t_0))))
(t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -6.5e+65)
t_1
(if (<= l -2.3)
t_2
(if (<= l 0.0135)
(+ U (* J (* (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)) t_0)))
(if (<= l 2.8e+60) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U + ((J * 0.016666666666666666) * (pow(l, 5.0) * t_0));
double t_2 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -6.5e+65) {
tmp = t_1;
} else if (l <= -2.3) {
tmp = t_2;
} else if (l <= 0.0135) {
tmp = U + (J * (((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0)) * t_0));
} else if (l <= 2.8e+60) {
tmp = t_2;
} else {
tmp = t_1;
}
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) :: t_2
real(8) :: tmp
t_0 = cos((k * 0.5d0))
t_1 = u + ((j * 0.016666666666666666d0) * ((l ** 5.0d0) * t_0))
t_2 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-6.5d+65)) then
tmp = t_1
else if (l <= (-2.3d0)) then
tmp = t_2
else if (l <= 0.0135d0) then
tmp = u + (j * (((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0)) * t_0))
else if (l <= 2.8d+60) then
tmp = t_2
else
tmp = t_1
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 t_1 = U + ((J * 0.016666666666666666) * (Math.pow(l, 5.0) * t_0));
double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -6.5e+65) {
tmp = t_1;
} else if (l <= -2.3) {
tmp = t_2;
} else if (l <= 0.0135) {
tmp = U + (J * (((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0)) * t_0));
} else if (l <= 2.8e+60) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = U + ((J * 0.016666666666666666) * (math.pow(l, 5.0) * t_0)) t_2 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -6.5e+65: tmp = t_1 elif l <= -2.3: tmp = t_2 elif l <= 0.0135: tmp = U + (J * (((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)) * t_0)) elif l <= 2.8e+60: tmp = t_2 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U + Float64(Float64(J * 0.016666666666666666) * Float64((l ^ 5.0) * t_0))) t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -6.5e+65) tmp = t_1; elseif (l <= -2.3) tmp = t_2; elseif (l <= 0.0135) tmp = Float64(U + Float64(J * Float64(Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0)) * t_0))); elseif (l <= 2.8e+60) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K * 0.5)); t_1 = U + ((J * 0.016666666666666666) * ((l ^ 5.0) * t_0)); t_2 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -6.5e+65) tmp = t_1; elseif (l <= -2.3) tmp = t_2; elseif (l <= 0.0135) tmp = U + (J * (((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)) * t_0)); elseif (l <= 2.8e+60) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(J * 0.016666666666666666), $MachinePrecision] * N[(N[Power[l, 5.0], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -6.5e+65], t$95$1, If[LessEqual[l, -2.3], t$95$2, If[LessEqual[l, 0.0135], N[(U + N[(J * N[(N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.8e+60], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + \left(J \cdot 0.016666666666666666\right) \cdot \left({\ell}^{5} \cdot t_0\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -6.5 \cdot 10^{+65}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -2.3:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq 0.0135:\\
\;\;\;\;U + J \cdot \left(\left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\right) \cdot t_0\right)\\
\mathbf{elif}\;\ell \leq 2.8 \cdot 10^{+60}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -6.5000000000000003e65 or 2.8e60 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
associate-*r*100.0%
Simplified100.0%
if -6.5000000000000003e65 < l < -2.2999999999999998 or 0.0134999999999999998 < l < 2.8e60Initial program 100.0%
Taylor expanded in K around 0 100.0%
if -2.2999999999999998 < l < 0.0134999999999999998Initial program 71.3%
Taylor expanded in l around 0 99.8%
Taylor expanded in J around 0 99.8%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* (* J 0.016666666666666666) (* (pow l 5.0) t_0))))
(t_2 (+ (* (- (exp l) (exp (- l))) J) U)))
(if (<= l -6.5e+65)
t_1
(if (<= l -0.00082)
t_2
(if (<= l 0.0072)
(+ U (* 2.0 (* J (* l t_0))))
(if (<= l 2.6e+60) t_2 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U + ((J * 0.016666666666666666) * (pow(l, 5.0) * t_0));
double t_2 = ((exp(l) - exp(-l)) * J) + U;
double tmp;
if (l <= -6.5e+65) {
tmp = t_1;
} else if (l <= -0.00082) {
tmp = t_2;
} else if (l <= 0.0072) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 2.6e+60) {
tmp = t_2;
} else {
tmp = t_1;
}
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) :: t_2
real(8) :: tmp
t_0 = cos((k * 0.5d0))
t_1 = u + ((j * 0.016666666666666666d0) * ((l ** 5.0d0) * t_0))
t_2 = ((exp(l) - exp(-l)) * j) + u
if (l <= (-6.5d+65)) then
tmp = t_1
else if (l <= (-0.00082d0)) then
tmp = t_2
else if (l <= 0.0072d0) then
tmp = u + (2.0d0 * (j * (l * t_0)))
else if (l <= 2.6d+60) then
tmp = t_2
else
tmp = t_1
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 t_1 = U + ((J * 0.016666666666666666) * (Math.pow(l, 5.0) * t_0));
double t_2 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double tmp;
if (l <= -6.5e+65) {
tmp = t_1;
} else if (l <= -0.00082) {
tmp = t_2;
} else if (l <= 0.0072) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 2.6e+60) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = U + ((J * 0.016666666666666666) * (math.pow(l, 5.0) * t_0)) t_2 = ((math.exp(l) - math.exp(-l)) * J) + U tmp = 0 if l <= -6.5e+65: tmp = t_1 elif l <= -0.00082: tmp = t_2 elif l <= 0.0072: tmp = U + (2.0 * (J * (l * t_0))) elif l <= 2.6e+60: tmp = t_2 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U + Float64(Float64(J * 0.016666666666666666) * Float64((l ^ 5.0) * t_0))) t_2 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) tmp = 0.0 if (l <= -6.5e+65) tmp = t_1; elseif (l <= -0.00082) tmp = t_2; elseif (l <= 0.0072) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_0)))); elseif (l <= 2.6e+60) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = cos((K * 0.5)); t_1 = U + ((J * 0.016666666666666666) * ((l ^ 5.0) * t_0)); t_2 = ((exp(l) - exp(-l)) * J) + U; tmp = 0.0; if (l <= -6.5e+65) tmp = t_1; elseif (l <= -0.00082) tmp = t_2; elseif (l <= 0.0072) tmp = U + (2.0 * (J * (l * t_0))); elseif (l <= 2.6e+60) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(U + N[(N[(J * 0.016666666666666666), $MachinePrecision] * N[(N[Power[l, 5.0], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, If[LessEqual[l, -6.5e+65], t$95$1, If[LessEqual[l, -0.00082], t$95$2, If[LessEqual[l, 0.0072], N[(U + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.6e+60], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + \left(J \cdot 0.016666666666666666\right) \cdot \left({\ell}^{5} \cdot t_0\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{if}\;\ell \leq -6.5 \cdot 10^{+65}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -0.00082:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq 0.0072:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t_0\right)\right)\\
\mathbf{elif}\;\ell \leq 2.6 \cdot 10^{+60}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -6.5000000000000003e65 or 2.60000000000000008e60 < l Initial program 100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in l around inf 100.0%
associate-*r*100.0%
Simplified100.0%
if -6.5000000000000003e65 < l < -8.1999999999999998e-4 or 0.0071999999999999998 < l < 2.60000000000000008e60Initial program 99.6%
Taylor expanded in K around 0 99.6%
if -8.1999999999999998e-4 < l < 0.0071999999999999998Initial program 70.9%
Taylor expanded in l around 0 99.3%
Final simplification99.6%
(FPCore (J l K U) :precision binary64 (if (or (<= l -0.00102) (not (<= l 0.00098))) (+ (* (- (exp l) (exp (- l))) J) U) (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -0.00102) || !(l <= 0.00098)) {
tmp = ((exp(l) - exp(-l)) * 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) :: tmp
if ((l <= (-0.00102d0)) .or. (.not. (l <= 0.00098d0))) then
tmp = ((exp(l) - exp(-l)) * 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 tmp;
if ((l <= -0.00102) || !(l <= 0.00098)) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -0.00102) or not (l <= 0.00098): tmp = ((math.exp(l) - math.exp(-l)) * J) + U else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -0.00102) || !(l <= 0.00098)) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * 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) tmp = 0.0; if ((l <= -0.00102) || ~((l <= 0.00098))) tmp = ((exp(l) - exp(-l)) * J) + U; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -0.00102], N[Not[LessEqual[l, 0.00098]], $MachinePrecision]], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * 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}
\mathbf{if}\;\ell \leq -0.00102 \lor \neg \left(\ell \leq 0.00098\right):\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \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 l < -0.00102 or 9.7999999999999997e-4 < l Initial program 99.9%
Taylor expanded in K around 0 80.1%
if -0.00102 < l < 9.7999999999999997e-4Initial program 70.9%
Taylor expanded in l around 0 99.3%
Final simplification88.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l 5e+31) (not (<= l 3.2e+181))) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (pow U -4.0)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= 5e+31) || !(l <= 3.2e+181)) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = pow(U, -4.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 <= 5d+31) .or. (.not. (l <= 3.2d+181))) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u ** (-4.0d0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= 5e+31) || !(l <= 3.2e+181)) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = Math.pow(U, -4.0);
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= 5e+31) or not (l <= 3.2e+181): tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = math.pow(U, -4.0) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= 5e+31) || !(l <= 3.2e+181)) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = U ^ -4.0; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= 5e+31) || ~((l <= 3.2e+181))) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U ^ -4.0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, 5e+31], N[Not[LessEqual[l, 3.2e+181]], $MachinePrecision]], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[U, -4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 5 \cdot 10^{+31} \lor \neg \left(\ell \leq 3.2 \cdot 10^{+181}\right):\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{U}^{-4}\\
\end{array}
\end{array}
if l < 5.00000000000000027e31 or 3.2e181 < l Initial program 84.7%
Taylor expanded in l around 0 67.2%
if 5.00000000000000027e31 < l < 3.2e181Initial program 100.0%
Applied egg-rr45.3%
Final simplification64.2%
(FPCore (J l K U)
:precision binary64
(if (<= l 1e+31)
(+ U (* (cos (/ K 2.0)) (* J (* l 2.0))))
(if (<= l 9.5e+180)
(pow U -4.0)
(+ U (* 2.0 (* J (* l (cos (* K 0.5)))))))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= 1e+31) {
tmp = U + (cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 9.5e+180) {
tmp = pow(U, -4.0);
} 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) :: tmp
if (l <= 1d+31) then
tmp = u + (cos((k / 2.0d0)) * (j * (l * 2.0d0)))
else if (l <= 9.5d+180) then
tmp = u ** (-4.0d0)
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 tmp;
if (l <= 1e+31) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * 2.0)));
} else if (l <= 9.5e+180) {
tmp = Math.pow(U, -4.0);
} else {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= 1e+31: tmp = U + (math.cos((K / 2.0)) * (J * (l * 2.0))) elif l <= 9.5e+180: tmp = math.pow(U, -4.0) else: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= 1e+31) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * 2.0)))); elseif (l <= 9.5e+180) tmp = U ^ -4.0; 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) tmp = 0.0; if (l <= 1e+31) tmp = U + (cos((K / 2.0)) * (J * (l * 2.0))); elseif (l <= 9.5e+180) tmp = U ^ -4.0; else tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, 1e+31], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 9.5e+180], N[Power[U, -4.0], $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}
\mathbf{if}\;\ell \leq 10^{+31}:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot 2\right)\right)\\
\mathbf{elif}\;\ell \leq 9.5 \cdot 10^{+180}:\\
\;\;\;\;{U}^{-4}\\
\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 l < 9.9999999999999996e30Initial program 83.0%
Taylor expanded in l around 0 70.6%
*-commutative70.6%
associate-*r*71.1%
Simplified71.1%
if 9.9999999999999996e30 < l < 9.5000000000000003e180Initial program 100.0%
Applied egg-rr45.3%
if 9.5000000000000003e180 < l Initial program 100.0%
Taylor expanded in l around 0 38.2%
Final simplification64.5%
(FPCore (J l K U) :precision binary64 (if (or (<= l -7.8e+28) (not (<= l 1220.0))) (* U (- U -4.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7.8e+28) || !(l <= 1220.0)) {
tmp = U * (U - -4.0);
} else {
tmp = U;
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if ((l <= (-7.8d+28)) .or. (.not. (l <= 1220.0d0))) then
tmp = u * (u - (-4.0d0))
else
tmp = u
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7.8e+28) || !(l <= 1220.0)) {
tmp = U * (U - -4.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -7.8e+28) or not (l <= 1220.0): tmp = U * (U - -4.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -7.8e+28) || !(l <= 1220.0)) tmp = Float64(U * Float64(U - -4.0)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -7.8e+28) || ~((l <= 1220.0))) tmp = U * (U - -4.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7.8e+28], N[Not[LessEqual[l, 1220.0]], $MachinePrecision]], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.8 \cdot 10^{+28} \lor \neg \left(\ell \leq 1220\right):\\
\;\;\;\;U \cdot \left(U - -4\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -7.7999999999999997e28 or 1220 < l Initial program 100.0%
Applied egg-rr20.1%
if -7.7999999999999997e28 < l < 1220Initial program 72.9%
Taylor expanded in J around 0 65.0%
Final simplification41.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -65000000000.0) (not (<= l 720.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -65000000000.0) || !(l <= 720.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 <= (-65000000000.0d0)) .or. (.not. (l <= 720.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 <= -65000000000.0) || !(l <= 720.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -65000000000.0) or not (l <= 720.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -65000000000.0) || !(l <= 720.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 <= -65000000000.0) || ~((l <= 720.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -65000000000.0], N[Not[LessEqual[l, 720.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -65000000000 \lor \neg \left(\ell \leq 720\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -6.5e10 or 720 < l Initial program 100.0%
Applied egg-rr19.5%
if -6.5e10 < l < 720Initial program 72.0%
Taylor expanded in J around 0 67.1%
Final simplification41.8%
(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 86.9%
Taylor expanded in l around 0 60.5%
*-commutative60.5%
associate-*l*60.5%
*-commutative60.5%
Simplified60.5%
Taylor expanded in K around 0 50.4%
*-commutative50.4%
associate-*r*50.8%
Simplified50.8%
Final simplification50.8%
(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 86.9%
Applied egg-rr2.7%
*-inverses2.7%
Simplified2.7%
Final simplification2.7%
(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 86.9%
Taylor expanded in J around 0 32.6%
Final simplification32.6%
herbie shell --seed 2023336
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))