
(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 7 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 (- n m)) l) (pow (- (* (+ m n) 0.5) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((n - m)) - l) - pow((((m + n) * 0.5) - 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((n - m)) - l) - ((((m + n) * 0.5d0) - 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((n - m)) - l) - Math.pow((((m + n) * 0.5) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((n - m)) - l) - math.pow((((m + n) * 0.5) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((n - m)) - l) - ((((m + n) * 0.5) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}
\end{array}
Initial program 76.0%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
associate--r+96.4%
*-commutative96.4%
Simplified96.4%
Final simplification96.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 1.06e-237)
(exp (- t_0 (+ l (* 0.25 (* (+ m n) (+ m n))))))
(if (<= n 1.18e-5)
(*
(cos (- (/ (* (+ m n) K) 2.0) M))
(exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) (- t_0 l))))
(exp (- t_0 (* 0.25 (pow (+ m n) 2.0))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= 1.06e-237) {
tmp = exp((t_0 - (l + (0.25 * ((m + n) * (m + n))))));
} else if (n <= 1.18e-5) {
tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l)));
} else {
tmp = exp((t_0 - (0.25 * pow((m + n), 2.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 = abs((n - m))
if (n <= 1.06d-237) then
tmp = exp((t_0 - (l + (0.25d0 * ((m + n) * (m + n))))))
else if (n <= 1.18d-5) then
tmp = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + (t_0 - l)))
else
tmp = exp((t_0 - (0.25d0 * ((m + n) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.abs((n - m));
double tmp;
if (n <= 1.06e-237) {
tmp = Math.exp((t_0 - (l + (0.25 * ((m + n) * (m + n))))));
} else if (n <= 1.18e-5) {
tmp = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l)));
} else {
tmp = Math.exp((t_0 - (0.25 * Math.pow((m + n), 2.0))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if n <= 1.06e-237: tmp = math.exp((t_0 - (l + (0.25 * ((m + n) * (m + n)))))) elif n <= 1.18e-5: tmp = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l))) else: tmp = math.exp((t_0 - (0.25 * math.pow((m + n), 2.0)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= 1.06e-237) tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(Float64(m + n) * Float64(m + n)))))); elseif (n <= 1.18e-5) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + Float64(t_0 - l)))); else tmp = exp(Float64(t_0 - Float64(0.25 * (Float64(m + n) ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (n <= 1.06e-237) tmp = exp((t_0 - (l + (0.25 * ((m + n) * (m + n)))))); elseif (n <= 1.18e-5) tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l))); else tmp = exp((t_0 - (0.25 * ((m + n) ^ 2.0)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 1.06e-237], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 1.18e-5], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 1.06 \cdot 10^{-237}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right)}\\
\mathbf{elif}\;n \leq 1.18 \cdot 10^{-5}:\\
\;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + \left(t_0 - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - 0.25 \cdot {\left(m + n\right)}^{2}}\\
\end{array}
\end{array}
if n < 1.05999999999999994e-237Initial program 77.1%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
associate--r+94.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in M around 0 87.0%
+-commutative87.0%
+-commutative87.0%
Simplified87.0%
+-commutative87.0%
pow287.0%
Applied egg-rr87.0%
if 1.05999999999999994e-237 < n < 1.18000000000000005e-5Initial program 76.2%
Taylor expanded in n around 0 76.2%
+-commutative76.2%
unpow276.2%
distribute-rgt-out76.2%
*-commutative76.2%
*-commutative76.2%
Simplified76.2%
if 1.18000000000000005e-5 < n Initial program 73.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
associate--r+100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in M around 0 98.6%
+-commutative98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in l around 0 100.0%
fabs-sub100.0%
Simplified100.0%
Final simplification88.5%
(FPCore (K m n M l) :precision binary64 (if (<= m -2.7e+17) (* (cos (- (* (* (+ m n) 0.5) K) M)) (exp (- m l))) (exp (- (* 0.25 (pow m 2.0)) (+ n l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2.7e+17) {
tmp = cos(((((m + n) * 0.5) * K) - M)) * exp((m - l));
} else {
tmp = exp(((0.25 * pow(m, 2.0)) - (n + l)));
}
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 <= (-2.7d+17)) then
tmp = cos(((((m + n) * 0.5d0) * k) - m_1)) * exp((m - l))
else
tmp = exp(((0.25d0 * (m ** 2.0d0)) - (n + l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2.7e+17) {
tmp = Math.cos(((((m + n) * 0.5) * K) - M)) * Math.exp((m - l));
} else {
tmp = Math.exp(((0.25 * Math.pow(m, 2.0)) - (n + l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -2.7e+17: tmp = math.cos(((((m + n) * 0.5) * K) - M)) * math.exp((m - l)) else: tmp = math.exp(((0.25 * math.pow(m, 2.0)) - (n + l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -2.7e+17) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) * 0.5) * K) - M)) * exp(Float64(m - l))); else tmp = exp(Float64(Float64(0.25 * (m ^ 2.0)) - Float64(n + l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -2.7e+17) tmp = cos(((((m + n) * 0.5) * K) - M)) * exp((m - l)); else tmp = exp(((0.25 * (m ^ 2.0)) - (n + l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -2.7e+17], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] * K), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(m - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.7 \cdot 10^{+17}:\\
\;\;\;\;\cos \left(\left(\left(m + n\right) \cdot 0.5\right) \cdot K - M\right) \cdot e^{m - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{0.25 \cdot {m}^{2} - \left(n + \ell\right)}\\
\end{array}
\end{array}
if m < -2.7e17Initial program 72.7%
Applied egg-rr7.9%
expm1-def7.9%
expm1-log1p8.3%
fma-neg8.3%
associate-*r*8.3%
+-commutative8.3%
associate-+l-8.3%
associate--r-8.3%
+-commutative8.3%
Simplified8.3%
Taylor expanded in n around inf 42.1%
Taylor expanded in n around 0 69.1%
if -2.7e17 < m Initial program 76.8%
Applied egg-rr19.3%
expm1-def19.3%
expm1-log1p20.7%
fma-neg20.7%
associate-*r*20.7%
+-commutative20.7%
associate-+l-20.7%
associate--r-20.7%
+-commutative20.7%
Simplified20.7%
Taylor expanded in K around 0 20.6%
cos-neg20.6%
Simplified20.6%
Taylor expanded in M around 0 26.1%
Taylor expanded in m around inf 40.7%
Final simplification46.8%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- n m)) (+ l (* 0.25 (* (+ m n) (+ m n)))))))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((n - m)) - (l + (0.25 * ((m + n) * (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 = exp((abs((n - m)) - (l + (0.25d0 * ((m + n) * (m + n))))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((n - m)) - (l + (0.25 * ((m + n) * (m + n))))));
}
def code(K, m, n, M, l): return math.exp((math.fabs((n - m)) - (l + (0.25 * ((m + n) * (m + n))))))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(n - m)) - Float64(l + Float64(0.25 * Float64(Float64(m + n) * Float64(m + n)))))) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((n - m)) - (l + (0.25 * ((m + n) * (m + n)))))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|n - m\right| - \left(\ell + 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right)}
\end{array}
Initial program 76.0%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
associate--r+96.4%
*-commutative96.4%
Simplified96.4%
Taylor expanded in M around 0 87.2%
+-commutative87.2%
+-commutative87.2%
Simplified87.2%
+-commutative87.2%
pow287.2%
Applied egg-rr87.2%
Final simplification87.2%
(FPCore (K m n M l) :precision binary64 (if (<= l 7.2e-31) (exp (- (* 0.25 (pow m 2.0)) (+ n l))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 7.2e-31) {
tmp = exp(((0.25 * pow(m, 2.0)) - (n + l)));
} else {
tmp = cos(M) * exp(-l);
}
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 (l <= 7.2d-31) then
tmp = exp(((0.25d0 * (m ** 2.0d0)) - (n + l)))
else
tmp = cos(m_1) * exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 7.2e-31) {
tmp = Math.exp(((0.25 * Math.pow(m, 2.0)) - (n + l)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 7.2e-31: tmp = math.exp(((0.25 * math.pow(m, 2.0)) - (n + l))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 7.2e-31) tmp = exp(Float64(Float64(0.25 * (m ^ 2.0)) - Float64(n + l))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 7.2e-31) tmp = exp(((0.25 * (m ^ 2.0)) - (n + l))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 7.2e-31], N[Exp[N[(N[(0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 7.2 \cdot 10^{-31}:\\
\;\;\;\;e^{0.25 \cdot {m}^{2} - \left(n + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 7.20000000000000007e-31Initial program 72.7%
Applied egg-rr10.6%
expm1-def10.6%
expm1-log1p12.1%
fma-neg12.1%
associate-*r*12.1%
+-commutative12.1%
associate-+l-12.1%
associate--r-12.1%
+-commutative12.1%
Simplified12.1%
Taylor expanded in K around 0 12.1%
cos-neg12.1%
Simplified12.1%
Taylor expanded in M around 0 11.1%
Taylor expanded in m around inf 24.6%
if 7.20000000000000007e-31 < l Initial program 83.0%
Applied egg-rr30.4%
expm1-def30.4%
expm1-log1p30.8%
fma-neg30.8%
associate-*r*30.8%
+-commutative30.8%
associate-+l-30.8%
associate--r-30.8%
+-commutative30.8%
Simplified30.8%
Taylor expanded in K around 0 30.7%
cos-neg30.7%
Simplified30.7%
Taylor expanded in m around 0 40.5%
*-commutative40.5%
+-commutative40.5%
Simplified40.5%
Taylor expanded in l around inf 91.6%
mul-1-neg91.6%
Simplified91.6%
Final simplification45.8%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * 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 = cos(m_1) * exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(-l);
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(-l)
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{-\ell}
\end{array}
Initial program 76.0%
Applied egg-rr16.9%
expm1-def16.9%
expm1-log1p18.0%
fma-neg18.0%
associate-*r*18.0%
+-commutative18.0%
associate-+l-18.0%
associate--r-18.0%
+-commutative18.0%
Simplified18.0%
Taylor expanded in K around 0 18.0%
cos-neg18.0%
Simplified18.0%
Taylor expanded in m around 0 21.2%
*-commutative21.2%
+-commutative21.2%
Simplified21.2%
Taylor expanded in l around inf 38.0%
mul-1-neg38.0%
Simplified38.0%
Final simplification38.0%
(FPCore (K m n M l) :precision binary64 (exp (- (+ m (* 0.25 (* (+ m n) (+ m n)))) (+ n l))))
double code(double K, double m, double n, double M, double l) {
return exp(((m + (0.25 * ((m + n) * (m + n)))) - (n + 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(((m + (0.25d0 * ((m + n) * (m + n)))) - (n + l)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((m + (0.25 * ((m + n) * (m + n)))) - (n + l)));
}
def code(K, m, n, M, l): return math.exp(((m + (0.25 * ((m + n) * (m + n)))) - (n + l)))
function code(K, m, n, M, l) return exp(Float64(Float64(m + Float64(0.25 * Float64(Float64(m + n) * Float64(m + n)))) - Float64(n + l))) end
function tmp = code(K, m, n, M, l) tmp = exp(((m + (0.25 * ((m + n) * (m + n)))) - (n + l))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(m + N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(m + 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right) - \left(n + \ell\right)}
\end{array}
Initial program 76.0%
Applied egg-rr16.9%
expm1-def16.9%
expm1-log1p18.0%
fma-neg18.0%
associate-*r*18.0%
+-commutative18.0%
associate-+l-18.0%
associate--r-18.0%
+-commutative18.0%
Simplified18.0%
Taylor expanded in K around 0 18.0%
cos-neg18.0%
Simplified18.0%
Taylor expanded in M around 0 22.7%
pow222.7%
Applied egg-rr22.7%
Final simplification22.7%
herbie shell --seed 2023338
(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)))))))