
(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 11 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}
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (fma 0.5 (+ n m) (- M)))) (* (cos M) (exp (- (fabs (- n m)) (fma t_0 t_0 l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fma(0.5, (n + m), -M);
return cos(M) * exp((fabs((n - m)) - fma(t_0, t_0, l)));
}
function code(K, m, n, M, l) t_0 = fma(0.5, Float64(n + m), Float64(-M)) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - fma(t_0, t_0, l)))) end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(0.5 * N[(n + m), $MachinePrecision] + (-M)), $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(t$95$0 * t$95$0 + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5, n + m, -M\right)\\
\cos M \cdot e^{\left|n - m\right| - \mathsf{fma}\left(t\_0, t\_0, \ell\right)}
\end{array}
\end{array}
Initial program 77.6%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites96.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- (* M M)))))
(if (<= M -1.65e+25)
t_0
(if (<= M 31.5)
(exp (- (fabs (- n m)) (fma 0.25 (* (+ n m) (+ n m)) l)))
t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-(M * M));
double tmp;
if (M <= -1.65e+25) {
tmp = t_0;
} else if (M <= 31.5) {
tmp = exp((fabs((n - m)) - fma(0.25, ((n + m) * (n + m)), l)));
} else {
tmp = t_0;
}
return tmp;
}
function code(K, m, n, M, l) t_0 = exp(Float64(-Float64(M * M))) tmp = 0.0 if (M <= -1.65e+25) tmp = t_0; elseif (M <= 31.5) tmp = exp(Float64(abs(Float64(n - m)) - fma(0.25, Float64(Float64(n + m) * Float64(n + m)), l))); else tmp = t_0; end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-N[(M * M), $MachinePrecision])], $MachinePrecision]}, If[LessEqual[M, -1.65e+25], t$95$0, If[LessEqual[M, 31.5], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(N[(n + m), $MachinePrecision] * N[(n + m), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-M \cdot M}\\
\mathbf{if}\;M \leq -1.65 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 31.5:\\
\;\;\;\;e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -1.6500000000000001e25 or 31.5 < M Initial program 79.8%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites100.0%
Taylor expanded in M around 0
Applied rewrites97.5%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6497.5
Applied rewrites97.5%
if -1.6500000000000001e25 < M < 31.5Initial program 75.6%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites93.3%
Taylor expanded in M around 0
fabs-subN/A
lower-exp.f64N/A
lower--.f64N/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
lower-+.f64N/A
lower-+.f6493.3
Applied rewrites93.3%
Final simplification95.3%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (fma 0.5 (+ n m) (- M)))) (exp (- (fabs (- n m)) (fma t_0 t_0 l)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fma(0.5, (n + m), -M);
return exp((fabs((n - m)) - fma(t_0, t_0, l)));
}
function code(K, m, n, M, l) t_0 = fma(0.5, Float64(n + m), Float64(-M)) return exp(Float64(abs(Float64(n - m)) - fma(t_0, t_0, l))) end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(0.5 * N[(n + m), $MachinePrecision] + (-M)), $MachinePrecision]}, N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(t$95$0 * t$95$0 + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.5, n + m, -M\right)\\
e^{\left|n - m\right| - \mathsf{fma}\left(t\_0, t\_0, \ell\right)}
\end{array}
\end{array}
Initial program 77.6%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites96.4%
Taylor expanded in M around 0
Applied rewrites95.2%
Final simplification95.2%
(FPCore (K m n M l)
:precision binary64
(if (<= m -55.0)
(exp (* -0.25 (* m m)))
(if (<= m 1.02e-210)
(exp (- (* M M)))
(exp (fma n (* n -0.25) (fabs (- n m)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = exp((-0.25 * (m * m)));
} else if (m <= 1.02e-210) {
tmp = exp(-(M * M));
} else {
tmp = exp(fma(n, (n * -0.25), fabs((n - m))));
}
return tmp;
}
function code(K, m, n, M, l) tmp = 0.0 if (m <= -55.0) tmp = exp(Float64(-0.25 * Float64(m * m))); elseif (m <= 1.02e-210) tmp = exp(Float64(-Float64(M * M))); else tmp = exp(fma(n, Float64(n * -0.25), abs(Float64(n - m)))); end return tmp end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -55.0], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 1.02e-210], N[Exp[(-N[(M * M), $MachinePrecision])], $MachinePrecision], N[Exp[N[(n * N[(n * -0.25), $MachinePrecision] + N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -55:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;m \leq 1.02 \cdot 10^{-210}:\\
\;\;\;\;e^{-M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{fma}\left(n, n \cdot -0.25, \left|n - m\right|\right)}\\
\end{array}
\end{array}
if m < -55Initial program 75.8%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites98.4%
Taylor expanded in M around 0
Applied rewrites98.4%
Taylor expanded in m around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6496.8
Applied rewrites96.8%
if -55 < m < 1.02000000000000002e-210Initial program 80.6%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites94.9%
Taylor expanded in M around 0
Applied rewrites92.7%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6447.0
Applied rewrites47.0%
if 1.02000000000000002e-210 < m Initial program 75.9%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites96.5%
Taylor expanded in M around 0
Applied rewrites95.5%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6450.7
Applied rewrites50.7%
lift--.f64N/A
lift-fabs.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-lft-identity50.7
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6450.7
Applied rewrites50.7%
Final simplification60.6%
(FPCore (K m n M l) :precision binary64 (if (<= m -55.0) (exp (* -0.25 (* m m))) (if (<= m 1.02e-210) (exp (- (* M M))) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = exp((-0.25 * (m * m)));
} else if (m <= 1.02e-210) {
tmp = exp(-(M * M));
} else {
tmp = exp((-0.25 * (n * n)));
}
return tmp;
}
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 (m <= (-55.0d0)) then
tmp = exp(((-0.25d0) * (m * m)))
else if (m <= 1.02d-210) then
tmp = exp(-(m_1 * m_1))
else
tmp = exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = Math.exp((-0.25 * (m * m)));
} else if (m <= 1.02e-210) {
tmp = Math.exp(-(M * M));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -55.0: tmp = math.exp((-0.25 * (m * m))) elif m <= 1.02e-210: tmp = math.exp(-(M * M)) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -55.0) tmp = exp(Float64(-0.25 * Float64(m * m))); elseif (m <= 1.02e-210) tmp = exp(Float64(-Float64(M * M))); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -55.0) tmp = exp((-0.25 * (m * m))); elseif (m <= 1.02e-210) tmp = exp(-(M * M)); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -55.0], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 1.02e-210], N[Exp[(-N[(M * M), $MachinePrecision])], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -55:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;m \leq 1.02 \cdot 10^{-210}:\\
\;\;\;\;e^{-M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -55Initial program 75.8%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites98.4%
Taylor expanded in M around 0
Applied rewrites98.4%
Taylor expanded in m around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6496.8
Applied rewrites96.8%
if -55 < m < 1.02000000000000002e-210Initial program 80.6%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites94.9%
Taylor expanded in M around 0
Applied rewrites92.7%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6447.0
Applied rewrites47.0%
if 1.02000000000000002e-210 < m Initial program 75.9%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites96.5%
Taylor expanded in M around 0
Applied rewrites95.5%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6457.5
Applied rewrites57.5%
Taylor expanded in n around inf
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.5
Applied rewrites57.5%
Final simplification63.3%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (exp (* -0.25 (* n n))))) (if (<= n -54.0) t_0 (if (<= n 55.0) (exp (- (* M M))) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-0.25 * (n * n)));
double tmp;
if (n <= -54.0) {
tmp = t_0;
} else if (n <= 55.0) {
tmp = exp(-(M * M));
} else {
tmp = t_0;
}
return tmp;
}
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(((-0.25d0) * (n * n)))
if (n <= (-54.0d0)) then
tmp = t_0
else if (n <= 55.0d0) then
tmp = exp(-(m_1 * m_1))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((-0.25 * (n * n)));
double tmp;
if (n <= -54.0) {
tmp = t_0;
} else if (n <= 55.0) {
tmp = Math.exp(-(M * M));
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-0.25 * (n * n))) tmp = 0 if n <= -54.0: tmp = t_0 elif n <= 55.0: tmp = math.exp(-(M * M)) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-0.25 * Float64(n * n))) tmp = 0.0 if (n <= -54.0) tmp = t_0; elseif (n <= 55.0) tmp = exp(Float64(-Float64(M * M))); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-0.25 * (n * n))); tmp = 0.0; if (n <= -54.0) tmp = t_0; elseif (n <= 55.0) tmp = exp(-(M * M)); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -54.0], t$95$0, If[LessEqual[n, 55.0], N[Exp[(-N[(M * M), $MachinePrecision])], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot \left(n \cdot n\right)}\\
\mathbf{if}\;n \leq -54:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 55:\\
\;\;\;\;e^{-M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -54 or 55 < n Initial program 69.7%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites97.9%
Taylor expanded in M around 0
Applied rewrites97.9%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6495.8
Applied rewrites95.8%
Taylor expanded in n around inf
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.8
Applied rewrites95.8%
if -54 < n < 55Initial program 87.4%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites94.6%
Taylor expanded in M around 0
Applied rewrites91.9%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6454.2
Applied rewrites54.2%
Final simplification77.3%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (exp (* -0.25 (* n n))))) (if (<= n -53.0) t_0 (if (<= n 52.0) (exp (- l)) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-0.25 * (n * n)));
double tmp;
if (n <= -53.0) {
tmp = t_0;
} else if (n <= 52.0) {
tmp = exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
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(((-0.25d0) * (n * n)))
if (n <= (-53.0d0)) then
tmp = t_0
else if (n <= 52.0d0) then
tmp = exp(-l)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp((-0.25 * (n * n)));
double tmp;
if (n <= -53.0) {
tmp = t_0;
} else if (n <= 52.0) {
tmp = Math.exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-0.25 * (n * n))) tmp = 0 if n <= -53.0: tmp = t_0 elif n <= 52.0: tmp = math.exp(-l) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-0.25 * Float64(n * n))) tmp = 0.0 if (n <= -53.0) tmp = t_0; elseif (n <= 52.0) tmp = exp(Float64(-l)); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-0.25 * (n * n))); tmp = 0.0; if (n <= -53.0) tmp = t_0; elseif (n <= 52.0) tmp = exp(-l); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -53.0], t$95$0, If[LessEqual[n, 52.0], N[Exp[(-l)], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot \left(n \cdot n\right)}\\
\mathbf{if}\;n \leq -53:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 52:\\
\;\;\;\;e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -53 or 52 < n Initial program 69.7%
Taylor expanded in K around 0
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
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
unpow2N/A
lower-fma.f64N/A
Applied rewrites97.9%
Taylor expanded in M around 0
Applied rewrites97.9%
Taylor expanded in n around inf
lower-*.f64N/A
unpow2N/A
lower-*.f6495.8
Applied rewrites95.8%
Taylor expanded in n around inf
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.8
Applied rewrites95.8%
if -53 < n < 52Initial program 87.4%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6436.7
Applied rewrites36.7%
Taylor expanded in n around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.2
Applied rewrites37.2%
Taylor expanded in n around 0
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6435.3
Applied rewrites35.3%
Final simplification68.9%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return exp(-l);
}
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
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 77.6%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6427.6
Applied rewrites27.6%
Taylor expanded in n around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6429.1
Applied rewrites29.1%
Taylor expanded in n around 0
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6430.5
Applied rewrites30.5%
(FPCore (K m n M l) :precision binary64 (* (fma K (* K (* (* n n) -0.125)) 1.0) (fma l (fma l (fma l -0.16666666666666666 0.5) -1.0) 1.0)))
double code(double K, double m, double n, double M, double l) {
return fma(K, (K * ((n * n) * -0.125)), 1.0) * fma(l, fma(l, fma(l, -0.16666666666666666, 0.5), -1.0), 1.0);
}
function code(K, m, n, M, l) return Float64(fma(K, Float64(K * Float64(Float64(n * n) * -0.125)), 1.0) * fma(l, fma(l, fma(l, -0.16666666666666666, 0.5), -1.0), 1.0)) end
code[K_, m_, n_, M_, l_] := N[(N[(K * N[(K * N[(N[(n * n), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[(l * N[(l * N[(l * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(K, K \cdot \left(\left(n \cdot n\right) \cdot -0.125\right), 1\right) \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right)
\end{array}
Initial program 77.6%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6427.6
Applied rewrites27.6%
Taylor expanded in n around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6429.1
Applied rewrites29.1%
Taylor expanded in l around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f649.6
Applied rewrites9.6%
Taylor expanded in n around 0
associate-*r*N/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.3
Applied rewrites8.3%
Final simplification8.3%
(FPCore (K m n M l) :precision binary64 (fma l (fma l (fma l -0.16666666666666666 0.5) -1.0) 1.0))
double code(double K, double m, double n, double M, double l) {
return fma(l, fma(l, fma(l, -0.16666666666666666, 0.5), -1.0), 1.0);
}
function code(K, m, n, M, l) return fma(l, fma(l, fma(l, -0.16666666666666666, 0.5), -1.0), 1.0) end
code[K_, m_, n_, M_, l_] := N[(l * N[(l * N[(l * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right)
\end{array}
Initial program 77.6%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6427.6
Applied rewrites27.6%
Taylor expanded in n around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6429.1
Applied rewrites29.1%
Taylor expanded in l around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f649.6
Applied rewrites9.6%
Taylor expanded in n around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f648.7
Applied rewrites8.7%
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
return 1.0;
}
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
public static double code(double K, double m, double n, double M, double l) {
return 1.0;
}
def code(K, m, n, M, l): return 1.0
function code(K, m, n, M, l) return 1.0 end
function tmp = code(K, m, n, M, l) tmp = 1.0; end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 77.6%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6437.7
Applied rewrites37.7%
Taylor expanded in m around 0
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f645.5
Applied rewrites5.5%
Taylor expanded in n around 0
cos-negN/A
lower-cos.f645.8
Applied rewrites5.8%
Taylor expanded in M around 0
Applied rewrites5.8%
herbie shell --seed 2024219
(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)))))))