
(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 9 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 (* (exp (* (- M) M)) 1.0)))
(if (<= M -1e+147)
t_0
(if (<= M 3e+83)
(*
(fma (* M M) -0.5 1.0)
(exp (- (fabs (- n m)) (+ (pow (fma 0.5 (+ n m) (- M)) 2.0) l))))
t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-M * M)) * 1.0;
double tmp;
if (M <= -1e+147) {
tmp = t_0;
} else if (M <= 3e+83) {
tmp = fma((M * M), -0.5, 1.0) * exp((fabs((n - m)) - (pow(fma(0.5, (n + m), -M), 2.0) + l)));
} else {
tmp = t_0;
}
return tmp;
}
function code(K, m, n, M, l) t_0 = Float64(exp(Float64(Float64(-M) * M)) * 1.0) tmp = 0.0 if (M <= -1e+147) tmp = t_0; elseif (M <= 3e+83) tmp = Float64(fma(Float64(M * M), -0.5, 1.0) * exp(Float64(abs(Float64(n - m)) - Float64((fma(0.5, Float64(n + m), Float64(-M)) ^ 2.0) + l)))); else tmp = t_0; end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[M, -1e+147], t$95$0, If[LessEqual[M, 3e+83], N[(N[(N[(M * M), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(0.5 * N[(n + m), $MachinePrecision] + (-M)), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\
\mathbf{if}\;M \leq -1 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 3 \cdot 10^{+83}:\\
\;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{\left|n - m\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -9.9999999999999998e146 or 3e83 < M Initial program 83.3%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6421.2
Applied rewrites21.2%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6427.1
Applied rewrites27.1%
Taylor expanded in M around 0
Applied rewrites27.1%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6497.3
Applied rewrites97.3%
if -9.9999999999999998e146 < M < 3e83Initial program 73.3%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.7%
Taylor expanded in M around 0
Applied rewrites92.8%
Final simplification94.1%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (fabs (- n m)) (+ (pow (fma 0.5 (+ n m) (- M)) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((n - m)) - (pow(fma(0.5, (n + m), -M), 2.0) + l)));
}
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64((fma(0.5, Float64(n + m), Float64(-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[(0.5 * N[(n + m), $MachinePrecision] + (-M)), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)}
\end{array}
Initial program 76.2%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.0%
Final simplification94.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (exp (* (- M) M)) 1.0)))
(if (<= M -1e+147)
t_0
(if (<= M 3e+83)
(*
(* -0.5 (* M M))
(exp (- (fabs (- n m)) (+ (pow (fma 0.5 (+ n m) (- M)) 2.0) l))))
t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-M * M)) * 1.0;
double tmp;
if (M <= -1e+147) {
tmp = t_0;
} else if (M <= 3e+83) {
tmp = (-0.5 * (M * M)) * exp((fabs((n - m)) - (pow(fma(0.5, (n + m), -M), 2.0) + l)));
} else {
tmp = t_0;
}
return tmp;
}
function code(K, m, n, M, l) t_0 = Float64(exp(Float64(Float64(-M) * M)) * 1.0) tmp = 0.0 if (M <= -1e+147) tmp = t_0; elseif (M <= 3e+83) tmp = Float64(Float64(-0.5 * Float64(M * M)) * exp(Float64(abs(Float64(n - m)) - Float64((fma(0.5, Float64(n + m), Float64(-M)) ^ 2.0) + l)))); else tmp = t_0; end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[M, -1e+147], t$95$0, If[LessEqual[M, 3e+83], N[(N[(-0.5 * N[(M * M), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(0.5 * N[(n + m), $MachinePrecision] + (-M)), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\
\mathbf{if}\;M \leq -1 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 3 \cdot 10^{+83}:\\
\;\;\;\;\left(-0.5 \cdot \left(M \cdot M\right)\right) \cdot e^{\left|n - m\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -9.9999999999999998e146 or 3e83 < M Initial program 83.3%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6421.2
Applied rewrites21.2%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6427.1
Applied rewrites27.1%
Taylor expanded in M around 0
Applied rewrites27.1%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6497.3
Applied rewrites97.3%
if -9.9999999999999998e146 < M < 3e83Initial program 73.3%
Taylor expanded in K around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites91.7%
Taylor expanded in M around 0
Applied rewrites92.8%
Taylor expanded in M around inf
Applied rewrites84.0%
Final simplification87.7%
(FPCore (K m n M l)
:precision binary64
(if (<= m -85000.0)
(* (exp (* -0.25 (* m m))) 1.0)
(if (<= m -8.5e-73)
(* (exp (- l)) (fma (* M M) -0.5 1.0))
(if (<= m -1.66e-183)
(* (exp (* (- M) M)) 1.0)
(* (exp (* (* n n) -0.25)) (cos M))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -85000.0) {
tmp = exp((-0.25 * (m * m))) * 1.0;
} else if (m <= -8.5e-73) {
tmp = exp(-l) * fma((M * M), -0.5, 1.0);
} else if (m <= -1.66e-183) {
tmp = exp((-M * M)) * 1.0;
} else {
tmp = exp(((n * n) * -0.25)) * cos(M);
}
return tmp;
}
function code(K, m, n, M, l) tmp = 0.0 if (m <= -85000.0) tmp = Float64(exp(Float64(-0.25 * Float64(m * m))) * 1.0); elseif (m <= -8.5e-73) tmp = Float64(exp(Float64(-l)) * fma(Float64(M * M), -0.5, 1.0)); elseif (m <= -1.66e-183) tmp = Float64(exp(Float64(Float64(-M) * M)) * 1.0); else tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * cos(M)); end return tmp end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -85000.0], N[(N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[m, -8.5e-73], N[(N[Exp[(-l)], $MachinePrecision] * N[(N[(M * M), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -1.66e-183], N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -85000:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot 1\\
\mathbf{elif}\;m \leq -8.5 \cdot 10^{-73}:\\
\;\;\;\;e^{-\ell} \cdot \mathsf{fma}\left(M \cdot M, -0.5, 1\right)\\
\mathbf{elif}\;m \leq -1.66 \cdot 10^{-183}:\\
\;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot \cos M\\
\end{array}
\end{array}
if m < -85000Initial program 68.6%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6417.1
Applied rewrites17.1%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6423.6
Applied rewrites23.6%
Taylor expanded in M around 0
Applied rewrites23.6%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6494.2
Applied rewrites94.2%
if -85000 < m < -8.4999999999999996e-73Initial program 74.7%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6433.8
Applied rewrites33.8%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6433.9
Applied rewrites33.9%
Taylor expanded in M around 0
Applied rewrites38.9%
if -8.4999999999999996e-73 < m < -1.66e-183Initial program 82.4%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6430.9
Applied rewrites30.9%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6432.0
Applied rewrites32.0%
Taylor expanded in M around 0
Applied rewrites32.0%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6472.2
Applied rewrites72.2%
if -1.66e-183 < m Initial program 78.0%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6444.1
Applied rewrites44.1%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6455.4
Applied rewrites55.4%
Final simplification63.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (exp (* (- M) M)) 1.0)) (t_1 (* (exp (* -0.25 (* m m))) 1.0)))
(if (<= m -3.6e+14)
t_1
(if (<= m -7.1e-233)
t_0
(if (<= m 1e-282) (* (exp (- l)) 1.0) (if (<= m 4.8e-11) t_0 t_1))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-M * M)) * 1.0;
double t_1 = exp((-0.25 * (m * m))) * 1.0;
double tmp;
if (m <= -3.6e+14) {
tmp = t_1;
} else if (m <= -7.1e-233) {
tmp = t_0;
} else if (m <= 1e-282) {
tmp = exp(-l) * 1.0;
} else if (m <= 4.8e-11) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = exp((-m_1 * m_1)) * 1.0d0
t_1 = exp(((-0.25d0) * (m * m))) * 1.0d0
if (m <= (-3.6d+14)) then
tmp = t_1
else if (m <= (-7.1d-233)) then
tmp = t_0
else if (m <= 1d-282) then
tmp = exp(-l) * 1.0d0
else if (m <= 4.8d-11) then
tmp = t_0
else
tmp = t_1
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)) * 1.0;
double t_1 = Math.exp((-0.25 * (m * m))) * 1.0;
double tmp;
if (m <= -3.6e+14) {
tmp = t_1;
} else if (m <= -7.1e-233) {
tmp = t_0;
} else if (m <= 1e-282) {
tmp = Math.exp(-l) * 1.0;
} else if (m <= 4.8e-11) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-M * M)) * 1.0 t_1 = math.exp((-0.25 * (m * m))) * 1.0 tmp = 0 if m <= -3.6e+14: tmp = t_1 elif m <= -7.1e-233: tmp = t_0 elif m <= 1e-282: tmp = math.exp(-l) * 1.0 elif m <= 4.8e-11: tmp = t_0 else: tmp = t_1 return tmp
function code(K, m, n, M, l) t_0 = Float64(exp(Float64(Float64(-M) * M)) * 1.0) t_1 = Float64(exp(Float64(-0.25 * Float64(m * m))) * 1.0) tmp = 0.0 if (m <= -3.6e+14) tmp = t_1; elseif (m <= -7.1e-233) tmp = t_0; elseif (m <= 1e-282) tmp = Float64(exp(Float64(-l)) * 1.0); elseif (m <= 4.8e-11) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-M * M)) * 1.0; t_1 = exp((-0.25 * (m * m))) * 1.0; tmp = 0.0; if (m <= -3.6e+14) tmp = t_1; elseif (m <= -7.1e-233) tmp = t_0; elseif (m <= 1e-282) tmp = exp(-l) * 1.0; elseif (m <= 4.8e-11) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[m, -3.6e+14], t$95$1, If[LessEqual[m, -7.1e-233], t$95$0, If[LessEqual[m, 1e-282], N[(N[Exp[(-l)], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[m, 4.8e-11], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\
t_1 := e^{-0.25 \cdot \left(m \cdot m\right)} \cdot 1\\
\mathbf{if}\;m \leq -3.6 \cdot 10^{+14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;m \leq -7.1 \cdot 10^{-233}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 10^{-282}:\\
\;\;\;\;e^{-\ell} \cdot 1\\
\mathbf{elif}\;m \leq 4.8 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if m < -3.6e14 or 4.8000000000000002e-11 < m Initial program 71.9%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6422.9
Applied rewrites22.9%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6432.7
Applied rewrites32.7%
Taylor expanded in M around 0
Applied rewrites32.0%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6493.6
Applied rewrites93.6%
if -3.6e14 < m < -7.1e-233 or 1e-282 < m < 4.8000000000000002e-11Initial program 76.8%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6435.4
Applied rewrites35.4%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6437.7
Applied rewrites37.7%
Taylor expanded in M around 0
Applied rewrites37.7%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6450.3
Applied rewrites50.3%
if -7.1e-233 < m < 1e-282Initial program 93.8%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6451.6
Applied rewrites51.6%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6448.4
Applied rewrites48.4%
Taylor expanded in M around 0
Applied rewrites48.4%
Final simplification73.6%
(FPCore (K m n M l)
:precision binary64
(if (<= m -85000.0)
(* (exp (* -0.25 (* m m))) 1.0)
(if (<= m -8.5e-73)
(* (exp (- l)) (fma (* M M) -0.5 1.0))
(if (<= m -1e-185)
(* (exp (* (- M) M)) 1.0)
(* (exp (* (* n n) -0.25)) 1.0)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -85000.0) {
tmp = exp((-0.25 * (m * m))) * 1.0;
} else if (m <= -8.5e-73) {
tmp = exp(-l) * fma((M * M), -0.5, 1.0);
} else if (m <= -1e-185) {
tmp = exp((-M * M)) * 1.0;
} else {
tmp = exp(((n * n) * -0.25)) * 1.0;
}
return tmp;
}
function code(K, m, n, M, l) tmp = 0.0 if (m <= -85000.0) tmp = Float64(exp(Float64(-0.25 * Float64(m * m))) * 1.0); elseif (m <= -8.5e-73) tmp = Float64(exp(Float64(-l)) * fma(Float64(M * M), -0.5, 1.0)); elseif (m <= -1e-185) tmp = Float64(exp(Float64(Float64(-M) * M)) * 1.0); else tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * 1.0); end return tmp end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -85000.0], N[(N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[m, -8.5e-73], N[(N[Exp[(-l)], $MachinePrecision] * N[(N[(M * M), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -1e-185], N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -85000:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot 1\\
\mathbf{elif}\;m \leq -8.5 \cdot 10^{-73}:\\
\;\;\;\;e^{-\ell} \cdot \mathsf{fma}\left(M \cdot M, -0.5, 1\right)\\
\mathbf{elif}\;m \leq -1 \cdot 10^{-185}:\\
\;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\
\end{array}
\end{array}
if m < -85000Initial program 68.6%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6417.1
Applied rewrites17.1%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6423.6
Applied rewrites23.6%
Taylor expanded in M around 0
Applied rewrites23.6%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6494.2
Applied rewrites94.2%
if -85000 < m < -8.4999999999999996e-73Initial program 74.7%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6433.8
Applied rewrites33.8%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6433.9
Applied rewrites33.9%
Taylor expanded in M around 0
Applied rewrites38.9%
if -8.4999999999999996e-73 < m < -9.9999999999999999e-186Initial program 82.4%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6430.9
Applied rewrites30.9%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6432.0
Applied rewrites32.0%
Taylor expanded in M around 0
Applied rewrites32.0%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6472.2
Applied rewrites72.2%
if -9.9999999999999999e-186 < m Initial program 78.0%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6444.1
Applied rewrites44.1%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6455.4
Applied rewrites55.4%
Taylor expanded in M around 0
Applied rewrites55.3%
Final simplification63.0%
(FPCore (K m n M l)
:precision binary64
(if (<= m -3.6e+14)
(* (exp (* -0.25 (* m m))) 1.0)
(if (<= m -1e-185)
(* (exp (* (- M) M)) 1.0)
(* (exp (* (* n n) -0.25)) 1.0))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -3.6e+14) {
tmp = exp((-0.25 * (m * m))) * 1.0;
} else if (m <= -1e-185) {
tmp = exp((-M * M)) * 1.0;
} else {
tmp = exp(((n * n) * -0.25)) * 1.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) :: tmp
if (m <= (-3.6d+14)) then
tmp = exp(((-0.25d0) * (m * m))) * 1.0d0
else if (m <= (-1d-185)) then
tmp = exp((-m_1 * m_1)) * 1.0d0
else
tmp = exp(((n * n) * (-0.25d0))) * 1.0d0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -3.6e+14) {
tmp = Math.exp((-0.25 * (m * m))) * 1.0;
} else if (m <= -1e-185) {
tmp = Math.exp((-M * M)) * 1.0;
} else {
tmp = Math.exp(((n * n) * -0.25)) * 1.0;
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -3.6e+14: tmp = math.exp((-0.25 * (m * m))) * 1.0 elif m <= -1e-185: tmp = math.exp((-M * M)) * 1.0 else: tmp = math.exp(((n * n) * -0.25)) * 1.0 return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -3.6e+14) tmp = Float64(exp(Float64(-0.25 * Float64(m * m))) * 1.0); elseif (m <= -1e-185) tmp = Float64(exp(Float64(Float64(-M) * M)) * 1.0); else tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * 1.0); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -3.6e+14) tmp = exp((-0.25 * (m * m))) * 1.0; elseif (m <= -1e-185) tmp = exp((-M * M)) * 1.0; else tmp = exp(((n * n) * -0.25)) * 1.0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -3.6e+14], N[(N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[m, -1e-185], N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.6 \cdot 10^{+14}:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot 1\\
\mathbf{elif}\;m \leq -1 \cdot 10^{-185}:\\
\;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\
\end{array}
\end{array}
if m < -3.6e14Initial program 68.6%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6417.1
Applied rewrites17.1%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6423.6
Applied rewrites23.6%
Taylor expanded in M around 0
Applied rewrites23.6%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6494.2
Applied rewrites94.2%
if -3.6e14 < m < -9.9999999999999999e-186Initial program 78.4%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6432.4
Applied rewrites32.4%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6433.0
Applied rewrites33.0%
Taylor expanded in M around 0
Applied rewrites33.0%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6449.5
Applied rewrites49.5%
if -9.9999999999999999e-186 < m Initial program 78.0%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6444.1
Applied rewrites44.1%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6455.4
Applied rewrites55.4%
Taylor expanded in M around 0
Applied rewrites55.3%
Final simplification62.3%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (* (exp (* (- M) M)) 1.0))) (if (<= M -27.0) t_0 (if (<= M 2e-17) (* (exp (- l)) 1.0) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-M * M)) * 1.0;
double tmp;
if (M <= -27.0) {
tmp = t_0;
} else if (M <= 2e-17) {
tmp = exp(-l) * 1.0;
} 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_1 * m_1)) * 1.0d0
if (m_1 <= (-27.0d0)) then
tmp = t_0
else if (m_1 <= 2d-17) then
tmp = exp(-l) * 1.0d0
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)) * 1.0;
double tmp;
if (M <= -27.0) {
tmp = t_0;
} else if (M <= 2e-17) {
tmp = Math.exp(-l) * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-M * M)) * 1.0 tmp = 0 if M <= -27.0: tmp = t_0 elif M <= 2e-17: tmp = math.exp(-l) * 1.0 else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = Float64(exp(Float64(Float64(-M) * M)) * 1.0) tmp = 0.0 if (M <= -27.0) tmp = t_0; elseif (M <= 2e-17) tmp = Float64(exp(Float64(-l)) * 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-M * M)) * 1.0; tmp = 0.0; if (M <= -27.0) tmp = t_0; elseif (M <= 2e-17) tmp = exp(-l) * 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[M, -27.0], t$95$0, If[LessEqual[M, 2e-17], N[(N[Exp[(-l)], $MachinePrecision] * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\
\mathbf{if}\;M \leq -27:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 2 \cdot 10^{-17}:\\
\;\;\;\;e^{-\ell} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -27 or 2.00000000000000014e-17 < M Initial program 74.2%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6416.6
Applied rewrites16.6%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6425.3
Applied rewrites25.3%
Taylor expanded in M around 0
Applied rewrites24.5%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6493.5
Applied rewrites93.5%
if -27 < M < 2.00000000000000014e-17Initial program 77.9%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6442.8
Applied rewrites42.8%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6445.9
Applied rewrites45.9%
Taylor expanded in M around 0
Applied rewrites45.9%
Final simplification68.2%
(FPCore (K m n M l) :precision binary64 (* (exp (- l)) 1.0))
double code(double K, double m, double n, double M, double l) {
return exp(-l) * 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 = exp(-l) * 1.0d0
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l) * 1.0;
}
def code(K, m, n, M, l): return math.exp(-l) * 1.0
function code(K, m, n, M, l) return Float64(exp(Float64(-l)) * 1.0) end
function tmp = code(K, m, n, M, l) tmp = exp(-l) * 1.0; end
code[K_, m_, n_, M_, l_] := N[(N[Exp[(-l)], $MachinePrecision] * 1.0), $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell} \cdot 1
\end{array}
Initial program 76.2%
Taylor expanded in l around inf
mul-1-negN/A
lower-neg.f6430.5
Applied rewrites30.5%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6436.2
Applied rewrites36.2%
Taylor expanded in M around 0
Applied rewrites35.9%
Final simplification35.9%
herbie shell --seed 2024276
(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)))))))