
(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 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
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)));
}
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
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)));
}
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)))
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
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
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}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 76.6%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6497.4
Simplified97.4%
Final simplification97.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* M (- M)))))
(if (<= M -6200.0)
t_0
(if (<= M 28.0)
(exp (fma -0.25 (* (+ m n) (+ m n)) (- (fabs (- m n)) 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 <= -6200.0) {
tmp = t_0;
} else if (M <= 28.0) {
tmp = exp(fma(-0.25, ((m + n) * (m + n)), (fabs((m - n)) - l)));
} else {
tmp = t_0;
}
return tmp;
}
function code(K, m, n, M, l) t_0 = exp(Float64(M * Float64(-M))) tmp = 0.0 if (M <= -6200.0) tmp = t_0; elseif (M <= 28.0) tmp = exp(fma(-0.25, Float64(Float64(m + n) * Float64(m + n)), Float64(abs(Float64(m - n)) - 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, -6200.0], t$95$0, If[LessEqual[M, 28.0], N[Exp[N[(-0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -6200:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 28:\\
\;\;\;\;e^{\mathsf{fma}\left(-0.25, \left(m + n\right) \cdot \left(m + n\right), \left|m - n\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -6200 or 28 < M Initial program 80.5%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f64100.0
Simplified100.0%
Taylor expanded in M around inf
unpow2N/A
lower-*.f6483.7
Simplified83.7%
Taylor expanded in M around 0
Simplified83.0%
Taylor expanded in M around inf
mul-1-negN/A
lower-neg.f64N/A
unpow2N/A
lower-*.f6499.3
Simplified99.3%
if -6200 < M < 28Initial program 72.5%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified34.3%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified31.8%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified94.5%
Final simplification97.0%
(FPCore (K m n M l)
:precision binary64
(if (<= m -0.00092)
(exp (* m (* m -0.25)))
(if (<= m -7.2e-300)
(exp (- (- (fabs (- m n)) l) (* M M)))
(exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.00092) {
tmp = exp((m * (m * -0.25)));
} else if (m <= -7.2e-300) {
tmp = exp(((fabs((m - n)) - l) - (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 <= (-0.00092d0)) then
tmp = exp((m * (m * (-0.25d0))))
else if (m <= (-7.2d-300)) then
tmp = exp(((abs((m - n)) - l) - (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 <= -0.00092) {
tmp = Math.exp((m * (m * -0.25)));
} else if (m <= -7.2e-300) {
tmp = Math.exp(((Math.abs((m - n)) - l) - (M * M)));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -0.00092: tmp = math.exp((m * (m * -0.25))) elif m <= -7.2e-300: tmp = math.exp(((math.fabs((m - n)) - l) - (M * M))) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -0.00092) tmp = exp(Float64(m * Float64(m * -0.25))); elseif (m <= -7.2e-300) tmp = exp(Float64(Float64(abs(Float64(m - n)) - l) - 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 <= -0.00092) tmp = exp((m * (m * -0.25))); elseif (m <= -7.2e-300) tmp = exp(((abs((m - n)) - l) - (M * M))); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.00092], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -7.2e-300], N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.00092:\\
\;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq -7.2 \cdot 10^{-300}:\\
\;\;\;\;e^{\left(\left|m - n\right| - \ell\right) - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -9.2000000000000003e-4Initial program 62.7%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified16.9%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified16.9%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified98.3%
Taylor expanded in m around inf
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.3
Simplified98.3%
if -9.2000000000000003e-4 < m < -7.20000000000000031e-300Initial program 85.3%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6495.9
Simplified95.9%
Taylor expanded in M around inf
unpow2N/A
lower-*.f6472.7
Simplified72.7%
Taylor expanded in M around 0
Simplified72.7%
if -7.20000000000000031e-300 < m Initial program 78.2%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified33.6%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified25.8%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified87.6%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.7
Simplified56.7%
Final simplification70.8%
(FPCore (K m n M l) :precision binary64 (if (<= n 2.8e-177) (exp (* m (* m -0.25))) (if (<= n 54.0) (exp (* M (- M))) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 2.8e-177) {
tmp = exp((m * (m * -0.25)));
} else if (n <= 54.0) {
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 (n <= 2.8d-177) then
tmp = exp((m * (m * (-0.25d0))))
else if (n <= 54.0d0) 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 (n <= 2.8e-177) {
tmp = Math.exp((m * (m * -0.25)));
} else if (n <= 54.0) {
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 n <= 2.8e-177: tmp = math.exp((m * (m * -0.25))) elif n <= 54.0: 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 (n <= 2.8e-177) tmp = exp(Float64(m * Float64(m * -0.25))); elseif (n <= 54.0) tmp = exp(Float64(M * Float64(-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 (n <= 2.8e-177) tmp = exp((m * (m * -0.25))); elseif (n <= 54.0) tmp = exp((M * -M)); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 2.8e-177], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 54.0], 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}\;n \leq 2.8 \cdot 10^{-177}:\\
\;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 2.79999999999999987e-177Initial program 80.3%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified40.9%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified31.0%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified89.6%
Taylor expanded in m around inf
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.3
Simplified59.3%
if 2.79999999999999987e-177 < n < 54Initial program 76.8%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6492.0
Simplified92.0%
Taylor expanded in M around inf
unpow2N/A
lower-*.f6465.4
Simplified65.4%
Taylor expanded in M around 0
Simplified62.7%
Taylor expanded in M around inf
mul-1-negN/A
lower-neg.f64N/A
unpow2N/A
lower-*.f6463.1
Simplified63.1%
if 54 < n Initial program 66.7%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified15.0%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified15.0%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified100.0%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.4
Simplified98.4%
Final simplification69.0%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (exp (* m (* m -0.25))))) (if (<= m -0.00092) t_0 (if (<= m 1.75e-47) (exp (- l)) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((m * (m * -0.25)));
double tmp;
if (m <= -0.00092) {
tmp = t_0;
} else if (m <= 1.75e-47) {
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((m * (m * (-0.25d0))))
if (m <= (-0.00092d0)) then
tmp = t_0
else if (m <= 1.75d-47) 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((m * (m * -0.25)));
double tmp;
if (m <= -0.00092) {
tmp = t_0;
} else if (m <= 1.75e-47) {
tmp = Math.exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((m * (m * -0.25))) tmp = 0 if m <= -0.00092: tmp = t_0 elif m <= 1.75e-47: tmp = math.exp(-l) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(m * Float64(m * -0.25))) tmp = 0.0 if (m <= -0.00092) tmp = t_0; elseif (m <= 1.75e-47) tmp = exp(Float64(-l)); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((m * (m * -0.25))); tmp = 0.0; if (m <= -0.00092) tmp = t_0; elseif (m <= 1.75e-47) 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[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -0.00092], t$95$0, If[LessEqual[m, 1.75e-47], N[Exp[(-l)], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{if}\;m \leq -0.00092:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 1.75 \cdot 10^{-47}:\\
\;\;\;\;e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -9.2000000000000003e-4 or 1.7499999999999999e-47 < m Initial program 69.6%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified21.7%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified20.3%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified95.0%
Taylor expanded in m around inf
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6492.9
Simplified92.9%
if -9.2000000000000003e-4 < m < 1.7499999999999999e-47Initial program 84.9%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified51.0%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified32.6%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified78.6%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6447.3
Simplified47.3%
(FPCore (K m n M l) :precision binary64 (if (<= n 1.7e-16) (exp (* m (* m -0.25))) (exp (* -0.25 (* n n)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1.7e-16) {
tmp = exp((m * (m * -0.25)));
} 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 (n <= 1.7d-16) then
tmp = exp((m * (m * (-0.25d0))))
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 (n <= 1.7e-16) {
tmp = Math.exp((m * (m * -0.25)));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 1.7e-16: tmp = math.exp((m * (m * -0.25))) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 1.7e-16) tmp = exp(Float64(m * Float64(m * -0.25))); 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 (n <= 1.7e-16) tmp = exp((m * (m * -0.25))); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1.7e-16], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.7 \cdot 10^{-16}:\\
\;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 1.7e-16Initial program 79.4%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified41.0%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified29.3%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified84.4%
Taylor expanded in m around inf
*-commutativeN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6456.9
Simplified56.9%
if 1.7e-16 < n Initial program 68.3%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified17.5%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified15.9%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified96.9%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.3
Simplified95.3%
Final simplification66.3%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (fma (* -0.125 (* K K)) (* (+ m n) (+ m n)) 1.0))) (if (<= l -9e+116) (fma l (* t_0 (fma 0.5 l -1.0)) t_0) (cos M))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fma((-0.125 * (K * K)), ((m + n) * (m + n)), 1.0);
double tmp;
if (l <= -9e+116) {
tmp = fma(l, (t_0 * fma(0.5, l, -1.0)), t_0);
} else {
tmp = cos(M);
}
return tmp;
}
function code(K, m, n, M, l) t_0 = fma(Float64(-0.125 * Float64(K * K)), Float64(Float64(m + n) * Float64(m + n)), 1.0) tmp = 0.0 if (l <= -9e+116) tmp = fma(l, Float64(t_0 * fma(0.5, l, -1.0)), t_0); else tmp = cos(M); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[l, -9e+116], N[(l * N[(t$95$0 * N[(0.5 * l + -1.0), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], N[Cos[M], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)\\
\mathbf{if}\;\ell \leq -9 \cdot 10^{+116}:\\
\;\;\;\;\mathsf{fma}\left(\ell, t\_0 \cdot \mathsf{fma}\left(0.5, \ell, -1\right), t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\cos M\\
\end{array}
\end{array}
if l < -9.00000000000000032e116Initial program 79.4%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified41.2%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified26.7%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6421.6
Simplified21.6%
Taylor expanded in l around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
Simplified21.6%
if -9.00000000000000032e116 < l Initial program 76.2%
Taylor expanded in M around inf
unpow2N/A
lower-*.f6448.7
Simplified48.7%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6432.0
Simplified32.0%
Taylor expanded in l around 0
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f647.2
Simplified7.2%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f647.5
Simplified7.5%
Final simplification9.4%
(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 76.6%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified35.2%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified26.0%
Taylor expanded in K around 0
fabs-subN/A
associate--r+N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
lower-exp.f64N/A
sub-negN/A
fabs-subN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-fma.f64N/A
Simplified87.5%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6435.0
Simplified35.0%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (fma (* -0.125 (* K K)) (* (+ m n) (+ m n)) 1.0))) (fma l (* t_0 (fma 0.5 l -1.0)) t_0)))
double code(double K, double m, double n, double M, double l) {
double t_0 = fma((-0.125 * (K * K)), ((m + n) * (m + n)), 1.0);
return fma(l, (t_0 * fma(0.5, l, -1.0)), t_0);
}
function code(K, m, n, M, l) t_0 = fma(Float64(-0.125 * Float64(K * K)), Float64(Float64(m + n) * Float64(m + n)), 1.0) return fma(l, Float64(t_0 * fma(0.5, l, -1.0)), t_0) end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, N[(l * N[(t$95$0 * N[(0.5 * l + -1.0), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)\\
\mathsf{fma}\left(\ell, t\_0 \cdot \mathsf{fma}\left(0.5, \ell, -1\right), t\_0\right)
\end{array}
\end{array}
Initial program 76.6%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified35.2%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified26.0%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6415.1
Simplified15.1%
Taylor expanded in l around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
Simplified7.5%
Final simplification7.5%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (* (+ m n) (+ m n)))) (fma l (fma 0.125 (* (* K K) t_0) -1.0) (fma (* -0.125 (* K K)) t_0 1.0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m + n) * (m + n);
return fma(l, fma(0.125, ((K * K) * t_0), -1.0), fma((-0.125 * (K * K)), t_0, 1.0));
}
function code(K, m, n, M, l) t_0 = Float64(Float64(m + n) * Float64(m + n)) return fma(l, fma(0.125, Float64(Float64(K * K) * t_0), -1.0), fma(Float64(-0.125 * Float64(K * K)), t_0, 1.0)) end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]}, N[(l * N[(0.125 * N[(N[(K * K), $MachinePrecision] * t$95$0), $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(m + n\right) \cdot \left(m + n\right)\\
\mathsf{fma}\left(\ell, \mathsf{fma}\left(0.125, \left(K \cdot K\right) \cdot t\_0, -1\right), \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), t\_0, 1\right)\right)
\end{array}
\end{array}
Initial program 76.6%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified35.2%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified26.0%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6415.1
Simplified15.1%
Taylor expanded in l around 0
+-commutativeN/A
associate-+l+N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
+-commutativeN/A
lower-fma.f64N/A
Simplified5.5%
Final simplification5.5%
(FPCore (K m n M l) :precision binary64 (fma (* -0.125 (* K K)) (* (+ m n) (+ m n)) 1.0))
double code(double K, double m, double n, double M, double l) {
return fma((-0.125 * (K * K)), ((m + n) * (m + n)), 1.0);
}
function code(K, m, n, M, l) return fma(Float64(-0.125 * Float64(K * K)), Float64(Float64(m + n) * Float64(m + n)), 1.0) end
code[K_, m_, n_, M_, l_] := N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)
\end{array}
Initial program 76.6%
Taylor expanded in K around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified35.2%
Taylor expanded in M around 0
lower-*.f64N/A
Simplified26.0%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6415.1
Simplified15.1%
Taylor expanded in l around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f645.2
Simplified5.2%
Final simplification5.2%
herbie shell --seed 2024215
(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)))))))