
(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 14 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 0.5))) (t_1 (- (exp l) (exp (- l)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 0.04)))
(+ (* (* t_1 J) (cos (/ K 2.0))) U)
(+
U
(+
(* 0.0003968253968253968 (* J (* (pow l 7.0) t_0)))
(+
(* 0.016666666666666666 (* J (* t_0 (pow l 5.0))))
(+
(* 0.3333333333333333 (* J (* t_0 (pow l 3.0))))
(* 2.0 (* J (* l t_0))))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 0.04)) {
tmp = ((t_1 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + ((0.0003968253968253968 * (J * (pow(l, 7.0) * t_0))) + ((0.016666666666666666 * (J * (t_0 * pow(l, 5.0)))) + ((0.3333333333333333 * (J * (t_0 * pow(l, 3.0)))) + (2.0 * (J * (l * t_0))))));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = Math.cos((K * 0.5));
double t_1 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 0.04)) {
tmp = ((t_1 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + ((0.0003968253968253968 * (J * (Math.pow(l, 7.0) * t_0))) + ((0.016666666666666666 * (J * (t_0 * Math.pow(l, 5.0)))) + ((0.3333333333333333 * (J * (t_0 * Math.pow(l, 3.0)))) + (2.0 * (J * (l * t_0))))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 0.04): tmp = ((t_1 * J) * math.cos((K / 2.0))) + U else: tmp = U + ((0.0003968253968253968 * (J * (math.pow(l, 7.0) * t_0))) + ((0.016666666666666666 * (J * (t_0 * math.pow(l, 5.0)))) + ((0.3333333333333333 * (J * (t_0 * math.pow(l, 3.0)))) + (2.0 * (J * (l * t_0)))))) return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 0.04)) tmp = Float64(Float64(Float64(t_1 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(Float64(0.0003968253968253968 * Float64(J * Float64((l ^ 7.0) * t_0))) + Float64(Float64(0.016666666666666666 * Float64(J * Float64(t_0 * (l ^ 5.0)))) + Float64(Float64(0.3333333333333333 * Float64(J * Float64(t_0 * (l ^ 3.0)))) + 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)); t_1 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 0.04))) tmp = ((t_1 * J) * cos((K / 2.0))) + U; else tmp = U + ((0.0003968253968253968 * (J * ((l ^ 7.0) * t_0))) + ((0.016666666666666666 * (J * (t_0 * (l ^ 5.0)))) + ((0.3333333333333333 * (J * (t_0 * (l ^ 3.0)))) + (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]}, 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.04]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(N[(0.0003968253968253968 * N[(J * N[(N[Power[l, 7.0], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.016666666666666666 * N[(J * N[(t$95$0 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(0.3333333333333333 * N[(J * N[(t$95$0 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 0.04\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \left(0.0003968253968253968 \cdot \left(J \cdot \left({\ell}^{7} \cdot t_0\right)\right) + \left(0.016666666666666666 \cdot \left(J \cdot \left(t_0 \cdot {\ell}^{5}\right)\right) + \left(0.3333333333333333 \cdot \left(J \cdot \left(t_0 \cdot {\ell}^{3}\right)\right) + 2 \cdot \left(J \cdot \left(\ell \cdot t_0\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 0.0400000000000000008 < (-.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.0400000000000000008Initial program 78.6%
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 0.04)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+
U
(*
J
(*
(cos (* K 0.5))
(+
(* 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 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.04)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (J * (cos((K * 0.5)) * ((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.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 0.04)) {
tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + (J * (Math.cos((K * 0.5)) * ((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.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 0.04): tmp = ((t_0 * J) * math.cos((K / 2.0))) + U else: tmp = U + (J * (math.cos((K * 0.5)) * ((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 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.04)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(J * Float64(cos(Float64(K * 0.5)) * 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 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 0.04))) tmp = ((t_0 * J) * cos((K / 2.0))) + U; else tmp = U + (J * (cos((K * 0.5)) * ((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[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 0.04]], $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[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * 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 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 0.04\right):\\
\;\;\;\;\left(t_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\cos \left(K \cdot 0.5\right) \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 0.0400000000000000008 < (-.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.0400000000000000008Initial program 78.6%
associate-*l*78.6%
fma-def78.6%
Simplified78.6%
Taylor expanded in l around 0 99.9%
Taylor expanded in J 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 0.0)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+
U
(*
J
(* (cos (* K 0.5)) (fma 2.0 l (* 0.3333333333333333 (pow l 3.0)))))))))
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 = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (J * (cos((K * 0.5)) * fma(2.0, l, (0.3333333333333333 * pow(l, 3.0)))));
}
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(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(J * Float64(cos(Float64(K * 0.5)) * fma(2.0, l, Float64(0.3333333333333333 * (l ^ 3.0)))))); end return 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[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(2.0 * l + N[(0.3333333333333333 * N[Power[l, 3.0], $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):\\
\;\;\;\;\left(t_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \mathsf{fma}\left(2, \ell, 0.3333333333333333 \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 78.3%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
+-commutative99.9%
*-commutative99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(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_1 J) t_0) U)
(+ U (* t_0 (* 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 = exp(l) - exp(-l);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * ((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 <= 0.0)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (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 = math.exp(l) - math.exp(-l) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 0.0): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (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(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 0.0)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * 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 = exp(l) - exp(-l); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 0.0))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (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[(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[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(N[(0.3333333333333333 * N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision] + N[(l * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 0\right):\\
\;\;\;\;\left(t_1 \cdot J\right) \cdot t_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t_0 \cdot \left(J \cdot \left(0.3333333333333333 \cdot {\ell}^{3} + \ell \cdot 2\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 78.3%
Taylor expanded in l around 0 99.8%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (- (exp l) (exp (- l))) J) U))
(t_1 (* (* (cos (* K 0.5)) (pow l 5.0)) (* J 0.016666666666666666))))
(if (<= l -1.1e+58)
t_1
(if (<= l -850.0)
t_0
(if (<= l 0.35)
(+
U
(*
(cos (/ K 2.0))
(* J (+ (* 0.3333333333333333 (pow l 3.0)) (* l 2.0)))))
(if (<= l 2.45e+61) t_0 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = ((exp(l) - exp(-l)) * J) + U;
double t_1 = (cos((K * 0.5)) * pow(l, 5.0)) * (J * 0.016666666666666666);
double tmp;
if (l <= -1.1e+58) {
tmp = t_1;
} else if (l <= -850.0) {
tmp = t_0;
} else if (l <= 0.35) {
tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 2.45e+61) {
tmp = t_0;
} 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) :: tmp
t_0 = ((exp(l) - exp(-l)) * j) + u
t_1 = (cos((k * 0.5d0)) * (l ** 5.0d0)) * (j * 0.016666666666666666d0)
if (l <= (-1.1d+58)) then
tmp = t_1
else if (l <= (-850.0d0)) then
tmp = t_0
else if (l <= 0.35d0) then
tmp = u + (cos((k / 2.0d0)) * (j * ((0.3333333333333333d0 * (l ** 3.0d0)) + (l * 2.0d0))))
else if (l <= 2.45d+61) then
tmp = t_0
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.exp(l) - Math.exp(-l)) * J) + U;
double t_1 = (Math.cos((K * 0.5)) * Math.pow(l, 5.0)) * (J * 0.016666666666666666);
double tmp;
if (l <= -1.1e+58) {
tmp = t_1;
} else if (l <= -850.0) {
tmp = t_0;
} else if (l <= 0.35) {
tmp = U + (Math.cos((K / 2.0)) * (J * ((0.3333333333333333 * Math.pow(l, 3.0)) + (l * 2.0))));
} else if (l <= 2.45e+61) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = ((math.exp(l) - math.exp(-l)) * J) + U t_1 = (math.cos((K * 0.5)) * math.pow(l, 5.0)) * (J * 0.016666666666666666) tmp = 0 if l <= -1.1e+58: tmp = t_1 elif l <= -850.0: tmp = t_0 elif l <= 0.35: tmp = U + (math.cos((K / 2.0)) * (J * ((0.3333333333333333 * math.pow(l, 3.0)) + (l * 2.0)))) elif l <= 2.45e+61: tmp = t_0 else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) t_1 = Float64(Float64(cos(Float64(K * 0.5)) * (l ^ 5.0)) * Float64(J * 0.016666666666666666)) tmp = 0.0 if (l <= -1.1e+58) tmp = t_1; elseif (l <= -850.0) tmp = t_0; elseif (l <= 0.35) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(Float64(0.3333333333333333 * (l ^ 3.0)) + Float64(l * 2.0))))); elseif (l <= 2.45e+61) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = ((exp(l) - exp(-l)) * J) + U; t_1 = (cos((K * 0.5)) * (l ^ 5.0)) * (J * 0.016666666666666666); tmp = 0.0; if (l <= -1.1e+58) tmp = t_1; elseif (l <= -850.0) tmp = t_0; elseif (l <= 0.35) tmp = U + (cos((K / 2.0)) * (J * ((0.3333333333333333 * (l ^ 3.0)) + (l * 2.0)))); elseif (l <= 2.45e+61) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.1e+58], t$95$1, If[LessEqual[l, -850.0], t$95$0, If[LessEqual[l, 0.35], 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, 2.45e+61], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
t_1 := \left(\cos \left(K \cdot 0.5\right) \cdot {\ell}^{5}\right) \cdot \left(J \cdot 0.016666666666666666\right)\\
\mathbf{if}\;\ell \leq -1.1 \cdot 10^{+58}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\ell \leq -850:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 0.35:\\
\;\;\;\;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 2.45 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if l < -1.1e58 or 2.45000000000000013e61 < l Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in l around 0 99.1%
Taylor expanded in l around inf 99.1%
*-commutative99.1%
*-commutative99.1%
associate-*l*99.1%
Simplified99.1%
if -1.1e58 < l < -850 or 0.34999999999999998 < l < 2.45000000000000013e61Initial program 100.0%
Taylor expanded in K around 0 74.2%
if -850 < l < 0.34999999999999998Initial program 78.8%
Taylor expanded in l around 0 98.8%
Final simplification95.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (- (exp l) (exp (- l))) J) U))
(t_1 (cos (* K 0.5)))
(t_2 (* (* t_1 (pow l 5.0)) (* J 0.016666666666666666))))
(if (<= l -1.02e+58)
t_2
(if (<= l -850.0)
t_0
(if (<= l 0.0145)
(+ U (* 2.0 (* J (* l t_1))))
(if (<= l 4.45e+61) t_0 t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = ((exp(l) - exp(-l)) * J) + U;
double t_1 = cos((K * 0.5));
double t_2 = (t_1 * pow(l, 5.0)) * (J * 0.016666666666666666);
double tmp;
if (l <= -1.02e+58) {
tmp = t_2;
} else if (l <= -850.0) {
tmp = t_0;
} else if (l <= 0.0145) {
tmp = U + (2.0 * (J * (l * t_1)));
} else if (l <= 4.45e+61) {
tmp = t_0;
} else {
tmp = t_2;
}
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 = ((exp(l) - exp(-l)) * j) + u
t_1 = cos((k * 0.5d0))
t_2 = (t_1 * (l ** 5.0d0)) * (j * 0.016666666666666666d0)
if (l <= (-1.02d+58)) then
tmp = t_2
else if (l <= (-850.0d0)) then
tmp = t_0
else if (l <= 0.0145d0) then
tmp = u + (2.0d0 * (j * (l * t_1)))
else if (l <= 4.45d+61) then
tmp = t_0
else
tmp = t_2
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)) * J) + U;
double t_1 = Math.cos((K * 0.5));
double t_2 = (t_1 * Math.pow(l, 5.0)) * (J * 0.016666666666666666);
double tmp;
if (l <= -1.02e+58) {
tmp = t_2;
} else if (l <= -850.0) {
tmp = t_0;
} else if (l <= 0.0145) {
tmp = U + (2.0 * (J * (l * t_1)));
} else if (l <= 4.45e+61) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(J, l, K, U): t_0 = ((math.exp(l) - math.exp(-l)) * J) + U t_1 = math.cos((K * 0.5)) t_2 = (t_1 * math.pow(l, 5.0)) * (J * 0.016666666666666666) tmp = 0 if l <= -1.02e+58: tmp = t_2 elif l <= -850.0: tmp = t_0 elif l <= 0.0145: tmp = U + (2.0 * (J * (l * t_1))) elif l <= 4.45e+61: tmp = t_0 else: tmp = t_2 return tmp
function code(J, l, K, U) t_0 = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U) t_1 = cos(Float64(K * 0.5)) t_2 = Float64(Float64(t_1 * (l ^ 5.0)) * Float64(J * 0.016666666666666666)) tmp = 0.0 if (l <= -1.02e+58) tmp = t_2; elseif (l <= -850.0) tmp = t_0; elseif (l <= 0.0145) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_1)))); elseif (l <= 4.45e+61) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = ((exp(l) - exp(-l)) * J) + U; t_1 = cos((K * 0.5)); t_2 = (t_1 * (l ^ 5.0)) * (J * 0.016666666666666666); tmp = 0.0; if (l <= -1.02e+58) tmp = t_2; elseif (l <= -850.0) tmp = t_0; elseif (l <= 0.0145) tmp = U + (2.0 * (J * (l * t_1))); elseif (l <= 4.45e+61) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.02e+58], t$95$2, If[LessEqual[l, -850.0], t$95$0, If[LessEqual[l, 0.0145], N[(U + N[(2.0 * N[(J * N[(l * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.45e+61], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
t_1 := \cos \left(K \cdot 0.5\right)\\
t_2 := \left(t_1 \cdot {\ell}^{5}\right) \cdot \left(J \cdot 0.016666666666666666\right)\\
\mathbf{if}\;\ell \leq -1.02 \cdot 10^{+58}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\ell \leq -850:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 0.0145:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t_1\right)\right)\\
\mathbf{elif}\;\ell \leq 4.45 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if l < -1.02000000000000005e58 or 4.45000000000000002e61 < l Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in l around 0 99.1%
Taylor expanded in l around inf 99.1%
*-commutative99.1%
*-commutative99.1%
associate-*l*99.1%
Simplified99.1%
if -1.02000000000000005e58 < l < -850 or 0.0145000000000000007 < l < 4.45000000000000002e61Initial program 100.0%
Taylor expanded in K around 0 74.2%
if -850 < l < 0.0145000000000000007Initial program 78.8%
Taylor expanded in l around 0 98.3%
Final simplification95.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -850.0) (not (<= l 0.0128))) (+ (* (- (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 <= -850.0) || !(l <= 0.0128)) {
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 <= (-850.0d0)) .or. (.not. (l <= 0.0128d0))) 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 <= -850.0) || !(l <= 0.0128)) {
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 <= -850.0) or not (l <= 0.0128): 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 <= -850.0) || !(l <= 0.0128)) 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 <= -850.0) || ~((l <= 0.0128))) 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, -850.0], N[Not[LessEqual[l, 0.0128]], $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 -850 \lor \neg \left(\ell \leq 0.0128\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 < -850 or 0.0128000000000000006 < l Initial program 100.0%
Taylor expanded in K around 0 74.1%
if -850 < l < 0.0128000000000000006Initial program 78.8%
Taylor expanded in l around 0 98.3%
Final simplification85.5%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ U (* 2.0 (* J (* l (cos (* K 0.5))))))))
(if (<= l -5.2e+164)
t_0
(if (<= l -9.5e+33)
(pow U -3.0)
(if (or (<= l 980.0) (not (<= l 1.7e+226))) t_0 (log1p (expm1 U)))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (2.0 * (J * (l * cos((K * 0.5)))));
double tmp;
if (l <= -5.2e+164) {
tmp = t_0;
} else if (l <= -9.5e+33) {
tmp = pow(U, -3.0);
} else if ((l <= 980.0) || !(l <= 1.7e+226)) {
tmp = t_0;
} else {
tmp = log1p(expm1(U));
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
double tmp;
if (l <= -5.2e+164) {
tmp = t_0;
} else if (l <= -9.5e+33) {
tmp = Math.pow(U, -3.0);
} else if ((l <= 980.0) || !(l <= 1.7e+226)) {
tmp = t_0;
} else {
tmp = Math.log1p(Math.expm1(U));
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (2.0 * (J * (l * math.cos((K * 0.5))))) tmp = 0 if l <= -5.2e+164: tmp = t_0 elif l <= -9.5e+33: tmp = math.pow(U, -3.0) elif (l <= 980.0) or not (l <= 1.7e+226): tmp = t_0 else: tmp = math.log1p(math.expm1(U)) return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))) tmp = 0.0 if (l <= -5.2e+164) tmp = t_0; elseif (l <= -9.5e+33) tmp = U ^ -3.0; elseif ((l <= 980.0) || !(l <= 1.7e+226)) tmp = t_0; else tmp = log1p(expm1(U)); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5.2e+164], t$95$0, If[LessEqual[l, -9.5e+33], N[Power[U, -3.0], $MachinePrecision], If[Or[LessEqual[l, 980.0], N[Not[LessEqual[l, 1.7e+226]], $MachinePrecision]], t$95$0, N[Log[1 + N[(Exp[U] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{if}\;\ell \leq -5.2 \cdot 10^{+164}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -9.5 \cdot 10^{+33}:\\
\;\;\;\;{U}^{-3}\\
\mathbf{elif}\;\ell \leq 980 \lor \neg \left(\ell \leq 1.7 \cdot 10^{+226}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(U\right)\right)\\
\end{array}
\end{array}
if l < -5.1999999999999998e164 or -9.5000000000000003e33 < l < 980 or 1.69999999999999989e226 < l Initial program 84.9%
Taylor expanded in l around 0 84.7%
if -5.1999999999999998e164 < l < -9.5000000000000003e33Initial program 100.0%
Applied egg-rr35.6%
if 980 < l < 1.69999999999999989e226Initial program 100.0%
Applied egg-rr37.4%
Final simplification68.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- -4.0 (* U U))))
(if (<= l -2.05e+104)
t_0
(if (<= l -2.5e+40)
(pow U -3.0)
(if (<= l -820.0)
t_0
(if (<= l 7200000.0)
U
(if (or (<= l 2.9e+119) (not (<= l 8.2e+174)))
(* U U)
(pow U -3.0))))))))
double code(double J, double l, double K, double U) {
double t_0 = -4.0 - (U * U);
double tmp;
if (l <= -2.05e+104) {
tmp = t_0;
} else if (l <= -2.5e+40) {
tmp = pow(U, -3.0);
} else if (l <= -820.0) {
tmp = t_0;
} else if (l <= 7200000.0) {
tmp = U;
} else if ((l <= 2.9e+119) || !(l <= 8.2e+174)) {
tmp = U * U;
} else {
tmp = pow(U, -3.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 = (-4.0d0) - (u * u)
if (l <= (-2.05d+104)) then
tmp = t_0
else if (l <= (-2.5d+40)) then
tmp = u ** (-3.0d0)
else if (l <= (-820.0d0)) then
tmp = t_0
else if (l <= 7200000.0d0) then
tmp = u
else if ((l <= 2.9d+119) .or. (.not. (l <= 8.2d+174))) then
tmp = u * u
else
tmp = u ** (-3.0d0)
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = -4.0 - (U * U);
double tmp;
if (l <= -2.05e+104) {
tmp = t_0;
} else if (l <= -2.5e+40) {
tmp = Math.pow(U, -3.0);
} else if (l <= -820.0) {
tmp = t_0;
} else if (l <= 7200000.0) {
tmp = U;
} else if ((l <= 2.9e+119) || !(l <= 8.2e+174)) {
tmp = U * U;
} else {
tmp = Math.pow(U, -3.0);
}
return tmp;
}
def code(J, l, K, U): t_0 = -4.0 - (U * U) tmp = 0 if l <= -2.05e+104: tmp = t_0 elif l <= -2.5e+40: tmp = math.pow(U, -3.0) elif l <= -820.0: tmp = t_0 elif l <= 7200000.0: tmp = U elif (l <= 2.9e+119) or not (l <= 8.2e+174): tmp = U * U else: tmp = math.pow(U, -3.0) return tmp
function code(J, l, K, U) t_0 = Float64(-4.0 - Float64(U * U)) tmp = 0.0 if (l <= -2.05e+104) tmp = t_0; elseif (l <= -2.5e+40) tmp = U ^ -3.0; elseif (l <= -820.0) tmp = t_0; elseif (l <= 7200000.0) tmp = U; elseif ((l <= 2.9e+119) || !(l <= 8.2e+174)) tmp = Float64(U * U); else tmp = U ^ -3.0; end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = -4.0 - (U * U); tmp = 0.0; if (l <= -2.05e+104) tmp = t_0; elseif (l <= -2.5e+40) tmp = U ^ -3.0; elseif (l <= -820.0) tmp = t_0; elseif (l <= 7200000.0) tmp = U; elseif ((l <= 2.9e+119) || ~((l <= 8.2e+174))) tmp = U * U; else tmp = U ^ -3.0; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(-4.0 - N[(U * U), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -2.05e+104], t$95$0, If[LessEqual[l, -2.5e+40], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, -820.0], t$95$0, If[LessEqual[l, 7200000.0], U, If[Or[LessEqual[l, 2.9e+119], N[Not[LessEqual[l, 8.2e+174]], $MachinePrecision]], N[(U * U), $MachinePrecision], N[Power[U, -3.0], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 - U \cdot U\\
\mathbf{if}\;\ell \leq -2.05 \cdot 10^{+104}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -2.5 \cdot 10^{+40}:\\
\;\;\;\;{U}^{-3}\\
\mathbf{elif}\;\ell \leq -820:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 7200000:\\
\;\;\;\;U\\
\mathbf{elif}\;\ell \leq 2.9 \cdot 10^{+119} \lor \neg \left(\ell \leq 8.2 \cdot 10^{+174}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;{U}^{-3}\\
\end{array}
\end{array}
if l < -2.04999999999999992e104 or -2.50000000000000002e40 < l < -820Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr29.6%
cancel-sign-sub-inv29.6%
Simplified29.6%
if -2.04999999999999992e104 < l < -2.50000000000000002e40 or 2.90000000000000007e119 < l < 8.20000000000000061e174Initial program 100.0%
Applied egg-rr42.4%
if -820 < l < 7.2e6Initial program 79.0%
Taylor expanded in J around 0 76.1%
if 7.2e6 < l < 2.90000000000000007e119 or 8.20000000000000061e174 < l Initial program 100.0%
Applied egg-rr28.8%
Final simplification53.0%
(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 90.0%
Taylor expanded in l around 0 61.6%
Final simplification61.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (- -4.0 (* U U))))
(if (<= l -4.8e+104)
t_0
(if (<= l -1.55e+26)
(pow U -4.0)
(if (<= l -800.0) t_0 (if (<= l 7200000.0) U (* U U)))))))
double code(double J, double l, double K, double U) {
double t_0 = -4.0 - (U * U);
double tmp;
if (l <= -4.8e+104) {
tmp = t_0;
} else if (l <= -1.55e+26) {
tmp = pow(U, -4.0);
} else if (l <= -800.0) {
tmp = t_0;
} else if (l <= 7200000.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) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) - (u * u)
if (l <= (-4.8d+104)) then
tmp = t_0
else if (l <= (-1.55d+26)) then
tmp = u ** (-4.0d0)
else if (l <= (-800.0d0)) then
tmp = t_0
else if (l <= 7200000.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 t_0 = -4.0 - (U * U);
double tmp;
if (l <= -4.8e+104) {
tmp = t_0;
} else if (l <= -1.55e+26) {
tmp = Math.pow(U, -4.0);
} else if (l <= -800.0) {
tmp = t_0;
} else if (l <= 7200000.0) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): t_0 = -4.0 - (U * U) tmp = 0 if l <= -4.8e+104: tmp = t_0 elif l <= -1.55e+26: tmp = math.pow(U, -4.0) elif l <= -800.0: tmp = t_0 elif l <= 7200000.0: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) t_0 = Float64(-4.0 - Float64(U * U)) tmp = 0.0 if (l <= -4.8e+104) tmp = t_0; elseif (l <= -1.55e+26) tmp = U ^ -4.0; elseif (l <= -800.0) tmp = t_0; elseif (l <= 7200000.0) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = -4.0 - (U * U); tmp = 0.0; if (l <= -4.8e+104) tmp = t_0; elseif (l <= -1.55e+26) tmp = U ^ -4.0; elseif (l <= -800.0) tmp = t_0; elseif (l <= 7200000.0) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(-4.0 - N[(U * U), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.8e+104], t$95$0, If[LessEqual[l, -1.55e+26], N[Power[U, -4.0], $MachinePrecision], If[LessEqual[l, -800.0], t$95$0, If[LessEqual[l, 7200000.0], U, N[(U * U), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 - U \cdot U\\
\mathbf{if}\;\ell \leq -4.8 \cdot 10^{+104}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -1.55 \cdot 10^{+26}:\\
\;\;\;\;{U}^{-4}\\
\mathbf{elif}\;\ell \leq -800:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq 7200000:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -4.8e104 or -1.55e26 < l < -800Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr30.3%
cancel-sign-sub-inv30.3%
Simplified30.3%
if -4.8e104 < l < -1.55e26Initial program 100.0%
Applied egg-rr39.6%
if -800 < l < 7.2e6Initial program 79.0%
Taylor expanded in J around 0 76.1%
if 7.2e6 < l Initial program 100.0%
Applied egg-rr24.1%
Final simplification51.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -6.8e+84) (not (<= l 7200000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -6.8e+84) || !(l <= 7200000.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 <= (-6.8d+84)) .or. (.not. (l <= 7200000.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 <= -6.8e+84) || !(l <= 7200000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -6.8e+84) or not (l <= 7200000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -6.8e+84) || !(l <= 7200000.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 <= -6.8e+84) || ~((l <= 7200000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -6.8e+84], N[Not[LessEqual[l, 7200000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.8 \cdot 10^{+84} \lor \neg \left(\ell \leq 7200000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -6.7999999999999996e84 or 7.2e6 < l Initial program 100.0%
Applied egg-rr20.5%
if -6.7999999999999996e84 < l < 7.2e6Initial program 81.1%
Taylor expanded in J around 0 68.4%
Final simplification46.0%
(FPCore (J l K U) :precision binary64 (if (<= l -620.0) (- -4.0 (* U U)) (if (<= l 7200000.0) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -620.0) {
tmp = -4.0 - (U * U);
} else if (l <= 7200000.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 <= (-620.0d0)) then
tmp = (-4.0d0) - (u * u)
else if (l <= 7200000.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 <= -620.0) {
tmp = -4.0 - (U * U);
} else if (l <= 7200000.0) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -620.0: tmp = -4.0 - (U * U) elif l <= 7200000.0: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -620.0) tmp = Float64(-4.0 - Float64(U * U)); elseif (l <= 7200000.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 <= -620.0) tmp = -4.0 - (U * U); elseif (l <= 7200000.0) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -620.0], N[(-4.0 - N[(U * U), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 7200000.0], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -620:\\
\;\;\;\;-4 - U \cdot U\\
\mathbf{elif}\;\ell \leq 7200000:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -620Initial program 100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Applied egg-rr25.3%
cancel-sign-sub-inv25.3%
Simplified25.3%
if -620 < l < 7.2e6Initial program 79.0%
Taylor expanded in J around 0 76.1%
if 7.2e6 < l Initial program 100.0%
Applied egg-rr24.1%
Final simplification49.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 90.0%
Taylor expanded in J around 0 37.6%
Final simplification37.6%
herbie shell --seed 2023321
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))