
(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 8 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)) (+ (pow (- (/ (+ m n) 2.0) M) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((n - m)) - (pow((((m + n) / 2.0) - M), 2.0) + 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((abs((n - m)) - (((((m + n) / 2.0d0) - m_1) ** 2.0d0) + l)))
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)) - (Math.pow((((m + n) / 2.0) - M), 2.0) + l)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((n - m)) - (math.pow((((m + n) / 2.0) - M), 2.0) + l)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64((Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0) + l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((n - m)) - (((((m + n) / 2.0) - M) ^ 2.0) + l))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*74.9%
+-commutative74.9%
Simplified74.9%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n -2.55e-163)
(* (cos M) (exp (+ t_0 (* -0.25 (* m m)))))
(if (<= n 38000000000000.0)
(* (exp (- t_0 (+ l (* M M)))) (cos (- (* 0.5 (* n K)) M)))
(exp (fma -0.25 (* n n) t_0))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= -2.55e-163) {
tmp = cos(M) * exp((t_0 + (-0.25 * (m * m))));
} else if (n <= 38000000000000.0) {
tmp = exp((t_0 - (l + (M * M)))) * cos(((0.5 * (n * K)) - M));
} else {
tmp = exp(fma(-0.25, (n * n), t_0));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= -2.55e-163) tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(-0.25 * Float64(m * m))))); elseif (n <= 38000000000000.0) tmp = Float64(exp(Float64(t_0 - Float64(l + Float64(M * M)))) * cos(Float64(Float64(0.5 * Float64(n * K)) - M))); else tmp = exp(fma(-0.25, Float64(n * n), t_0)); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -2.55e-163], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 38000000000000.0], N[(N[Exp[N[(t$95$0 - N[(l + N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(0.5 * N[(n * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq -2.55 \cdot 10^{-163}:\\
\;\;\;\;\cos M \cdot e^{t_0 + -0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 38000000000000:\\
\;\;\;\;e^{t_0 - \left(\ell + M \cdot M\right)} \cdot \cos \left(0.5 \cdot \left(n \cdot K\right) - M\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{fma}\left(-0.25, n \cdot n, t_0\right)}\\
\end{array}
\end{array}
if n < -2.54999999999999995e-163Initial program 72.3%
+-commutative72.3%
+-commutative72.3%
fabs-sub72.3%
associate-/l*71.2%
+-commutative71.2%
Simplified71.2%
Taylor expanded in K around 0 98.9%
cos-neg98.9%
Simplified98.9%
Taylor expanded in m around inf 49.7%
unpow249.7%
Simplified49.7%
if -2.54999999999999995e-163 < n < 3.8e13Initial program 82.9%
+-commutative82.9%
+-commutative82.9%
fabs-sub82.9%
associate-/l*82.1%
+-commutative82.1%
Simplified82.1%
Taylor expanded in M around inf 71.9%
unpow271.9%
Simplified71.9%
Taylor expanded in m around 0 79.1%
unpow279.1%
Simplified79.1%
if 3.8e13 < n Initial program 68.5%
+-commutative68.5%
+-commutative68.5%
fabs-sub68.5%
associate-/l*69.9%
+-commutative69.9%
Simplified69.9%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 83.8%
*-commutative83.8%
unpow283.8%
associate-*l*83.8%
Simplified83.8%
Taylor expanded in M around 0 83.8%
exp-sum0.0%
sub-neg0.0%
mul-1-neg0.0%
exp-sum83.8%
fma-def83.8%
unpow283.8%
mul-1-neg83.8%
sub-neg83.8%
Simplified83.8%
Final simplification70.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= m -5.4e+17)
(* (cos M) (exp (+ t_0 (* -0.25 (* m m)))))
(if (<= m 7.5e-140)
(* (cos M) (exp (- t_0 (* M M))))
(* (cos M) (exp (+ t_0 (* n (* n -0.25)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (m <= -5.4e+17) {
tmp = cos(M) * exp((t_0 + (-0.25 * (m * m))));
} else if (m <= 7.5e-140) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = cos(M) * exp((t_0 + (n * (n * -0.25))));
}
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 (m <= (-5.4d+17)) then
tmp = cos(m_1) * exp((t_0 + ((-0.25d0) * (m * m))))
else if (m <= 7.5d-140) then
tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
else
tmp = cos(m_1) * exp((t_0 + (n * (n * (-0.25d0)))))
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 (m <= -5.4e+17) {
tmp = Math.cos(M) * Math.exp((t_0 + (-0.25 * (m * m))));
} else if (m <= 7.5e-140) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 + (n * (n * -0.25))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if m <= -5.4e+17: tmp = math.cos(M) * math.exp((t_0 + (-0.25 * (m * m)))) elif m <= 7.5e-140: tmp = math.cos(M) * math.exp((t_0 - (M * M))) else: tmp = math.cos(M) * math.exp((t_0 + (n * (n * -0.25)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (m <= -5.4e+17) tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(-0.25 * Float64(m * m))))); elseif (m <= 7.5e-140) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(n * Float64(n * -0.25))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (m <= -5.4e+17) tmp = cos(M) * exp((t_0 + (-0.25 * (m * m)))); elseif (m <= 7.5e-140) tmp = cos(M) * exp((t_0 - (M * M))); else tmp = cos(M) * exp((t_0 + (n * (n * -0.25)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -5.4e+17], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 7.5e-140], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;m \leq -5.4 \cdot 10^{+17}:\\
\;\;\;\;\cos M \cdot e^{t_0 + -0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;m \leq 7.5 \cdot 10^{-140}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 + n \cdot \left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if m < -5.4e17Initial program 71.2%
+-commutative71.2%
+-commutative71.2%
fabs-sub71.2%
associate-/l*71.2%
+-commutative71.2%
Simplified71.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 86.7%
unpow286.7%
Simplified86.7%
if -5.4e17 < m < 7.4999999999999998e-140Initial program 80.8%
+-commutative80.8%
+-commutative80.8%
fabs-sub80.8%
associate-/l*80.0%
+-commutative80.0%
Simplified80.0%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in M around inf 62.9%
mul-1-neg62.9%
unpow262.9%
distribute-rgt-neg-out62.9%
Simplified62.9%
if 7.4999999999999998e-140 < m Initial program 71.8%
+-commutative71.8%
+-commutative71.8%
fabs-sub71.8%
associate-/l*71.8%
+-commutative71.8%
Simplified71.8%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in n around inf 41.4%
*-commutative41.4%
unpow241.4%
associate-*l*41.4%
Simplified41.4%
Final simplification60.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (or (<= n -2e+84) (not (<= n 200000000000.0)))
(exp (fma -0.25 (* n n) t_0))
(* (cos M) (exp (- t_0 (* M M)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if ((n <= -2e+84) || !(n <= 200000000000.0)) {
tmp = exp(fma(-0.25, (n * n), t_0));
} else {
tmp = cos(M) * exp((t_0 - (M * M)));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if ((n <= -2e+84) || !(n <= 200000000000.0)) tmp = exp(fma(-0.25, Float64(n * n), t_0)); else tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[n, -2e+84], N[Not[LessEqual[n, 200000000000.0]], $MachinePrecision]], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq -2 \cdot 10^{+84} \lor \neg \left(n \leq 200000000000\right):\\
\;\;\;\;e^{\mathsf{fma}\left(-0.25, n \cdot n, t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\end{array}
\end{array}
if n < -2.00000000000000012e84 or 2e11 < n Initial program 67.2%
+-commutative67.2%
+-commutative67.2%
fabs-sub67.2%
associate-/l*67.2%
+-commutative67.2%
Simplified67.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 86.8%
*-commutative86.8%
unpow286.8%
associate-*l*86.8%
Simplified86.8%
Taylor expanded in M around 0 86.8%
exp-sum0.0%
sub-neg0.0%
mul-1-neg0.0%
exp-sum86.8%
fma-def86.8%
unpow286.8%
mul-1-neg86.8%
sub-neg86.8%
Simplified86.8%
if -2.00000000000000012e84 < n < 2e11Initial program 82.2%
+-commutative82.2%
+-commutative82.2%
fabs-sub82.2%
associate-/l*81.6%
+-commutative81.6%
Simplified81.6%
Taylor expanded in K around 0 95.4%
cos-neg95.4%
Simplified95.4%
Taylor expanded in M around inf 60.3%
mul-1-neg60.3%
unpow260.3%
distribute-rgt-neg-out60.3%
Simplified60.3%
Final simplification72.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= m -1.56e+18)
(* (cos M) (exp (+ t_0 (* -0.25 (* m m)))))
(if (<= m 1.65e-135)
(* (cos M) (exp (- t_0 (* M M))))
(exp (fma -0.25 (* n n) t_0))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (m <= -1.56e+18) {
tmp = cos(M) * exp((t_0 + (-0.25 * (m * m))));
} else if (m <= 1.65e-135) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = exp(fma(-0.25, (n * n), t_0));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (m <= -1.56e+18) tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(-0.25 * Float64(m * m))))); elseif (m <= 1.65e-135) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = exp(fma(-0.25, Float64(n * n), t_0)); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -1.56e+18], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.65e-135], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;m \leq -1.56 \cdot 10^{+18}:\\
\;\;\;\;\cos M \cdot e^{t_0 + -0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;m \leq 1.65 \cdot 10^{-135}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{\mathsf{fma}\left(-0.25, n \cdot n, t_0\right)}\\
\end{array}
\end{array}
if m < -1.56e18Initial program 71.2%
+-commutative71.2%
+-commutative71.2%
fabs-sub71.2%
associate-/l*71.2%
+-commutative71.2%
Simplified71.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 86.7%
unpow286.7%
Simplified86.7%
if -1.56e18 < m < 1.65e-135Initial program 80.0%
+-commutative80.0%
+-commutative80.0%
fabs-sub80.0%
associate-/l*79.2%
+-commutative79.2%
Simplified79.2%
Taylor expanded in K around 0 94.6%
cos-neg94.6%
Simplified94.6%
Taylor expanded in M around inf 62.3%
mul-1-neg62.3%
unpow262.3%
distribute-rgt-neg-out62.3%
Simplified62.3%
if 1.65e-135 < m Initial program 72.6%
+-commutative72.6%
+-commutative72.6%
fabs-sub72.6%
associate-/l*72.6%
+-commutative72.6%
Simplified72.6%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in n around inf 41.8%
*-commutative41.8%
unpow241.8%
associate-*l*41.8%
Simplified41.8%
Taylor expanded in M around 0 41.8%
exp-sum1.2%
sub-neg1.2%
mul-1-neg1.2%
exp-sum41.8%
fma-def41.8%
unpow241.8%
mul-1-neg41.8%
sub-neg41.8%
Simplified41.8%
Final simplification60.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (or (<= n -1.15e+36) (not (<= n 0.5)))
(exp (fma -0.25 (* n n) t_0))
(exp (- t_0 l)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if ((n <= -1.15e+36) || !(n <= 0.5)) {
tmp = exp(fma(-0.25, (n * n), t_0));
} else {
tmp = exp((t_0 - l));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if ((n <= -1.15e+36) || !(n <= 0.5)) tmp = exp(fma(-0.25, Float64(n * n), t_0)); else tmp = exp(Float64(t_0 - l)); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[n, -1.15e+36], N[Not[LessEqual[n, 0.5]], $MachinePrecision]], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], N[Exp[N[(t$95$0 - l), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq -1.15 \cdot 10^{+36} \lor \neg \left(n \leq 0.5\right):\\
\;\;\;\;e^{\mathsf{fma}\left(-0.25, n \cdot n, t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \ell}\\
\end{array}
\end{array}
if n < -1.14999999999999998e36 or 0.5 < n Initial program 68.8%
+-commutative68.8%
+-commutative68.8%
fabs-sub68.8%
associate-/l*68.8%
+-commutative68.8%
Simplified68.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 84.6%
*-commutative84.6%
unpow284.6%
associate-*l*84.6%
Simplified84.6%
Taylor expanded in M around 0 84.6%
exp-sum0.1%
sub-neg0.1%
mul-1-neg0.1%
exp-sum84.6%
fma-def84.6%
unpow284.6%
mul-1-neg84.6%
sub-neg84.6%
Simplified84.6%
if -1.14999999999999998e36 < n < 0.5Initial program 81.8%
+-commutative81.8%
+-commutative81.8%
fabs-sub81.8%
associate-/l*81.1%
+-commutative81.1%
Simplified81.1%
Taylor expanded in M around inf 64.9%
unpow264.9%
Simplified64.9%
Taylor expanded in M around 0 28.9%
Taylor expanded in K around 0 31.5%
Final simplification58.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (or (<= n -1.5e+66) (not (<= n 5.0)))
(exp (fma -0.25 (* n n) t_0))
(* (cos M) (exp (- t_0 l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if ((n <= -1.5e+66) || !(n <= 5.0)) {
tmp = exp(fma(-0.25, (n * n), t_0));
} else {
tmp = cos(M) * exp((t_0 - l));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if ((n <= -1.5e+66) || !(n <= 5.0)) tmp = exp(fma(-0.25, Float64(n * n), t_0)); else tmp = Float64(cos(M) * exp(Float64(t_0 - l))); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[n, -1.5e+66], N[Not[LessEqual[n, 5.0]], $MachinePrecision]], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq -1.5 \cdot 10^{+66} \lor \neg \left(n \leq 5\right):\\
\;\;\;\;e^{\mathsf{fma}\left(-0.25, n \cdot n, t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \ell}\\
\end{array}
\end{array}
if n < -1.50000000000000001e66 or 5 < n Initial program 68.0%
+-commutative68.0%
+-commutative68.0%
fabs-sub68.0%
associate-/l*68.0%
+-commutative68.0%
Simplified68.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 86.3%
*-commutative86.3%
unpow286.3%
associate-*l*86.3%
Simplified86.3%
Taylor expanded in M around 0 86.3%
exp-sum0.0%
sub-neg0.0%
mul-1-neg0.0%
exp-sum86.3%
fma-def86.3%
unpow286.3%
mul-1-neg86.3%
sub-neg86.3%
Simplified86.3%
if -1.50000000000000001e66 < n < 5Initial program 81.8%
+-commutative81.8%
+-commutative81.8%
fabs-sub81.8%
associate-/l*81.2%
+-commutative81.2%
Simplified81.2%
associate-/l*81.8%
expm1-log1p-u58.6%
div-inv58.6%
*-commutative58.6%
associate-*l*58.6%
metadata-eval58.6%
Applied egg-rr58.6%
Taylor expanded in l around inf 23.5%
neg-mul-123.5%
Simplified23.5%
Taylor expanded in K around 0 30.9%
cos-neg30.9%
sub-neg30.9%
mul-1-neg30.9%
mul-1-neg30.9%
sub-neg30.9%
fabs-sub30.9%
Simplified30.9%
Final simplification57.3%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- n m)) l)))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((n - m)) - 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((abs((n - m)) - l))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((n - m)) - l));
}
def code(K, m, n, M, l): return math.exp((math.fabs((n - m)) - l))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(n - m)) - l)) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((n - m)) - l)); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|n - m\right| - \ell}
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*74.9%
+-commutative74.9%
Simplified74.9%
Taylor expanded in M around inf 49.5%
unpow249.5%
Simplified49.5%
Taylor expanded in M around 0 19.2%
Taylor expanded in K around 0 23.1%
Final simplification23.1%
herbie shell --seed 2023275
(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)))))))