
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (cos (- (/ (* (+ m n) K) 2.0) M))) (t_1 (fabs (- m n))))
(if (<= (* (exp (- (- t_1 l) (pow (- (/ (+ m n) 2.0) M) 2.0))) t_0) 0.0)
(*
t_0
(exp
(*
n
(*
n
(+
-0.25
(/
(+
(fma m -0.5 M)
(/ (- t_1 (fma (fma m -0.5 M) (fma m -0.5 M) l)) n))
n))))))
(exp (- t_1 (fma 0.25 (* (+ m n) (+ m n)) l))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(((((m + n) * K) / 2.0) - M));
double t_1 = fabs((m - n));
double tmp;
if ((exp(((t_1 - l) - pow((((m + n) / 2.0) - M), 2.0))) * t_0) <= 0.0) {
tmp = t_0 * exp((n * (n * (-0.25 + ((fma(m, -0.5, M) + ((t_1 - fma(fma(m, -0.5, M), fma(m, -0.5, M), l)) / n)) / n)))));
} else {
tmp = exp((t_1 - fma(0.25, ((m + n) * (m + n)), l)));
}
return tmp;
}
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) t_1 = abs(Float64(m - n)) tmp = 0.0 if (Float64(exp(Float64(Float64(t_1 - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) * t_0) <= 0.0) tmp = Float64(t_0 * exp(Float64(n * Float64(n * Float64(-0.25 + Float64(Float64(fma(m, -0.5, M) + Float64(Float64(t_1 - fma(fma(m, -0.5, M), fma(m, -0.5, M), l)) / n)) / n)))))); else tmp = exp(Float64(t_1 - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l))); end return tmp end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Exp[N[(N[(t$95$1 - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], 0.0], N[(t$95$0 * N[Exp[N[(n * N[(n * N[(-0.25 + N[(N[(N[(m * -0.5 + M), $MachinePrecision] + N[(N[(t$95$1 - N[(N[(m * -0.5 + M), $MachinePrecision] * N[(m * -0.5 + M), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$1 - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right)\\
t_1 := \left|m - n\right|\\
\mathbf{if}\;e^{\left(t\_1 - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot t\_0 \leq 0:\\
\;\;\;\;t\_0 \cdot e^{n \cdot \left(n \cdot \left(-0.25 + \frac{\mathsf{fma}\left(m, -0.5, M\right) + \frac{t\_1 - \mathsf{fma}\left(\mathsf{fma}\left(m, -0.5, M\right), \mathsf{fma}\left(m, -0.5, M\right), \ell\right)}{n}}{n}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_1 - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < -0.0Initial program 98.9%
Taylor expanded in n around -inf
Applied rewrites98.9%
if -0.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 34.2%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6496.4
Applied rewrites96.4%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6495.7
Applied rewrites95.7%
Final simplification98.0%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0)));
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 79.7%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6497.8
Applied rewrites97.8%
Final simplification97.8%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (* M (- M))))))
(if (<= M -5.5e+53)
t_0
(if (<= M 170.0)
(exp (- (fabs (- m n)) (fma 0.25 (* (+ m n) (+ m n)) l)))
t_0))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp((M * -M));
double tmp;
if (M <= -5.5e+53) {
tmp = t_0;
} else if (M <= 170.0) {
tmp = exp((fabs((m - n)) - fma(0.25, ((m + n) * (m + n)), l)));
} else {
tmp = t_0;
}
return tmp;
}
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(cos(M) * exp(Float64(M * Float64(-M)))) tmp = 0.0 if (M <= -5.5e+53) tmp = t_0; elseif (M <= 170.0) tmp = exp(Float64(abs(Float64(m - n)) - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l))); else tmp = t_0; end return tmp end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -5.5e+53], t$95$0, If[LessEqual[M, 170.0], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -5.5 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 170:\\
\;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -5.49999999999999975e53 or 170 < M Initial program 81.7%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f64100.0
Applied rewrites100.0%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6499.1
Applied rewrites99.1%
if -5.49999999999999975e53 < M < 170Initial program 78.2%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6496.2
Applied rewrites96.2%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6495.2
Applied rewrites95.2%
Final simplification96.9%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (<= M -7.6e+21)
(exp
(- t_0 (fma 0.25 (* n (* n (fma m (+ (/ 2.0 n) (/ m (* n n))) 1.0))) l)))
(exp (- t_0 (fma 0.25 (* (+ m n) (+ m n)) l))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if (M <= -7.6e+21) {
tmp = exp((t_0 - fma(0.25, (n * (n * fma(m, ((2.0 / n) + (m / (n * n))), 1.0))), l)));
} else {
tmp = exp((t_0 - fma(0.25, ((m + n) * (m + n)), l)));
}
return tmp;
}
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if (M <= -7.6e+21) tmp = exp(Float64(t_0 - fma(0.25, Float64(n * Float64(n * fma(m, Float64(Float64(2.0 / n) + Float64(m / Float64(n * n))), 1.0))), l))); else tmp = exp(Float64(t_0 - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l))); end return tmp end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -7.6e+21], N[Exp[N[(t$95$0 - N[(0.25 * N[(n * N[(n * N[(m * N[(N[(2.0 / n), $MachinePrecision] + N[(m / N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(t$95$0 - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;M \leq -7.6 \cdot 10^{+21}:\\
\;\;\;\;e^{t\_0 - \mathsf{fma}\left(0.25, n \cdot \left(n \cdot \mathsf{fma}\left(m, \frac{2}{n} + \frac{m}{n \cdot n}, 1\right)\right), \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\
\end{array}
\end{array}
if M < -7.6e21Initial program 85.2%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f64100.0
Applied rewrites100.0%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6472.9
Applied rewrites72.9%
Taylor expanded in n around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
associate-+l+N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
unpow2N/A
associate-/l*N/A
lower-fma.f64N/A
Applied rewrites80.1%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.1
Applied rewrites80.1%
if -7.6e21 < M Initial program 78.2%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6497.3
Applied rewrites97.3%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6493.1
Applied rewrites93.1%
Final simplification90.4%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (exp (- (fabs (- m n)) (fma 0.25 (* (+ m n) (+ m n)) l))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp((fabs((m - n)) - fma(0.25, ((m + n) * (m + n)), l)));
}
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return exp(Float64(abs(Float64(m - n)) - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l))) end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}
\end{array}
Initial program 79.7%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6497.8
Applied rewrites97.8%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6488.9
Applied rewrites88.9%
Final simplification88.9%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (let* ((t_0 (exp (* n (* n -0.25))))) (if (<= n -7.2e-16) t_0 (if (<= n 115000.0) (exp (- l)) t_0))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((n * (n * -0.25)));
double tmp;
if (n <= -7.2e-16) {
tmp = t_0;
} else if (n <= 115000.0) {
tmp = exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = exp((n * (n * (-0.25d0))))
if (n <= (-7.2d-16)) then
tmp = t_0
else if (n <= 115000.0d0) then
tmp = exp(-l)
else
tmp = t_0
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((n * (n * -0.25)));
double tmp;
if (n <= -7.2e-16) {
tmp = t_0;
} else if (n <= 115000.0) {
tmp = Math.exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.exp((n * (n * -0.25))) tmp = 0 if n <= -7.2e-16: tmp = t_0 elif n <= 115000.0: tmp = math.exp(-l) else: tmp = t_0 return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = exp(Float64(n * Float64(n * -0.25))) tmp = 0.0 if (n <= -7.2e-16) tmp = t_0; elseif (n <= 115000.0) tmp = exp(Float64(-l)); else tmp = t_0; end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
t_0 = exp((n * (n * -0.25)));
tmp = 0.0;
if (n <= -7.2e-16)
tmp = t_0;
elseif (n <= 115000.0)
tmp = exp(-l);
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -7.2e-16], t$95$0, If[LessEqual[n, 115000.0], N[Exp[(-l)], $MachinePrecision], t$95$0]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := e^{n \cdot \left(n \cdot -0.25\right)}\\
\mathbf{if}\;n \leq -7.2 \cdot 10^{-16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 115000:\\
\;\;\;\;e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -7.19999999999999965e-16 or 115000 < n Initial program 76.7%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6498.4
Applied rewrites98.4%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6497.7
Applied rewrites97.7%
Taylor expanded in n around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6495.4
Applied rewrites95.4%
if -7.19999999999999965e-16 < n < 115000Initial program 82.7%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6497.2
Applied rewrites97.2%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6479.9
Applied rewrites79.9%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6450.8
Applied rewrites50.8%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (<= n 115000.0) (exp (* -0.25 (* m m))) (exp (* n (* n -0.25)))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 115000.0) {
tmp = exp((-0.25 * (m * m)));
} else {
tmp = exp((n * (n * -0.25)));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (n <= 115000.0d0) then
tmp = exp(((-0.25d0) * (m * m)))
else
tmp = exp((n * (n * (-0.25d0))))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 115000.0) {
tmp = Math.exp((-0.25 * (m * m)));
} else {
tmp = Math.exp((n * (n * -0.25)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if n <= 115000.0: tmp = math.exp((-0.25 * (m * m))) else: tmp = math.exp((n * (n * -0.25))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (n <= 115000.0) tmp = exp(Float64(-0.25 * Float64(m * m))); else tmp = exp(Float64(n * Float64(n * -0.25))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (n <= 115000.0)
tmp = exp((-0.25 * (m * m)));
else
tmp = exp((n * (n * -0.25)));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[n, 115000.0], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;n \leq 115000:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{n \cdot \left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if n < 115000Initial program 79.8%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6497.2
Applied rewrites97.2%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6485.6
Applied rewrites85.6%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.3
Applied rewrites57.3%
if 115000 < n Initial program 79.3%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f64100.0
Applied rewrites100.0%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64100.0
Applied rewrites100.0%
Taylor expanded in n around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.3
Applied rewrites98.3%
Final simplification66.6%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (exp (- l)))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp(-l);
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(-l)
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.exp(-l)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return exp(Float64(-l)) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = exp(-l);
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{-\ell}
\end{array}
Initial program 79.7%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6497.8
Applied rewrites97.8%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
fabs-subN/A
sub-negN/A
mul-1-negN/A
lower-fabs.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6488.9
Applied rewrites88.9%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6435.3
Applied rewrites35.3%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (cos M))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1)
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.cos(M)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return cos(M) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = cos(M);
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M
\end{array}
Initial program 79.7%
Taylor expanded in n around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6444.7
Applied rewrites44.7%
Taylor expanded in n around 0
lower-cos.f64N/A
sub-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f648.3
Applied rewrites8.3%
Taylor expanded in m around 0
cos-negN/A
lower-cos.f648.7
Applied rewrites8.7%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 1.0)
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return 1.0;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = 1.0d0
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return 1.0;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return 1.0
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return 1.0 end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = 1.0;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
1
\end{array}
Initial program 79.7%
Taylor expanded in n around inf
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6444.7
Applied rewrites44.7%
Taylor expanded in n around 0
lower-cos.f64N/A
sub-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f648.3
Applied rewrites8.3%
Taylor expanded in m around 0
cos-negN/A
lower-cos.f648.7
Applied rewrites8.7%
Taylor expanded in M around 0
Applied rewrites8.7%
herbie shell --seed 2024214
(FPCore (K m n M l)
:name "Maksimov and Kolovsky, Equation (32)"
:precision binary64
(* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))