
(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 (- (exp l) (exp (- l)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.0005)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+
U
(*
J
(*
l
(*
(cos (* K 0.5))
(+
2.0
(*
(pow l 2.0)
(+ 0.3333333333333333 (* (pow l 2.0) 0.016666666666666666)))))))))))
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.0005)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (J * (l * (cos((K * 0.5)) * (2.0 + (pow(l, 2.0) * (0.3333333333333333 + (pow(l, 2.0) * 0.016666666666666666)))))));
}
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.0005)) {
tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + (J * (l * (Math.cos((K * 0.5)) * (2.0 + (Math.pow(l, 2.0) * (0.3333333333333333 + (Math.pow(l, 2.0) * 0.016666666666666666)))))));
}
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.0005): tmp = ((t_0 * J) * math.cos((K / 2.0))) + U else: tmp = U + (J * (l * (math.cos((K * 0.5)) * (2.0 + (math.pow(l, 2.0) * (0.3333333333333333 + (math.pow(l, 2.0) * 0.016666666666666666))))))) 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.0005)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(J * Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(2.0 + Float64((l ^ 2.0) * Float64(0.3333333333333333 + Float64((l ^ 2.0) * 0.016666666666666666)))))))); 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.0005))) tmp = ((t_0 * J) * cos((K / 2.0))) + U; else tmp = U + (J * (l * (cos((K * 0.5)) * (2.0 + ((l ^ 2.0) * (0.3333333333333333 + ((l ^ 2.0) * 0.016666666666666666))))))); 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.0005]], $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[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * N[(0.3333333333333333 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $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.0005\right):\\
\;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(2 + {\ell}^{2} \cdot \left(0.3333333333333333 + {\ell}^{2} \cdot 0.016666666666666666\right)\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -inf.0 or 5.0000000000000001e-4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
if -inf.0 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000001e-4Initial program 74.4%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.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 -0.005) (not (<= t_0 0.0005)))
(+ (* (* t_0 J) (cos (/ K 2.0))) U)
(+
U
(*
J
(*
l
(* (cos (* K 0.5)) (+ 2.0 (* (pow l 2.0) 0.3333333333333333)))))))))
double code(double J, double l, double K, double U) {
double t_0 = exp(l) - exp(-l);
double tmp;
if ((t_0 <= -0.005) || !(t_0 <= 0.0005)) {
tmp = ((t_0 * J) * cos((K / 2.0))) + U;
} else {
tmp = U + (J * (l * (cos((K * 0.5)) * (2.0 + (pow(l, 2.0) * 0.3333333333333333)))));
}
return tmp;
}
real(8) function code(j, l, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = exp(l) - exp(-l)
if ((t_0 <= (-0.005d0)) .or. (.not. (t_0 <= 0.0005d0))) then
tmp = ((t_0 * j) * cos((k / 2.0d0))) + u
else
tmp = u + (j * (l * (cos((k * 0.5d0)) * (2.0d0 + ((l ** 2.0d0) * 0.3333333333333333d0)))))
end if
code = tmp
end function
public static double code(double J, double l, double K, double U) {
double t_0 = Math.exp(l) - Math.exp(-l);
double tmp;
if ((t_0 <= -0.005) || !(t_0 <= 0.0005)) {
tmp = ((t_0 * J) * Math.cos((K / 2.0))) + U;
} else {
tmp = U + (J * (l * (Math.cos((K * 0.5)) * (2.0 + (Math.pow(l, 2.0) * 0.3333333333333333)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = math.exp(l) - math.exp(-l) tmp = 0 if (t_0 <= -0.005) or not (t_0 <= 0.0005): tmp = ((t_0 * J) * math.cos((K / 2.0))) + U else: tmp = U + (J * (l * (math.cos((K * 0.5)) * (2.0 + (math.pow(l, 2.0) * 0.3333333333333333))))) return tmp
function code(J, l, K, U) t_0 = Float64(exp(l) - exp(Float64(-l))) tmp = 0.0 if ((t_0 <= -0.005) || !(t_0 <= 0.0005)) tmp = Float64(Float64(Float64(t_0 * J) * cos(Float64(K / 2.0))) + U); else tmp = Float64(U + Float64(J * Float64(l * Float64(cos(Float64(K * 0.5)) * Float64(2.0 + Float64((l ^ 2.0) * 0.3333333333333333)))))); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = exp(l) - exp(-l); tmp = 0.0; if ((t_0 <= -0.005) || ~((t_0 <= 0.0005))) tmp = ((t_0 * J) * cos((K / 2.0))) + U; else tmp = U + (J * (l * (cos((K * 0.5)) * (2.0 + ((l ^ 2.0) * 0.3333333333333333))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.005], N[Not[LessEqual[t$95$0, 0.0005]], $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[(l * N[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\ell} - e^{-\ell}\\
\mathbf{if}\;t\_0 \leq -0.005 \lor \neg \left(t\_0 \leq 0.0005\right):\\
\;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(2 + {\ell}^{2} \cdot 0.3333333333333333\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.0050000000000000001 or 5.0000000000000001e-4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 99.9%
if -0.0050000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000001e-4Initial program 73.7%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in J around 0 99.9%
Taylor expanded in l around 0 99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5))) (t_1 (- (exp l) (exp (- l)))))
(if (<= t_1 -0.005)
(+ U (* t_1 (* J t_0)))
(if (<= t_1 0.0005)
(+ U (* J (* l (* t_0 (+ 2.0 (* (pow l 2.0) 0.3333333333333333))))))
(+ (* (* t_1 J) (cos (/ K 2.0))) U)))))
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 <= -0.005) {
tmp = U + (t_1 * (J * t_0));
} else if (t_1 <= 0.0005) {
tmp = U + (J * (l * (t_0 * (2.0 + (pow(l, 2.0) * 0.3333333333333333)))));
} else {
tmp = ((t_1 * J) * cos((K / 2.0))) + 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 = cos((k * 0.5d0))
t_1 = exp(l) - exp(-l)
if (t_1 <= (-0.005d0)) then
tmp = u + (t_1 * (j * t_0))
else if (t_1 <= 0.0005d0) then
tmp = u + (j * (l * (t_0 * (2.0d0 + ((l ** 2.0d0) * 0.3333333333333333d0)))))
else
tmp = ((t_1 * j) * cos((k / 2.0d0))) + u
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 = Math.exp(l) - Math.exp(-l);
double tmp;
if (t_1 <= -0.005) {
tmp = U + (t_1 * (J * t_0));
} else if (t_1 <= 0.0005) {
tmp = U + (J * (l * (t_0 * (2.0 + (Math.pow(l, 2.0) * 0.3333333333333333)))));
} else {
tmp = ((t_1 * J) * Math.cos((K / 2.0))) + U;
}
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 <= -0.005: tmp = U + (t_1 * (J * t_0)) elif t_1 <= 0.0005: tmp = U + (J * (l * (t_0 * (2.0 + (math.pow(l, 2.0) * 0.3333333333333333))))) else: tmp = ((t_1 * J) * math.cos((K / 2.0))) + U 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 <= -0.005) tmp = Float64(U + Float64(t_1 * Float64(J * t_0))); elseif (t_1 <= 0.0005) tmp = Float64(U + Float64(J * Float64(l * Float64(t_0 * Float64(2.0 + Float64((l ^ 2.0) * 0.3333333333333333)))))); else tmp = Float64(Float64(Float64(t_1 * J) * cos(Float64(K / 2.0))) + U); 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 <= -0.005) tmp = U + (t_1 * (J * t_0)); elseif (t_1 <= 0.0005) tmp = U + (J * (l * (t_0 * (2.0 + ((l ^ 2.0) * 0.3333333333333333))))); else tmp = ((t_1 * J) * cos((K / 2.0))) + U; 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[LessEqual[t$95$1, -0.005], N[(U + N[(t$95$1 * N[(J * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0005], N[(U + N[(J * N[(l * N[(t$95$0 * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 * J), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $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 -0.005:\\
\;\;\;\;U + t\_1 \cdot \left(J \cdot t\_0\right)\\
\mathbf{elif}\;t\_1 \leq 0.0005:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(t\_0 \cdot \left(2 + {\ell}^{2} \cdot 0.3333333333333333\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 \cdot J\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\end{array}
\end{array}
if (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < -0.0050000000000000001Initial program 99.7%
Taylor expanded in J around 0 99.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
if -0.0050000000000000001 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) < 5.0000000000000001e-4Initial program 73.7%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in J around 0 99.9%
Taylor expanded in l around 0 99.9%
associate-*r*99.9%
*-commutative99.9%
distribute-rgt-out99.9%
*-commutative99.9%
Simplified99.9%
if 5.0000000000000001e-4 < (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l))) Initial program 100.0%
Final simplification99.9%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (- (exp l) (exp (- l))) J)))
(if (<= t_0 (- INFINITY))
t_0
(if (<= t_0 2e+282) (fma J (* (cos (/ K 2.0)) (* l 2.0)) U) (+ t_0 U)))))
double code(double J, double l, double K, double U) {
double t_0 = (exp(l) - exp(-l)) * J;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_0;
} else if (t_0 <= 2e+282) {
tmp = fma(J, (cos((K / 2.0)) * (l * 2.0)), U);
} else {
tmp = t_0 + U;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_0; elseif (t_0 <= 2e+282) tmp = fma(J, Float64(cos(Float64(K / 2.0)) * Float64(l * 2.0)), U); else tmp = Float64(t_0 + U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$0, If[LessEqual[t$95$0, 2e+282], N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], N[(t$95$0 + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+282}:\\
\;\;\;\;\mathsf{fma}\left(J, \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot 2\right), U\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + U\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -inf.0Initial program 100.0%
Taylor expanded in K around 0 70.2%
Taylor expanded in J around inf 70.2%
if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 2.00000000000000007e282Initial program 74.4%
associate-*l*74.4%
fma-define74.4%
Simplified74.4%
Taylor expanded in l around 0 98.7%
if 2.00000000000000007e282 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
Taylor expanded in K around 0 80.0%
Final simplification87.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (- (exp l) (exp (- l))) J)))
(if (<= t_0 (- INFINITY))
t_0
(if (<= t_0 2e+282)
(+ U (* J (* l (* 2.0 (cos (* K 0.5))))))
(+ t_0 U)))))
double code(double J, double l, double K, double U) {
double t_0 = (exp(l) - exp(-l)) * J;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_0;
} else if (t_0 <= 2e+282) {
tmp = U + (J * (l * (2.0 * cos((K * 0.5)))));
} else {
tmp = t_0 + U;
}
return tmp;
}
public static double code(double J, double l, double K, double U) {
double t_0 = (Math.exp(l) - Math.exp(-l)) * J;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_0;
} else if (t_0 <= 2e+282) {
tmp = U + (J * (l * (2.0 * Math.cos((K * 0.5)))));
} else {
tmp = t_0 + U;
}
return tmp;
}
def code(J, l, K, U): t_0 = (math.exp(l) - math.exp(-l)) * J tmp = 0 if t_0 <= -math.inf: tmp = t_0 elif t_0 <= 2e+282: tmp = U + (J * (l * (2.0 * math.cos((K * 0.5))))) else: tmp = t_0 + U return tmp
function code(J, l, K, U) t_0 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_0; elseif (t_0 <= 2e+282) tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 * cos(Float64(K * 0.5)))))); else tmp = Float64(t_0 + U); end return tmp end
function tmp_2 = code(J, l, K, U) t_0 = (exp(l) - exp(-l)) * J; tmp = 0.0; if (t_0 <= -Inf) tmp = t_0; elseif (t_0 <= 2e+282) tmp = U + (J * (l * (2.0 * cos((K * 0.5))))); else tmp = t_0 + U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$0, If[LessEqual[t$95$0, 2e+282], N[(U + N[(J * N[(l * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+282}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 + U\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -inf.0Initial program 100.0%
Taylor expanded in K around 0 70.2%
Taylor expanded in J around inf 70.2%
if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 2.00000000000000007e282Initial program 74.4%
Taylor expanded in l around 0 98.7%
*-commutative98.7%
associate-*l*98.7%
associate-*r*98.7%
*-commutative98.7%
Simplified98.7%
if 2.00000000000000007e282 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
Taylor expanded in K around 0 80.0%
Final simplification87.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (- (exp l) (exp (- l))) J)))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+282)))
t_0
(+ U (* J (* l (* 2.0 (cos (* K 0.5)))))))))
double code(double J, double l, double K, double U) {
double t_0 = (exp(l) - exp(-l)) * J;
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 2e+282)) {
tmp = t_0;
} else {
tmp = U + (J * (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)) * J;
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 2e+282)) {
tmp = t_0;
} else {
tmp = U + (J * (l * (2.0 * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): t_0 = (math.exp(l) - math.exp(-l)) * J tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 2e+282): tmp = t_0 else: tmp = U + (J * (l * (2.0 * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) t_0 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 2e+282)) tmp = t_0; else tmp = Float64(U + Float64(J * Float64(l * Float64(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)) * J; tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 2e+282))) tmp = t_0; else tmp = U + (J * (l * (2.0 * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 2e+282]], $MachinePrecision]], t$95$0, N[(U + N[(J * N[(l * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 2 \cdot 10^{+282}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < -inf.0 or 2.00000000000000007e282 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) Initial program 100.0%
Taylor expanded in K around 0 75.4%
Taylor expanded in J around inf 75.4%
if -inf.0 < (*.f64 J (-.f64 (exp.f64 l) (exp.f64 (neg.f64 l)))) < 2.00000000000000007e282Initial program 74.4%
Taylor expanded in l around 0 98.7%
*-commutative98.7%
associate-*l*98.7%
associate-*r*98.7%
*-commutative98.7%
Simplified98.7%
Final simplification87.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0
(+ U (* (pow l 5.0) (* (cos (* K 0.5)) (* J 0.016666666666666666)))))
(t_1 (* (- (exp l) (exp (- l))) J)))
(if (<= l -6.4e+49)
t_0
(if (<= l -260.0)
t_1
(if (<= l 0.18)
(fma J (* (cos (/ K 2.0)) (* l 2.0)) U)
(if (<= l 1.42e+41) (+ t_1 U) t_0))))))
double code(double J, double l, double K, double U) {
double t_0 = U + (pow(l, 5.0) * (cos((K * 0.5)) * (J * 0.016666666666666666)));
double t_1 = (exp(l) - exp(-l)) * J;
double tmp;
if (l <= -6.4e+49) {
tmp = t_0;
} else if (l <= -260.0) {
tmp = t_1;
} else if (l <= 0.18) {
tmp = fma(J, (cos((K / 2.0)) * (l * 2.0)), U);
} else if (l <= 1.42e+41) {
tmp = t_1 + U;
} else {
tmp = t_0;
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(U + Float64((l ^ 5.0) * Float64(cos(Float64(K * 0.5)) * Float64(J * 0.016666666666666666)))) t_1 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) tmp = 0.0 if (l <= -6.4e+49) tmp = t_0; elseif (l <= -260.0) tmp = t_1; elseif (l <= 0.18) tmp = fma(J, Float64(cos(Float64(K / 2.0)) * Float64(l * 2.0)), U); elseif (l <= 1.42e+41) tmp = Float64(t_1 + 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[(N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision] * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[l, -6.4e+49], t$95$0, If[LessEqual[l, -260.0], t$95$1, If[LessEqual[l, 0.18], N[(J * N[(N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision] * N[(l * 2.0), $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.42e+41], N[(t$95$1 + U), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := U + {\ell}^{5} \cdot \left(\cos \left(K \cdot 0.5\right) \cdot \left(J \cdot 0.016666666666666666\right)\right)\\
t_1 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -6.4 \cdot 10^{+49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq -260:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq 0.18:\\
\;\;\;\;\mathsf{fma}\left(J, \cos \left(\frac{K}{2}\right) \cdot \left(\ell \cdot 2\right), U\right)\\
\mathbf{elif}\;\ell \leq 1.42 \cdot 10^{+41}:\\
\;\;\;\;t\_1 + U\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < -6.40000000000000028e49 or 1.42000000000000007e41 < l Initial program 100.0%
Taylor expanded in l around 0 98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in l around inf 98.1%
*-commutative98.1%
associate-*r*98.1%
associate-*l*98.1%
*-commutative98.1%
associate-*r*98.1%
*-commutative98.1%
Simplified98.1%
if -6.40000000000000028e49 < l < -260Initial program 100.0%
Taylor expanded in K around 0 85.7%
Taylor expanded in J around inf 85.7%
if -260 < l < 0.17999999999999999Initial program 74.4%
associate-*l*74.4%
fma-define74.4%
Simplified74.4%
Taylor expanded in l around 0 98.7%
if 0.17999999999999999 < l < 1.42000000000000007e41Initial program 100.0%
Taylor expanded in K around 0 80.0%
Final simplification97.4%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (+ U (* (pow l 5.0) (* t_0 (* J 0.016666666666666666)))))
(t_2 (* (- (exp l) (exp (- l))) J)))
(if (<= l -6.4e+49)
t_1
(if (<= l -26.5)
t_2
(if (<= l 0.018)
(+ U (* J (* l (* t_0 (+ 2.0 (* (pow l 2.0) 0.3333333333333333))))))
(if (<= l 1.42e+41) (+ t_2 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) * (t_0 * (J * 0.016666666666666666)));
double t_2 = (exp(l) - exp(-l)) * J;
double tmp;
if (l <= -6.4e+49) {
tmp = t_1;
} else if (l <= -26.5) {
tmp = t_2;
} else if (l <= 0.018) {
tmp = U + (J * (l * (t_0 * (2.0 + (pow(l, 2.0) * 0.3333333333333333)))));
} else if (l <= 1.42e+41) {
tmp = t_2 + U;
} 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 + ((l ** 5.0d0) * (t_0 * (j * 0.016666666666666666d0)))
t_2 = (exp(l) - exp(-l)) * j
if (l <= (-6.4d+49)) then
tmp = t_1
else if (l <= (-26.5d0)) then
tmp = t_2
else if (l <= 0.018d0) then
tmp = u + (j * (l * (t_0 * (2.0d0 + ((l ** 2.0d0) * 0.3333333333333333d0)))))
else if (l <= 1.42d+41) then
tmp = t_2 + u
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 + (Math.pow(l, 5.0) * (t_0 * (J * 0.016666666666666666)));
double t_2 = (Math.exp(l) - Math.exp(-l)) * J;
double tmp;
if (l <= -6.4e+49) {
tmp = t_1;
} else if (l <= -26.5) {
tmp = t_2;
} else if (l <= 0.018) {
tmp = U + (J * (l * (t_0 * (2.0 + (Math.pow(l, 2.0) * 0.3333333333333333)))));
} else if (l <= 1.42e+41) {
tmp = t_2 + 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) * (t_0 * (J * 0.016666666666666666))) t_2 = (math.exp(l) - math.exp(-l)) * J tmp = 0 if l <= -6.4e+49: tmp = t_1 elif l <= -26.5: tmp = t_2 elif l <= 0.018: tmp = U + (J * (l * (t_0 * (2.0 + (math.pow(l, 2.0) * 0.3333333333333333))))) elif l <= 1.42e+41: tmp = t_2 + 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(t_0 * Float64(J * 0.016666666666666666)))) t_2 = Float64(Float64(exp(l) - exp(Float64(-l))) * J) tmp = 0.0 if (l <= -6.4e+49) tmp = t_1; elseif (l <= -26.5) tmp = t_2; elseif (l <= 0.018) tmp = Float64(U + Float64(J * Float64(l * Float64(t_0 * Float64(2.0 + Float64((l ^ 2.0) * 0.3333333333333333)))))); elseif (l <= 1.42e+41) tmp = Float64(t_2 + U); 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 + ((l ^ 5.0) * (t_0 * (J * 0.016666666666666666))); t_2 = (exp(l) - exp(-l)) * J; tmp = 0.0; if (l <= -6.4e+49) tmp = t_1; elseif (l <= -26.5) tmp = t_2; elseif (l <= 0.018) tmp = U + (J * (l * (t_0 * (2.0 + ((l ^ 2.0) * 0.3333333333333333))))); elseif (l <= 1.42e+41) tmp = t_2 + U; 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[Power[l, 5.0], $MachinePrecision] * N[(t$95$0 * N[(J * 0.016666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision] * J), $MachinePrecision]}, If[LessEqual[l, -6.4e+49], t$95$1, If[LessEqual[l, -26.5], t$95$2, If[LessEqual[l, 0.018], N[(U + N[(J * N[(l * N[(t$95$0 * N[(2.0 + N[(N[Power[l, 2.0], $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.42e+41], N[(t$95$2 + U), $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(t\_0 \cdot \left(J \cdot 0.016666666666666666\right)\right)\\
t_2 := \left(e^{\ell} - e^{-\ell}\right) \cdot J\\
\mathbf{if}\;\ell \leq -6.4 \cdot 10^{+49}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -26.5:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq 0.018:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(t\_0 \cdot \left(2 + {\ell}^{2} \cdot 0.3333333333333333\right)\right)\right)\\
\mathbf{elif}\;\ell \leq 1.42 \cdot 10^{+41}:\\
\;\;\;\;t\_2 + U\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -6.40000000000000028e49 or 1.42000000000000007e41 < l Initial program 100.0%
Taylor expanded in l around 0 98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in l around inf 98.1%
*-commutative98.1%
associate-*r*98.1%
associate-*l*98.1%
*-commutative98.1%
associate-*r*98.1%
*-commutative98.1%
Simplified98.1%
if -6.40000000000000028e49 < l < -26.5Initial program 100.0%
Taylor expanded in K around 0 85.7%
Taylor expanded in J around inf 85.7%
if -26.5 < l < 0.0179999999999999986Initial program 74.4%
Taylor expanded in l around 0 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in J around 0 99.9%
Taylor expanded in l around 0 99.6%
associate-*r*99.6%
*-commutative99.6%
distribute-rgt-out99.6%
*-commutative99.6%
Simplified99.6%
if 0.0179999999999999986 < l < 1.42000000000000007e41Initial program 100.0%
Taylor expanded in K around 0 80.0%
Final simplification97.9%
(FPCore (J l K U) :precision binary64 (if (or (<= l -3.7e+16) (not (<= l 1.08e+19))) (+ U (* 0.016666666666666666 (* J (pow l 5.0)))) (+ U (* J (* l (* 2.0 (cos (* K 0.5))))))))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3.7e+16) || !(l <= 1.08e+19)) {
tmp = U + (0.016666666666666666 * (J * pow(l, 5.0)));
} else {
tmp = U + (J * (l * (2.0 * 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 <= (-3.7d+16)) .or. (.not. (l <= 1.08d+19))) then
tmp = u + (0.016666666666666666d0 * (j * (l ** 5.0d0)))
else
tmp = u + (j * (l * (2.0d0 * 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 <= -3.7e+16) || !(l <= 1.08e+19)) {
tmp = U + (0.016666666666666666 * (J * Math.pow(l, 5.0)));
} else {
tmp = U + (J * (l * (2.0 * Math.cos((K * 0.5)))));
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -3.7e+16) or not (l <= 1.08e+19): tmp = U + (0.016666666666666666 * (J * math.pow(l, 5.0))) else: tmp = U + (J * (l * (2.0 * math.cos((K * 0.5))))) return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -3.7e+16) || !(l <= 1.08e+19)) tmp = Float64(U + Float64(0.016666666666666666 * Float64(J * (l ^ 5.0)))); else tmp = Float64(U + Float64(J * Float64(l * Float64(2.0 * cos(Float64(K * 0.5)))))); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if ((l <= -3.7e+16) || ~((l <= 1.08e+19))) tmp = U + (0.016666666666666666 * (J * (l ^ 5.0))); else tmp = U + (J * (l * (2.0 * cos((K * 0.5))))); end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3.7e+16], N[Not[LessEqual[l, 1.08e+19]], $MachinePrecision]], N[(U + N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(U + N[(J * N[(l * N[(2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.7 \cdot 10^{+16} \lor \neg \left(\ell \leq 1.08 \cdot 10^{+19}\right):\\
\;\;\;\;U + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;U + J \cdot \left(\ell \cdot \left(2 \cdot \cos \left(K \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if l < -3.7e16 or 1.08e19 < l Initial program 100.0%
Taylor expanded in l around 0 90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in l around inf 90.2%
*-commutative90.2%
associate-*r*90.2%
associate-*l*90.2%
*-commutative90.2%
associate-*r*90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in K around 0 67.1%
if -3.7e16 < l < 1.08e19Initial program 75.3%
Taylor expanded in l around 0 95.3%
*-commutative95.3%
associate-*l*95.3%
associate-*r*95.3%
*-commutative95.3%
Simplified95.3%
Final simplification82.4%
(FPCore (J l K U) :precision binary64 (if (or (<= l -3.15e+16) (not (<= l 3.3))) (+ U (* 0.016666666666666666 (* J (pow l 5.0)))) (fma (* J 2.0) l U)))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -3.15e+16) || !(l <= 3.3)) {
tmp = U + (0.016666666666666666 * (J * pow(l, 5.0)));
} else {
tmp = fma((J * 2.0), l, U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if ((l <= -3.15e+16) || !(l <= 3.3)) tmp = Float64(U + Float64(0.016666666666666666 * Float64(J * (l ^ 5.0)))); else tmp = fma(Float64(J * 2.0), l, U); end return tmp end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -3.15e+16], N[Not[LessEqual[l, 3.3]], $MachinePrecision]], N[(U + N[(0.016666666666666666 * N[(J * N[Power[l, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(J * 2.0), $MachinePrecision] * l + U), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.15 \cdot 10^{+16} \lor \neg \left(\ell \leq 3.3\right):\\
\;\;\;\;U + 0.016666666666666666 \cdot \left(J \cdot {\ell}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(J \cdot 2, \ell, U\right)\\
\end{array}
\end{array}
if l < -3.15e16 or 3.2999999999999998 < l Initial program 100.0%
Taylor expanded in l around 0 88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in l around inf 88.9%
*-commutative88.9%
associate-*r*88.9%
associate-*l*88.9%
*-commutative88.9%
associate-*r*88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in K around 0 65.5%
if -3.15e16 < l < 3.2999999999999998Initial program 74.8%
Taylor expanded in l around 0 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in l around 0 97.3%
*-commutative97.3%
associate-*l*97.3%
Simplified97.3%
Taylor expanded in K around 0 83.9%
+-commutative83.9%
associate-*r*83.9%
fma-define83.9%
Simplified83.9%
Final simplification75.3%
(FPCore (J l K U) :precision binary64 (fma (* J 2.0) l U))
double code(double J, double l, double K, double U) {
return fma((J * 2.0), l, U);
}
function code(J, l, K, U) return fma(Float64(J * 2.0), l, U) end
code[J_, l_, K_, U_] := N[(N[(J * 2.0), $MachinePrecision] * l + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(J \cdot 2, \ell, U\right)
\end{array}
Initial program 86.6%
Taylor expanded in l around 0 94.0%
*-commutative94.0%
Simplified94.0%
Taylor expanded in l around 0 64.2%
*-commutative64.2%
associate-*l*64.2%
Simplified64.2%
Taylor expanded in K around 0 54.1%
+-commutative54.1%
associate-*r*54.1%
fma-define54.1%
Simplified54.1%
Final simplification54.1%
(FPCore (J l K U) :precision binary64 (if (or (<= l -6.5e+49) (not (<= l 1.35e+23))) (* U U) U))
double code(double J, double l, double K, double U) {
double tmp;
if ((l <= -6.5e+49) || !(l <= 1.35e+23)) {
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.5d+49)) .or. (.not. (l <= 1.35d+23))) 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.5e+49) || !(l <= 1.35e+23)) {
tmp = U * U;
} else {
tmp = U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if (l <= -6.5e+49) or not (l <= 1.35e+23): tmp = U * U else: tmp = U return tmp
function code(J, l, K, U) tmp = 0.0 if ((l <= -6.5e+49) || !(l <= 1.35e+23)) 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.5e+49) || ~((l <= 1.35e+23))) tmp = U * U; else tmp = U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[Or[LessEqual[l, -6.5e+49], N[Not[LessEqual[l, 1.35e+23]], $MachinePrecision]], N[(U * U), $MachinePrecision], U]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -6.5 \cdot 10^{+49} \lor \neg \left(\ell \leq 1.35 \cdot 10^{+23}\right):\\
\;\;\;\;U \cdot U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if l < -6.5000000000000005e49 or 1.3499999999999999e23 < l Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
Applied egg-rr14.4%
if -6.5000000000000005e49 < l < 1.3499999999999999e23Initial program 76.7%
associate-*l*76.7%
fma-define76.7%
Simplified76.7%
Taylor expanded in J around 0 65.6%
Final simplification43.8%
(FPCore (J l K U) :precision binary64 (if (<= l -750.0) (- (* U U) U) (if (<= l 1.4e+23) U (* U U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -750.0) {
tmp = (U * U) - U;
} else if (l <= 1.4e+23) {
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 <= (-750.0d0)) then
tmp = (u * u) - u
else if (l <= 1.4d+23) 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 <= -750.0) {
tmp = (U * U) - U;
} else if (l <= 1.4e+23) {
tmp = U;
} else {
tmp = U * U;
}
return tmp;
}
def code(J, l, K, U): tmp = 0 if l <= -750.0: tmp = (U * U) - U elif l <= 1.4e+23: tmp = U else: tmp = U * U return tmp
function code(J, l, K, U) tmp = 0.0 if (l <= -750.0) tmp = Float64(Float64(U * U) - U); elseif (l <= 1.4e+23) tmp = U; else tmp = Float64(U * U); end return tmp end
function tmp_2 = code(J, l, K, U) tmp = 0.0; if (l <= -750.0) tmp = (U * U) - U; elseif (l <= 1.4e+23) tmp = U; else tmp = U * U; end tmp_2 = tmp; end
code[J_, l_, K_, U_] := If[LessEqual[l, -750.0], N[(N[(U * U), $MachinePrecision] - U), $MachinePrecision], If[LessEqual[l, 1.4e+23], U, N[(U * U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -750:\\
\;\;\;\;U \cdot U - U\\
\mathbf{elif}\;\ell \leq 1.4 \cdot 10^{+23}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;U \cdot U\\
\end{array}
\end{array}
if l < -750Initial program 100.0%
Taylor expanded in l around 0 24.6%
associate-*r*24.6%
Simplified24.6%
Applied egg-rr16.6%
fmm-undef16.6%
Simplified16.6%
if -750 < l < 1.4e23Initial program 75.3%
associate-*l*75.3%
fma-define75.3%
Simplified75.3%
Taylor expanded in J around 0 69.2%
if 1.4e23 < l Initial program 100.0%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
Applied egg-rr10.3%
Final simplification43.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.6%
Taylor expanded in l around 0 94.0%
*-commutative94.0%
Simplified94.0%
Taylor expanded in l around 0 64.2%
*-commutative64.2%
associate-*l*64.2%
Simplified64.2%
Taylor expanded in K around 0 54.1%
Final simplification54.1%
(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.6%
associate-*l*86.6%
fma-define86.6%
Simplified86.6%
Taylor expanded in J around 0 38.6%
Final simplification38.6%
herbie shell --seed 2024100
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))