
(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 18 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 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.001)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+
U
(*
l
(* (* J (cos (* K 0.5))) (fma 0.3333333333333333 (pow l 2.0) 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.001)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (l * ((J * cos((K * 0.5))) * fma(0.3333333333333333, pow(l, 2.0), 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.001)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(l * Float64(Float64(J * cos(Float64(K * 0.5))) * fma(0.3333333333333333, (l ^ 2.0), 2.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.001]], $MachinePrecision]], N[(N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(l * N[(N[(J * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision] + 2.0), $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.001\right):\\
\;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + \ell \cdot \left(\left(J \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \mathsf{fma}\left(0.3333333333333333, {\ell}^{2}, 2\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 1e-3 < (-.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))) < 1e-3Initial program 75.2%
Taylor expanded in l around 0 99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
distribute-lft-out99.9%
fma-define99.9%
Simplified99.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 0.001)))
(+ (* (* t_1 J) t_0) U)
(+ U (* t_0 (* J (* l (+ 2.0 (* 0.3333333333333333 (pow 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.001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * pow(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.001)) {
tmp = ((t_1 * J) * t_0) + U;
} else {
tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(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.001): tmp = ((t_1 * J) * t_0) + U else: tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * math.pow(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.001)) tmp = Float64(Float64(Float64(t_1 * J) * t_0) + U); else tmp = Float64(U + Float64(t_0 * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (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.001))) tmp = ((t_1 * J) * t_0) + U; else tmp = U + (t_0 * (J * (l * (2.0 + (0.3333333333333333 * (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.001]], $MachinePrecision]], N[(N[(N[(t$95$1 * J), $MachinePrecision] * t$95$0), $MachinePrecision] + U), $MachinePrecision], N[(U + N[(t$95$0 * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 0.001\right):\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot t\_0 + U\\
\mathbf{else}:\\
\;\;\;\;U + t\_0 \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 1e-3 < (-.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))) < 1e-3Initial program 75.2%
Taylor expanded in l around 0 99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* (pow l 5.0) (* J (* t_0 0.016666666666666666))))))
(if (<= l -1.9e+47)
t_1
(if (<= l -600.0)
(+ (* (- (exp l) (exp (- l))) J) U)
(if (<= l 400000.0)
(+ U (* 2.0 (* J (* l t_0))))
(if (<= l 2.5e+43) (log1p (expm1 (- (/ -4.0 U) U))) t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U + (pow(l, 5.0) * (J * (t_0 * 0.016666666666666666)));
double tmp;
if (l <= -1.9e+47) {
tmp = t_1;
} else if (l <= -600.0) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else if (l <= 400000.0) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 2.5e+43) {
tmp = log1p(expm1(((-4.0 / U) - U)));
} else {
tmp = t_1;
}
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 = U + (Math.pow(l, 5.0) * (J * (t_0 * 0.016666666666666666)));
double tmp;
if (l <= -1.9e+47) {
tmp = t_1;
} else if (l <= -600.0) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else if (l <= 400000.0) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 2.5e+43) {
tmp = Math.log1p(Math.expm1(((-4.0 / U) - U)));
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = U + (math.pow(l, 5.0) * (J * (t_0 * 0.016666666666666666))) tmp = 0 if l <= -1.9e+47: tmp = t_1 elif l <= -600.0: tmp = ((math.exp(l) - math.exp(-l)) * J) + U elif l <= 400000.0: tmp = U + (2.0 * (J * (l * t_0))) elif l <= 2.5e+43: tmp = math.log1p(math.expm1(((-4.0 / U) - U))) else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U + Float64((l ^ 5.0) * Float64(J * Float64(t_0 * 0.016666666666666666)))) tmp = 0.0 if (l <= -1.9e+47) tmp = t_1; elseif (l <= -600.0) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); elseif (l <= 400000.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_0)))); elseif (l <= 2.5e+43) tmp = log1p(expm1(Float64(Float64(-4.0 / U) - U))); else tmp = t_1; end return 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[Power[l, 5.0], $MachinePrecision] * N[(J * N[(t$95$0 * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.9e+47], t$95$1, If[LessEqual[l, -600.0], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 400000.0], N[(U + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 2.5e+43], N[Log[1 + N[(Exp[N[(N[(-4.0 / U), $MachinePrecision] - U), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U + {\ell}^{5} \cdot \left(J \cdot \left(t\_0 \cdot 0.016666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{+47}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -600:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{elif}\;\ell \leq 400000:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t\_0\right)\right)\\
\mathbf{elif}\;\ell \leq 2.5 \cdot 10^{+43}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-4}{U} - U\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -1.9000000000000002e47 or 2.5000000000000002e43 < l Initial program 100.0%
Taylor expanded in l around 0 98.2%
*-commutative98.2%
Simplified98.2%
Taylor expanded in l around inf 98.2%
*-commutative98.2%
associate-*r*98.2%
associate-*l*98.2%
*-commutative98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.2%
Simplified98.2%
if -1.9000000000000002e47 < l < -600Initial program 100.0%
Taylor expanded in K around 0 90.9%
if -600 < l < 4e5Initial program 75.8%
Taylor expanded in l around 0 98.0%
if 4e5 < l < 2.5000000000000002e43Initial program 100.0%
Applied egg-rr6.4%
log1p-expm1-u100.0%
Applied egg-rr100.0%
Final simplification97.8%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (pow l 5.0) (* J (* (cos (* K 0.5)) 0.016666666666666666))))))
(if (<= l -1.9e+47)
t_0
(if (<= l -600.0)
(+ (* (- (exp l) (exp (- l))) J) U)
(if (<= l 400000.0)
(+
U
(*
(cos (/ K 2.0))
(* J (* l (+ 2.0 (* 0.3333333333333333 (pow l 2.0)))))))
(if (<= l 1e+41) (log1p (expm1 (- (/ -4.0 U) U))) t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (pow(l, 5.0) * (J * (cos((K * 0.5)) * 0.016666666666666666)));
double tmp;
if (l <= -1.9e+47) {
tmp = t_0;
} else if (l <= -600.0) {
tmp = ((exp(l) - exp(-l)) * J) + U;
} else if (l <= 400000.0) {
tmp = U + (cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * pow(l, 2.0))))));
} else if (l <= 1e+41) {
tmp = log1p(expm1(((-4.0 / U) - U)));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = U + (Math.pow(l, 5.0) * (J * (Math.cos((K * 0.5)) * 0.016666666666666666)));
double tmp;
if (l <= -1.9e+47) {
tmp = t_0;
} else if (l <= -600.0) {
tmp = ((Math.exp(l) - Math.exp(-l)) * J) + U;
} else if (l <= 400000.0) {
tmp = U + (Math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * Math.pow(l, 2.0))))));
} else if (l <= 1e+41) {
tmp = Math.log1p(Math.expm1(((-4.0 / U) - U)));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, l, K, U): t_0 = U + (math.pow(l, 5.0) * (J * (math.cos((K * 0.5)) * 0.016666666666666666))) tmp = 0 if l <= -1.9e+47: tmp = t_0 elif l <= -600.0: tmp = ((math.exp(l) - math.exp(-l)) * J) + U elif l <= 400000.0: tmp = U + (math.cos((K / 2.0)) * (J * (l * (2.0 + (0.3333333333333333 * math.pow(l, 2.0)))))) elif l <= 1e+41: tmp = math.log1p(math.expm1(((-4.0 / U) - U))) else: tmp = t_0 return tmp
function code(J, l, K, U) t_0 = Float64(U + Float64((l ^ 5.0) * Float64(J * Float64(cos(Float64(K * 0.5)) * 0.016666666666666666)))) tmp = 0.0 if (l <= -1.9e+47) tmp = t_0; elseif (l <= -600.0) tmp = Float64(Float64(Float64(exp(l) - exp(Float64(-l))) * J) + U); elseif (l <= 400000.0) tmp = Float64(U + Float64(cos(Float64(K / 2.0)) * Float64(J * Float64(l * Float64(2.0 + Float64(0.3333333333333333 * (l ^ 2.0))))))); elseif (l <= 1e+41) tmp = log1p(expm1(Float64(Float64(-4.0 / U) - U))); else tmp = t_0; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(U + N[(N[Power[l, 5.0], $MachinePrecision] * N[(J * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.9e+47], t$95$0, If[LessEqual[l, -600.0], N[(N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 400000.0], N[(U + N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(J * N[(l * N[(2.0 + N[(0.3333333333333333 * N[Power[l, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1e+41], N[Log[1 + N[(Exp[N[(N[(-4.0 / U), $MachinePrecision] - U), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + {\ell}^{5} \cdot \left(J \cdot \left(\cos \left(K \cdot 0.5\right) \cdot 0.016666666666666666\right)\right)\\
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{+47}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -600:\\
\;\;\;\;\left(e^{\ell} - e^{-\ell}\right) \cdot J + U\\
\mathbf{elif}\;\ell \leq 400000:\\
\;\;\;\;U + \cos \left(\frac{K}{2}\right) \cdot \left(J \cdot \left(\ell \cdot \left(2 + 0.3333333333333333 \cdot {\ell}^{2}\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 10^{+41}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-4}{U} - U\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -1.9000000000000002e47 or 1.00000000000000001e41 < l Initial program 100.0%
Taylor expanded in l around 0 98.2%
*-commutative98.2%
Simplified98.2%
Taylor expanded in l around inf 98.2%
*-commutative98.2%
associate-*r*98.2%
associate-*l*98.2%
*-commutative98.2%
associate-*r*98.2%
*-commutative98.2%
associate-*l*98.2%
Simplified98.2%
if -1.9000000000000002e47 < l < -600Initial program 100.0%
Taylor expanded in K around 0 90.9%
if -600 < l < 4e5Initial program 75.8%
Taylor expanded in l around 0 98.4%
if 4e5 < l < 1.00000000000000001e41Initial program 100.0%
Applied egg-rr6.4%
log1p-expm1-u100.0%
Applied egg-rr100.0%
Final simplification98.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (* U (+ 1.0 (* 2.0 (* l (* J (/ t_0 U)))))))
(t_2 (log1p (expm1 (- (/ -4.0 U) U)))))
(if (<= l -1.28e+132)
t_1
(if (<= l -3700000000000.0)
t_2
(if (<= l 400000.0)
(+ U (* 2.0 (* J (* l t_0))))
(if (<= l 5.1e+116)
t_2
(if (<= l 1.9e+160)
(pow U -3.0)
(if (<= l 1.1e+217)
(* U (+ 1.0 (* (* J 2.0) (/ l U))))
t_1))))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = U * (1.0 + (2.0 * (l * (J * (t_0 / U)))));
double t_2 = log1p(expm1(((-4.0 / U) - U)));
double tmp;
if (l <= -1.28e+132) {
tmp = t_1;
} else if (l <= -3700000000000.0) {
tmp = t_2;
} else if (l <= 400000.0) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 5.1e+116) {
tmp = t_2;
} else if (l <= 1.9e+160) {
tmp = pow(U, -3.0);
} else if (l <= 1.1e+217) {
tmp = U * (1.0 + ((J * 2.0) * (l / U)));
} else {
tmp = t_1;
}
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 = U * (1.0 + (2.0 * (l * (J * (t_0 / U)))));
double t_2 = Math.log1p(Math.expm1(((-4.0 / U) - U)));
double tmp;
if (l <= -1.28e+132) {
tmp = t_1;
} else if (l <= -3700000000000.0) {
tmp = t_2;
} else if (l <= 400000.0) {
tmp = U + (2.0 * (J * (l * t_0)));
} else if (l <= 5.1e+116) {
tmp = t_2;
} else if (l <= 1.9e+160) {
tmp = Math.pow(U, -3.0);
} else if (l <= 1.1e+217) {
tmp = U * (1.0 + ((J * 2.0) * (l / U)));
} else {
tmp = t_1;
}
return tmp;
}
def code(J, l, K, U): t_0 = math.cos((K * 0.5)) t_1 = U * (1.0 + (2.0 * (l * (J * (t_0 / U))))) t_2 = math.log1p(math.expm1(((-4.0 / U) - U))) tmp = 0 if l <= -1.28e+132: tmp = t_1 elif l <= -3700000000000.0: tmp = t_2 elif l <= 400000.0: tmp = U + (2.0 * (J * (l * t_0))) elif l <= 5.1e+116: tmp = t_2 elif l <= 1.9e+160: tmp = math.pow(U, -3.0) elif l <= 1.1e+217: tmp = U * (1.0 + ((J * 2.0) * (l / U))) else: tmp = t_1 return tmp
function code(J, l, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = Float64(U * Float64(1.0 + Float64(2.0 * Float64(l * Float64(J * Float64(t_0 / U)))))) t_2 = log1p(expm1(Float64(Float64(-4.0 / U) - U))) tmp = 0.0 if (l <= -1.28e+132) tmp = t_1; elseif (l <= -3700000000000.0) tmp = t_2; elseif (l <= 400000.0) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_0)))); elseif (l <= 5.1e+116) tmp = t_2; elseif (l <= 1.9e+160) tmp = U ^ -3.0; elseif (l <= 1.1e+217) tmp = Float64(U * Float64(1.0 + Float64(Float64(J * 2.0) * Float64(l / U)))); else tmp = t_1; end return 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[(1.0 + N[(2.0 * N[(l * N[(J * N[(t$95$0 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Log[1 + N[(Exp[N[(N[(-4.0 / U), $MachinePrecision] - U), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -1.28e+132], t$95$1, If[LessEqual[l, -3700000000000.0], t$95$2, If[LessEqual[l, 400000.0], N[(U + N[(2.0 * N[(J * N[(l * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.1e+116], t$95$2, If[LessEqual[l, 1.9e+160], N[Power[U, -3.0], $MachinePrecision], If[LessEqual[l, 1.1e+217], N[(U * N[(1.0 + N[(N[(J * 2.0), $MachinePrecision] * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := U \cdot \left(1 + 2 \cdot \left(\ell \cdot \left(J \cdot \frac{t\_0}{U}\right)\right)\right)\\
t_2 := \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{-4}{U} - U\right)\right)\\
\mathbf{if}\;\ell \leq -1.28 \cdot 10^{+132}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -3700000000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 400000:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t\_0\right)\right)\\
\mathbf{elif}\;\ell \leq 5.1 \cdot 10^{+116}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 1.9 \cdot 10^{+160}:\\
\;\;\;\;{U}^{-3}\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+217}:\\
\;\;\;\;U \cdot \left(1 + \left(J \cdot 2\right) \cdot \frac{\ell}{U}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -1.2800000000000001e132 or 1.1e217 < l Initial program 100.0%
Taylor expanded in l around 0 55.0%
associate-*r*55.0%
Simplified55.0%
Taylor expanded in U around inf 68.8%
associate-*r*68.8%
Simplified68.8%
associate-/l*68.8%
*-commutative68.8%
associate-*l*68.8%
Applied egg-rr68.8%
if -1.2800000000000001e132 < l < -3.7e12 or 4e5 < l < 5.09999999999999999e116Initial program 100.0%
Applied egg-rr3.3%
log1p-expm1-u64.0%
Applied egg-rr64.0%
if -3.7e12 < l < 4e5Initial program 76.1%
Taylor expanded in l around 0 96.6%
if 5.09999999999999999e116 < l < 1.90000000000000006e160Initial program 100.0%
Applied egg-rr75.7%
if 1.90000000000000006e160 < l < 1.1e217Initial program 100.0%
Taylor expanded in l around 0 24.7%
associate-*r*24.7%
Simplified24.7%
Taylor expanded in U around inf 42.8%
associate-*r*42.8%
Simplified42.8%
Taylor expanded in K around 0 42.8%
associate-/l*62.2%
associate-*r*62.2%
*-commutative62.2%
Simplified62.2%
Final simplification82.3%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (+ (* (- (exp l) (exp (- l))) J) U)) (t_1 (cos (* K 0.5))))
(if (<= l -780.0)
t_0
(if (<= l 7.5e-6)
(+ U (* 2.0 (* J (* l t_1))))
(if (<= l 1.3e+250) t_0 (* U (+ 1.0 (* 2.0 (* l (* J (/ t_1 U)))))))))))
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 tmp;
if (l <= -780.0) {
tmp = t_0;
} else if (l <= 7.5e-6) {
tmp = U + (2.0 * (J * (l * t_1)));
} else if (l <= 1.3e+250) {
tmp = t_0;
} else {
tmp = U * (1.0 + (2.0 * (l * (J * (t_1 / U)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((exp(l) - exp(-l)) * j) + u
t_1 = cos((k * 0.5d0))
if (l <= (-780.0d0)) then
tmp = t_0
else if (l <= 7.5d-6) then
tmp = u + (2.0d0 * (j * (l * t_1)))
else if (l <= 1.3d+250) then
tmp = t_0
else
tmp = u * (1.0d0 + (2.0d0 * (l * (j * (t_1 / u)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = ((Math.exp(l) - Math.exp(-l)) * J) + U;
double t_1 = Math.cos((K * 0.5));
double tmp;
if (l <= -780.0) {
tmp = t_0;
} else if (l <= 7.5e-6) {
tmp = U + (2.0 * (J * (l * t_1)));
} else if (l <= 1.3e+250) {
tmp = t_0;
} else {
tmp = U * (1.0 + (2.0 * (l * (J * (t_1 / U)))));
}
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)) tmp = 0 if l <= -780.0: tmp = t_0 elif l <= 7.5e-6: tmp = U + (2.0 * (J * (l * t_1))) elif l <= 1.3e+250: tmp = t_0 else: tmp = U * (1.0 + (2.0 * (l * (J * (t_1 / U))))) 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)) tmp = 0.0 if (l <= -780.0) tmp = t_0; elseif (l <= 7.5e-6) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * t_1)))); elseif (l <= 1.3e+250) tmp = t_0; else tmp = Float64(U * Float64(1.0 + Float64(2.0 * Float64(l * Float64(J * Float64(t_1 / U)))))); 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)); tmp = 0.0; if (l <= -780.0) tmp = t_0; elseif (l <= 7.5e-6) tmp = U + (2.0 * (J * (l * t_1))); elseif (l <= 1.3e+250) tmp = t_0; else tmp = U * (1.0 + (2.0 * (l * (J * (t_1 / U))))); 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]}, If[LessEqual[l, -780.0], t$95$0, If[LessEqual[l, 7.5e-6], N[(U + N[(2.0 * N[(J * N[(l * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.3e+250], t$95$0, N[(U * N[(1.0 + N[(2.0 * N[(l * N[(J * N[(t$95$1 / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\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)\\
\mathbf{if}\;\ell \leq -780:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 7.5 \cdot 10^{-6}:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot t\_1\right)\right)\\
\mathbf{elif}\;\ell \leq 1.3 \cdot 10^{+250}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + 2 \cdot \left(\ell \cdot \left(J \cdot \frac{t\_1}{U}\right)\right)\right)\\
\end{array}
\end{array}
if l < -780 or 7.50000000000000019e-6 < l < 1.30000000000000006e250Initial program 99.9%
Taylor expanded in K around 0 76.6%
if -780 < l < 7.50000000000000019e-6Initial program 74.9%
Taylor expanded in l around 0 99.8%
if 1.30000000000000006e250 < l Initial program 100.0%
Taylor expanded in l around 0 74.7%
associate-*r*74.7%
Simplified74.7%
Taylor expanded in U around inf 87.3%
associate-*r*87.3%
Simplified87.3%
associate-/l*87.3%
*-commutative87.3%
associate-*l*87.3%
Applied egg-rr87.3%
Final simplification88.6%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.38) (* J (+ (* 2.0 (* l (cos (* K 0.5)))) (/ U J))) (* U (+ 1.0 (* (* J 2.0) (/ l U))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.38) {
tmp = J * ((2.0 * (l * cos((K * 0.5)))) + (U / J));
} else {
tmp = U * (1.0 + ((J * 2.0) * (l / U)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (cos((k / 2.0d0)) <= 0.38d0) then
tmp = j * ((2.0d0 * (l * cos((k * 0.5d0)))) + (u / j))
else
tmp = u * (1.0d0 + ((j * 2.0d0) * (l / u)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.38) {
tmp = J * ((2.0 * (l * Math.cos((K * 0.5)))) + (U / J));
} else {
tmp = U * (1.0 + ((J * 2.0) * (l / U)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.38: tmp = J * ((2.0 * (l * math.cos((K * 0.5)))) + (U / J)) else: tmp = U * (1.0 + ((J * 2.0) * (l / U))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.38) tmp = Float64(J * Float64(Float64(2.0 * Float64(l * cos(Float64(K * 0.5)))) + Float64(U / J))); else tmp = Float64(U * Float64(1.0 + Float64(Float64(J * 2.0) * Float64(l / U)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.38) tmp = J * ((2.0 * (l * cos((K * 0.5)))) + (U / J)); else tmp = U * (1.0 + ((J * 2.0) * (l / U))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.38], N[(J * N[(N[(2.0 * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(U / J), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(N[(J * 2.0), $MachinePrecision] * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.38:\\
\;\;\;\;J \cdot \left(2 \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right) + \frac{U}{J}\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + \left(J \cdot 2\right) \cdot \frac{\ell}{U}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.38Initial program 85.8%
Taylor expanded in l around 0 71.3%
associate-*r*71.3%
Simplified71.3%
Taylor expanded in J around inf 71.4%
if 0.38 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in l around 0 62.6%
associate-*r*62.6%
Simplified62.6%
Taylor expanded in U around inf 68.1%
associate-*r*68.1%
Simplified68.1%
Taylor expanded in K around 0 65.9%
associate-/l*69.3%
associate-*r*69.3%
*-commutative69.3%
Simplified69.3%
Final simplification70.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) 0.38) (+ U (* 2.0 (* J (* l (cos (* K 0.5)))))) (* U (+ 1.0 (* (* J 2.0) (/ l U))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= 0.38) {
tmp = U + (2.0 * (J * (l * cos((K * 0.5)))));
} else {
tmp = U * (1.0 + ((J * 2.0) * (l / U)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (cos((k / 2.0d0)) <= 0.38d0) then
tmp = u + (2.0d0 * (j * (l * cos((k * 0.5d0)))))
else
tmp = u * (1.0d0 + ((j * 2.0d0) * (l / u)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= 0.38) {
tmp = U + (2.0 * (J * (l * Math.cos((K * 0.5)))));
} else {
tmp = U * (1.0 + ((J * 2.0) * (l / U)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= 0.38: tmp = U + (2.0 * (J * (l * math.cos((K * 0.5))))) else: tmp = U * (1.0 + ((J * 2.0) * (l / U))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= 0.38) tmp = Float64(U + Float64(2.0 * Float64(J * Float64(l * cos(Float64(K * 0.5)))))); else tmp = Float64(U * Float64(1.0 + Float64(Float64(J * 2.0) * Float64(l / U)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= 0.38) tmp = U + (2.0 * (J * (l * cos((K * 0.5))))); else tmp = U * (1.0 + ((J * 2.0) * (l / U))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], 0.38], N[(U + N[(2.0 * N[(J * N[(l * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(N[(J * 2.0), $MachinePrecision] * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq 0.38:\\
\;\;\;\;U + 2 \cdot \left(J \cdot \left(\ell \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + \left(J \cdot 2\right) \cdot \frac{\ell}{U}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < 0.38Initial program 85.8%
Taylor expanded in l around 0 71.3%
if 0.38 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 88.5%
Taylor expanded in l around 0 62.6%
associate-*r*62.6%
Simplified62.6%
Taylor expanded in U around inf 68.1%
associate-*r*68.1%
Simplified68.1%
Taylor expanded in K around 0 65.9%
associate-/l*69.3%
associate-*r*69.3%
*-commutative69.3%
Simplified69.3%
Final simplification70.0%
(FPCore (J l K U) :precision binary64 (if (<= (cos (/ K 2.0)) -0.008) (+ U (* (* J -0.25) (* l (pow K 2.0)))) (* U (+ 1.0 (* (* J 2.0) (/ l U))))))
double code(double J, double l, double K, double U) {
double tmp;
if (cos((K / 2.0)) <= -0.008) {
tmp = U + ((J * -0.25) * (l * pow(K, 2.0)));
} else {
tmp = U * (1.0 + ((J * 2.0) * (l / U)));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (cos((k / 2.0d0)) <= (-0.008d0)) then
tmp = u + ((j * (-0.25d0)) * (l * (k ** 2.0d0)))
else
tmp = u * (1.0d0 + ((j * 2.0d0) * (l / u)))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double tmp;
if (Math.cos((K / 2.0)) <= -0.008) {
tmp = U + ((J * -0.25) * (l * Math.pow(K, 2.0)));
} else {
tmp = U * (1.0 + ((J * 2.0) * (l / U)));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if math.cos((K / 2.0)) <= -0.008: tmp = U + ((J * -0.25) * (l * math.pow(K, 2.0))) else: tmp = U * (1.0 + ((J * 2.0) * (l / U))) return tmp
function code(J, l, K, U) tmp = 0.0 if (cos(Float64(K / 2.0)) <= -0.008) tmp = Float64(U + Float64(Float64(J * -0.25) * Float64(l * (K ^ 2.0)))); else tmp = Float64(U * Float64(1.0 + Float64(Float64(J * 2.0) * Float64(l / U)))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (cos((K / 2.0)) <= -0.008) tmp = U + ((J * -0.25) * (l * (K ^ 2.0))); else tmp = U * (1.0 + ((J * 2.0) * (l / U))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision], -0.008], N[(U + N[(N[(J * -0.25), $MachinePrecision] * N[(l * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U * N[(1.0 + N[(N[(J * 2.0), $MachinePrecision] * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\frac{K}{2}\right) \leq -0.008:\\
\;\;\;\;U + \left(J \cdot -0.25\right) \cdot \left(\ell \cdot {K}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;U \cdot \left(1 + \left(J \cdot 2\right) \cdot \frac{\ell}{U}\right)\\
\end{array}
\end{array}
if (cos.f64 (/.f64 K #s(literal 2 binary64))) < -0.0080000000000000002Initial program 89.9%
Taylor expanded in l around 0 70.9%
associate-*r*70.9%
Simplified70.9%
Taylor expanded in K around 0 41.0%
Taylor expanded in K around inf 60.7%
associate-*r*60.7%
*-commutative60.7%
*-commutative60.7%
Simplified60.7%
if -0.0080000000000000002 < (cos.f64 (/.f64 K #s(literal 2 binary64))) Initial program 86.8%
Taylor expanded in l around 0 63.8%
associate-*r*63.8%
Simplified63.8%
Taylor expanded in U around inf 69.1%
associate-*r*69.1%
Simplified69.1%
Taylor expanded in K around 0 64.5%
associate-/l*68.1%
associate-*r*68.1%
*-commutative68.1%
Simplified68.1%
Final simplification66.2%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* 2.0 (/ (* (cos (* K 0.5)) (* l J)) U)))))
double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * ((cos((K * 0.5)) * (l * J)) / U)));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u * (1.0d0 + (2.0d0 * ((cos((k * 0.5d0)) * (l * j)) / u)))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * ((Math.cos((K * 0.5)) * (l * J)) / U)));
}
def code(J, l, K, U): return U * (1.0 + (2.0 * ((math.cos((K * 0.5)) * (l * J)) / U)))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(2.0 * Float64(Float64(cos(Float64(K * 0.5)) * Float64(l * J)) / U)))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + (2.0 * ((cos((K * 0.5)) * (l * J)) / U))); end
code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(2.0 * N[(N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(l * J), $MachinePrecision]), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U \cdot \left(1 + 2 \cdot \frac{\cos \left(K \cdot 0.5\right) \cdot \left(\ell \cdot J\right)}{U}\right)
\end{array}
Initial program 87.6%
Taylor expanded in l around 0 65.6%
associate-*r*65.6%
Simplified65.6%
Taylor expanded in U around inf 70.3%
associate-*r*70.3%
Simplified70.3%
Final simplification70.3%
(FPCore (J l K U) :precision binary64 (if (or (<= l -5.2e+37) (not (<= l 400000.0))) (* U (- U -4.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -5.2e+37) || !(l <= 400000.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 <= (-5.2d+37)) .or. (.not. (l <= 400000.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 <= -5.2e+37) || !(l <= 400000.0)) {
tmp = U * (U - -4.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -5.2e+37) or not (l <= 400000.0): tmp = U * (U - -4.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -5.2e+37) || !(l <= 400000.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 <= -5.2e+37) || ~((l <= 400000.0))) tmp = U * (U - -4.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -5.2e+37], N[Not[LessEqual[l, 400000.0]], $MachinePrecision]], N[(U * N[(U - -4.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.2 \cdot 10^{+37} \lor \neg \left(\ell \leq 400000\right):\\
\;\;\;\;U \cdot \left(U - -4\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -5.1999999999999998e37 or 4e5 < l Initial program 100.0%
Applied egg-rr16.4%
if -5.1999999999999998e37 < l < 4e5Initial program 77.3%
Taylor expanded in J around 0 68.6%
Final simplification45.0%
(FPCore (J l K U) :precision binary64 (if (or (<= l -7.3e+15) (not (<= l 450.0))) (* l (* J 2.0)) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -7.3e+15) || !(l <= 450.0)) {
tmp = l * (J * 2.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.3d+15)) .or. (.not. (l <= 450.0d0))) then
tmp = l * (j * 2.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.3e+15) || !(l <= 450.0)) {
tmp = l * (J * 2.0);
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -7.3e+15) or not (l <= 450.0): tmp = l * (J * 2.0) else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -7.3e+15) || !(l <= 450.0)) tmp = Float64(l * Float64(J * 2.0)); else tmp = U; end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -7.3e+15) || ~((l <= 450.0))) tmp = l * (J * 2.0); else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -7.3e+15], N[Not[LessEqual[l, 450.0]], $MachinePrecision]], N[(l * N[(J * 2.0), $MachinePrecision]), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -7.3 \cdot 10^{+15} \lor \neg \left(\ell \leq 450\right):\\
\;\;\;\;\ell \cdot \left(J \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -7.3e15 or 450 < l Initial program 100.0%
Taylor expanded in l around 0 32.1%
associate-*r*32.1%
Simplified32.1%
Taylor expanded in U around inf 45.0%
associate-*r*45.0%
Simplified45.0%
Taylor expanded in U around 0 32.3%
associate-*r*32.3%
Simplified32.3%
Taylor expanded in K around 0 21.2%
*-commutative21.2%
*-commutative21.2%
associate-*r*21.2%
Simplified21.2%
if -7.3e15 < l < 450Initial program 76.1%
Taylor expanded in J around 0 72.1%
Final simplification47.7%
(FPCore (J l K U) :precision binary64 (if (or (<= l -2.9e+37) (not (<= l 400000.0))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -2.9e+37) || !(l <= 400000.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 <= (-2.9d+37)) .or. (.not. (l <= 400000.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 <= -2.9e+37) || !(l <= 400000.0)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -2.9e+37) or not (l <= 400000.0): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -2.9e+37) || !(l <= 400000.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 <= -2.9e+37) || ~((l <= 400000.0))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -2.9e+37], N[Not[LessEqual[l, 400000.0]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.9 \cdot 10^{+37} \lor \neg \left(\ell \leq 400000\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -2.89999999999999978e37 or 4e5 < l Initial program 100.0%
Applied egg-rr16.4%
if -2.89999999999999978e37 < l < 4e5Initial program 77.3%
Taylor expanded in J around 0 68.6%
Final simplification44.9%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* 2.0 (/ (* l J) U)))))
double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * ((l * J) / U)));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u * (1.0d0 + (2.0d0 * ((l * j) / u)))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + (2.0 * ((l * J) / U)));
}
def code(J, l, K, U): return U * (1.0 + (2.0 * ((l * J) / U)))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(2.0 * Float64(Float64(l * J) / U)))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + (2.0 * ((l * J) / U))); end
code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(2.0 * N[(N[(l * J), $MachinePrecision] / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U \cdot \left(1 + 2 \cdot \frac{\ell \cdot J}{U}\right)
\end{array}
Initial program 87.6%
Taylor expanded in l around 0 65.6%
associate-*r*65.6%
Simplified65.6%
Taylor expanded in U around inf 70.3%
associate-*r*70.3%
Simplified70.3%
Taylor expanded in K around 0 58.2%
Final simplification58.2%
(FPCore (J l K U) :precision binary64 (* U (+ 1.0 (* (* J 2.0) (/ l U)))))
double code(double J, double l, double K, double U) {
return U * (1.0 + ((J * 2.0) * (l / U)));
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u * (1.0d0 + ((j * 2.0d0) * (l / u)))
end function
public static double code(double J, double l, double K, double U) {
return U * (1.0 + ((J * 2.0) * (l / U)));
}
def code(J, l, K, U): return U * (1.0 + ((J * 2.0) * (l / U)))
function code(J, l, K, U) return Float64(U * Float64(1.0 + Float64(Float64(J * 2.0) * Float64(l / U)))) end
function tmp = code(J, l, K, U) tmp = U * (1.0 + ((J * 2.0) * (l / U))); end
code[J_, l_, K_, U_] := N[(U * N[(1.0 + N[(N[(J * 2.0), $MachinePrecision] * N[(l / U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
U \cdot \left(1 + \left(J \cdot 2\right) \cdot \frac{\ell}{U}\right)
\end{array}
Initial program 87.6%
Taylor expanded in l around 0 65.6%
associate-*r*65.6%
Simplified65.6%
Taylor expanded in U around inf 70.3%
associate-*r*70.3%
Simplified70.3%
Taylor expanded in K around 0 58.2%
associate-/l*60.8%
associate-*r*60.8%
*-commutative60.8%
Simplified60.8%
Final simplification60.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 87.6%
Taylor expanded in l around 0 65.6%
associate-*r*65.6%
Simplified65.6%
Taylor expanded in K around 0 53.9%
*-commutative53.9%
associate-*r*53.9%
Simplified53.9%
Final simplification53.9%
(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 87.6%
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 87.6%
Taylor expanded in J around 0 38.4%
Final simplification38.4%
herbie shell --seed 2024079
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))