
(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 (- (* 0.5 (+ m n)) M))) (* (cos M) (exp (* l (- -1.0 (/ (- (* t_0 t_0) (fabs (- m n))) l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (0.5 * (m + n)) - M;
return cos(M) * exp((l * (-1.0 - (((t_0 * t_0) - fabs((m - 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
real(8) :: t_0
t_0 = (0.5d0 * (m + n)) - m_1
code = cos(m_1) * exp((l * ((-1.0d0) - (((t_0 * t_0) - abs((m - n))) / l))))
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (0.5 * (m + n)) - M;
return Math.cos(M) * Math.exp((l * (-1.0 - (((t_0 * t_0) - Math.abs((m - n))) / l))));
}
def code(K, m, n, M, l): t_0 = (0.5 * (m + n)) - M return math.cos(M) * math.exp((l * (-1.0 - (((t_0 * t_0) - math.fabs((m - n))) / l))))
function code(K, m, n, M, l) t_0 = Float64(Float64(0.5 * Float64(m + n)) - M) return Float64(cos(M) * exp(Float64(l * Float64(-1.0 - Float64(Float64(Float64(t_0 * t_0) - abs(Float64(m - n))) / l))))) end
function tmp = code(K, m, n, M, l) t_0 = (0.5 * (m + n)) - M; tmp = cos(M) * exp((l * (-1.0 - (((t_0 * t_0) - abs((m - n))) / l)))); end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(l * N[(-1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(m + n\right) - M\\
\cos M \cdot e^{\ell \cdot \left(-1 - \frac{t\_0 \cdot t\_0 - \left|m - n\right|}{\ell}\right)}
\end{array}
\end{array}
Initial program 75.7%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6495.9
Applied rewrites95.9%
Taylor expanded in l around -inf
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites95.9%
Final simplification95.9%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (- (* 0.5 (+ m n)) M))) (exp (* l (- -1.0 (/ (- (* t_0 t_0) (fabs (- m n))) l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (0.5 * (m + n)) - M;
return exp((l * (-1.0 - (((t_0 * t_0) - fabs((m - 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
real(8) :: t_0
t_0 = (0.5d0 * (m + n)) - m_1
code = exp((l * ((-1.0d0) - (((t_0 * t_0) - abs((m - n))) / l))))
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (0.5 * (m + n)) - M;
return Math.exp((l * (-1.0 - (((t_0 * t_0) - Math.abs((m - n))) / l))));
}
def code(K, m, n, M, l): t_0 = (0.5 * (m + n)) - M return math.exp((l * (-1.0 - (((t_0 * t_0) - math.fabs((m - n))) / l))))
function code(K, m, n, M, l) t_0 = Float64(Float64(0.5 * Float64(m + n)) - M) return exp(Float64(l * Float64(-1.0 - Float64(Float64(Float64(t_0 * t_0) - abs(Float64(m - n))) / l)))) end
function tmp = code(K, m, n, M, l) t_0 = (0.5 * (m + n)) - M; tmp = exp((l * (-1.0 - (((t_0 * t_0) - abs((m - n))) / l)))); end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]}, N[Exp[N[(l * N[(-1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(m + n\right) - M\\
e^{\ell \cdot \left(-1 - \frac{t\_0 \cdot t\_0 - \left|m - n\right|}{\ell}\right)}
\end{array}
\end{array}
Initial program 75.7%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6495.9
Applied rewrites95.9%
Taylor expanded in l around -inf
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites95.9%
Taylor expanded in M around 0
Applied rewrites95.8%
Final simplification95.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* M (- M)))))
(if (<= M -2.8e+101)
t_0
(if (<= M 5e+41)
(exp (- (fabs (- m n)) (fma 0.25 (* (+ m n) (+ 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 <= -2.8e+101) {
tmp = t_0;
} else if (M <= 5e+41) {
tmp = exp((fabs((m - n)) - fma(0.25, ((m + n) * (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 <= -2.8e+101) tmp = t_0; elseif (M <= 5e+41) tmp = exp(Float64(abs(Float64(m - n)) - fma(0.25, Float64(Float64(m + n) * 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, -2.8e+101], t$95$0, If[LessEqual[M, 5e+41], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * 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 -2.8 \cdot 10^{+101}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 5 \cdot 10^{+41}:\\
\;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -2.79999999999999981e101 or 5.00000000000000022e41 < M Initial program 80.4%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f64100.0
Applied rewrites100.0%
Taylor expanded in l around -inf
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites100.0%
Taylor expanded in M around 0
Applied rewrites100.0%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
if -2.79999999999999981e101 < M < 5.00000000000000022e41Initial program 72.3%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6493.0
Applied rewrites93.0%
Taylor expanded in M around 0
lower-exp.f64N/A
lower--.f64N/A
lower-fabs.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6492.1
Applied rewrites92.1%
Final simplification95.4%
(FPCore (K m n M l) :precision binary64 (if (<= m -0.34) (exp (* (* m m) -0.25)) (if (<= m -1e-255) (exp (* M (- M))) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.34) {
tmp = exp(((m * m) * -0.25));
} else if (m <= -1e-255) {
tmp = exp((M * -M));
} else {
tmp = exp((-0.25 * (n * n)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-0.34d0)) then
tmp = exp(((m * m) * (-0.25d0)))
else if (m <= (-1d-255)) then
tmp = exp((m_1 * -m_1))
else
tmp = exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.34) {
tmp = Math.exp(((m * m) * -0.25));
} else if (m <= -1e-255) {
tmp = Math.exp((M * -M));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -0.34: tmp = math.exp(((m * m) * -0.25)) elif m <= -1e-255: tmp = math.exp((M * -M)) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -0.34) tmp = exp(Float64(Float64(m * m) * -0.25)); elseif (m <= -1e-255) 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 (m <= -0.34) tmp = exp(((m * m) * -0.25)); elseif (m <= -1e-255) tmp = exp((M * -M)); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.34], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -1e-255], N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.34:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;m \leq -1 \cdot 10^{-255}:\\
\;\;\;\;e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -0.340000000000000024Initial program 69.2%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6498.7
Applied rewrites98.7%
Taylor expanded in l around -inf
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites98.7%
Taylor expanded in M around 0
Applied rewrites98.7%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.5
Applied rewrites97.5%
if -0.340000000000000024 < m < -1e-255Initial program 84.0%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6495.8
Applied rewrites95.8%
Taylor expanded in l around -inf
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites95.8%
Taylor expanded in M around 0
Applied rewrites95.8%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6463.5
Applied rewrites63.5%
if -1e-255 < m Initial program 76.8%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6494.4
Applied rewrites94.4%
Taylor expanded in l around -inf
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites94.4%
Taylor expanded in M around 0
Applied rewrites94.2%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.0
Applied rewrites55.0%
Final simplification69.3%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (exp (* M (- M))))) (if (<= M -1.6e+21) t_0 (if (<= M 27.0) (exp (* (* m m) -0.25)) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((M * -M));
double tmp;
if (M <= -1.6e+21) {
tmp = t_0;
} else if (M <= 27.0) {
tmp = exp(((m * m) * -0.25));
} 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))
if (m_1 <= (-1.6d+21)) then
tmp = t_0
else if (m_1 <= 27.0d0) then
tmp = exp(((m * m) * (-0.25d0)))
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));
double tmp;
if (M <= -1.6e+21) {
tmp = t_0;
} else if (M <= 27.0) {
tmp = Math.exp(((m * m) * -0.25));
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((M * -M)) tmp = 0 if M <= -1.6e+21: tmp = t_0 elif M <= 27.0: tmp = math.exp(((m * m) * -0.25)) 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 <= -1.6e+21) tmp = t_0; elseif (M <= 27.0) tmp = exp(Float64(Float64(m * m) * -0.25)); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((M * -M)); tmp = 0.0; if (M <= -1.6e+21) tmp = t_0; elseif (M <= 27.0) tmp = exp(((m * m) * -0.25)); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -1.6e+21], t$95$0, If[LessEqual[M, 27.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -1.6 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 27:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -1.6e21 or 27 < M Initial program 83.2%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f64100.0
Applied rewrites100.0%
Taylor expanded in l around -inf
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites100.0%
Taylor expanded in M around 0
Applied rewrites100.0%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6498.5
Applied rewrites98.5%
if -1.6e21 < M < 27Initial program 67.8%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6491.7
Applied rewrites91.7%
Taylor expanded in l around -inf
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites91.7%
Taylor expanded in M around 0
Applied rewrites91.4%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6453.5
Applied rewrites53.5%
Final simplification76.5%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (exp (* M (- M))))) (if (<= M -2.1e+17) t_0 (if (<= M 4.5e-63) (exp (- 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 <= -2.1e+17) {
tmp = t_0;
} else if (M <= 4.5e-63) {
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_1 * -m_1))
if (m_1 <= (-2.1d+17)) then
tmp = t_0
else if (m_1 <= 4.5d-63) 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));
double tmp;
if (M <= -2.1e+17) {
tmp = t_0;
} else if (M <= 4.5e-63) {
tmp = Math.exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((M * -M)) tmp = 0 if M <= -2.1e+17: tmp = t_0 elif M <= 4.5e-63: tmp = math.exp(-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 <= -2.1e+17) tmp = t_0; elseif (M <= 4.5e-63) 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)); tmp = 0.0; if (M <= -2.1e+17) tmp = t_0; elseif (M <= 4.5e-63) 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 * (-M)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -2.1e+17], t$95$0, If[LessEqual[M, 4.5e-63], N[Exp[(-l)], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -2.1 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 4.5 \cdot 10^{-63}:\\
\;\;\;\;e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -2.1e17 or 4.5e-63 < M Initial program 83.0%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f64100.0
Applied rewrites100.0%
Taylor expanded in l around -inf
associate-*r*N/A
lower-*.f64N/A
neg-mul-1N/A
lower-neg.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites100.0%
Taylor expanded in M around 0
Applied rewrites100.0%
Taylor expanded in M around inf
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6493.8
Applied rewrites93.8%
if -2.1e17 < M < 4.5e-63Initial program 66.8%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6490.9
Applied rewrites90.9%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6434.8
Applied rewrites34.8%
Taylor expanded in M around 0
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6434.8
Applied rewrites34.8%
Final simplification67.3%
(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 75.7%
Taylor expanded in K around 0
cos-negN/A
lower-cos.f6495.9
Applied rewrites95.9%
Taylor expanded in l around inf
neg-mul-1N/A
lower-neg.f6429.6
Applied rewrites29.6%
Taylor expanded in M around 0
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6429.6
Applied rewrites29.6%
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
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)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
def code(K, m, n, M, l): return math.cos(M)
function code(K, m, n, M, l) return cos(M) end
function tmp = code(K, m, n, M, l) tmp = cos(M); end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
\\
\cos M
\end{array}
Initial program 75.7%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6440.5
Applied rewrites40.5%
Taylor expanded in m around 0
lower-cos.f64N/A
sub-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f645.0
Applied rewrites5.0%
Taylor expanded in n around 0
cos-negN/A
lower-cos.f645.4
Applied rewrites5.4%
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
return 1.0;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = 1.0d0
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0;
}
def code(K, m, n, M, l): return 1.0
function code(K, m, n, M, l) return 1.0 end
function tmp = code(K, m, n, M, l) tmp = 1.0; end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 75.7%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6440.5
Applied rewrites40.5%
Taylor expanded in m around 0
lower-cos.f64N/A
sub-negN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f645.0
Applied rewrites5.0%
Taylor expanded in n around 0
cos-negN/A
lower-cos.f645.4
Applied rewrites5.4%
Taylor expanded in M around 0
Applied rewrites5.4%
herbie shell --seed 2024216
(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)))))))