
(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 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 75.1%
Taylor expanded in K around 0 97.3%
cos-neg97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (K m n M l) :precision binary64 (if (<= m -3.9e+33) (exp (* -0.25 (pow m 2.0))) (+ (+ 1.0 (exp (- (- (fabs (- m n)) l) (pow (- (* n 0.5) M) 2.0)))) -1.0)))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -3.9e+33) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else {
tmp = (1.0 + exp(((fabs((m - n)) - l) - pow(((n * 0.5) - M), 2.0)))) + -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.9d+33)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = (1.0d0 + exp(((abs((m - n)) - l) - (((n * 0.5d0) - m_1) ** 2.0d0)))) + (-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.9e+33) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = (1.0 + Math.exp(((Math.abs((m - n)) - l) - Math.pow(((n * 0.5) - M), 2.0)))) + -1.0;
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -3.9e+33: tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = (1.0 + math.exp(((math.fabs((m - n)) - l) - math.pow(((n * 0.5) - M), 2.0)))) + -1.0 return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -3.9e+33) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = Float64(Float64(1.0 + exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(n * 0.5) - M) ^ 2.0)))) + -1.0); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -3.9e+33) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = (1.0 + exp(((abs((m - n)) - l) - (((n * 0.5) - M) ^ 2.0)))) + -1.0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -3.9e+33], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(1.0 + N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.9 \cdot 10^{+33}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + e^{\left(\left|m - n\right| - \ell\right) - {\left(n \cdot 0.5 - M\right)}^{2}}\right) + -1\\
\end{array}
\end{array}
if m < -3.9000000000000002e33Initial program 70.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 98.1%
Taylor expanded in m around inf 98.2%
if -3.9000000000000002e33 < m Initial program 76.3%
Taylor expanded in K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Taylor expanded in M around 0 96.2%
*-un-lft-identity96.2%
expm1-log1p-u96.2%
expm1-undefine96.2%
Applied egg-rr96.2%
Taylor expanded in m around 0 86.9%
+-commutative86.9%
associate--r+86.9%
*-commutative86.9%
Simplified86.9%
Final simplification89.3%
(FPCore (K m n M l) :precision binary64 (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0))))
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 75.1%
Taylor expanded in K around 0 97.3%
cos-neg97.3%
Simplified97.3%
Taylor expanded in M around 0 96.6%
Final simplification96.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -1.92e+27) (not (<= M 1.35e+40))) (exp (- (pow M 2.0))) (exp (+ (- (- m n) l) (* -0.25 (pow (+ m n) 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -1.92e+27) || !(M <= 1.35e+40)) {
tmp = exp(-pow(M, 2.0));
} else {
tmp = exp((((m - n) - l) + (-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) :: tmp
if ((m_1 <= (-1.92d+27)) .or. (.not. (m_1 <= 1.35d+40))) then
tmp = exp(-(m_1 ** 2.0d0))
else
tmp = exp((((m - n) - l) + ((-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 tmp;
if ((M <= -1.92e+27) || !(M <= 1.35e+40)) {
tmp = Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp((((m - n) - l) + (-0.25 * Math.pow((m + n), 2.0))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -1.92e+27) or not (M <= 1.35e+40): tmp = math.exp(-math.pow(M, 2.0)) else: tmp = math.exp((((m - n) - l) + (-0.25 * math.pow((m + n), 2.0)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -1.92e+27) || !(M <= 1.35e+40)) tmp = exp(Float64(-(M ^ 2.0))); else tmp = exp(Float64(Float64(Float64(m - n) - l) + Float64(-0.25 * (Float64(m + n) ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -1.92e+27) || ~((M <= 1.35e+40))) tmp = exp(-(M ^ 2.0)); else tmp = exp((((m - n) - l) + (-0.25 * ((m + n) ^ 2.0)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -1.92e+27], N[Not[LessEqual[M, 1.35e+40]], $MachinePrecision]], N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision], N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] + N[(-0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -1.92 \cdot 10^{+27} \lor \neg \left(M \leq 1.35 \cdot 10^{+40}\right):\\
\;\;\;\;e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(\left(m - n\right) - \ell\right) + -0.25 \cdot {\left(m + n\right)}^{2}}\\
\end{array}
\end{array}
if M < -1.92000000000000004e27 or 1.35000000000000005e40 < M Initial program 74.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 99.1%
Taylor expanded in M around inf 99.2%
mul-1-neg99.2%
Simplified99.2%
if -1.92000000000000004e27 < M < 1.35000000000000005e40Initial program 75.7%
Taylor expanded in K around 0 95.0%
cos-neg95.0%
Simplified95.0%
Taylor expanded in M around 0 93.0%
associate--r+93.0%
cancel-sign-sub-inv93.0%
sub-neg93.0%
neg-mul-193.0%
neg-mul-193.0%
sub-neg93.0%
rem-square-sqrt51.8%
fabs-sqr51.8%
rem-square-sqrt93.0%
metadata-eval93.0%
Simplified93.0%
Final simplification95.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- (pow M 2.0)))))
(if (<= M -300000.0)
t_0
(if (<= M -3.4e-65)
(exp (- l))
(if (<= M 27.0) (exp (* -0.25 (pow m 2.0))) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-pow(M, 2.0));
double tmp;
if (M <= -300000.0) {
tmp = t_0;
} else if (M <= -3.4e-65) {
tmp = exp(-l);
} else if (M <= 27.0) {
tmp = exp((-0.25 * pow(m, 2.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 ** 2.0d0))
if (m_1 <= (-300000.0d0)) then
tmp = t_0
else if (m_1 <= (-3.4d-65)) then
tmp = exp(-l)
else if (m_1 <= 27.0d0) then
tmp = exp(((-0.25d0) * (m ** 2.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(-Math.pow(M, 2.0));
double tmp;
if (M <= -300000.0) {
tmp = t_0;
} else if (M <= -3.4e-65) {
tmp = Math.exp(-l);
} else if (M <= 27.0) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-math.pow(M, 2.0)) tmp = 0 if M <= -300000.0: tmp = t_0 elif M <= -3.4e-65: tmp = math.exp(-l) elif M <= 27.0: tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-(M ^ 2.0))) tmp = 0.0 if (M <= -300000.0) tmp = t_0; elseif (M <= -3.4e-65) tmp = exp(Float64(-l)); elseif (M <= 27.0) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-(M ^ 2.0)); tmp = 0.0; if (M <= -300000.0) tmp = t_0; elseif (M <= -3.4e-65) tmp = exp(-l); elseif (M <= 27.0) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]}, If[LessEqual[M, -300000.0], t$95$0, If[LessEqual[M, -3.4e-65], N[Exp[(-l)], $MachinePrecision], If[LessEqual[M, 27.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-{M}^{2}}\\
\mathbf{if}\;M \leq -300000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq -3.4 \cdot 10^{-65}:\\
\;\;\;\;e^{-\ell}\\
\mathbf{elif}\;M \leq 27:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -3e5 or 27 < M Initial program 74.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 98.5%
Taylor expanded in M around inf 96.3%
mul-1-neg96.3%
Simplified96.3%
if -3e5 < M < -3.39999999999999987e-65Initial program 72.9%
Taylor expanded in K around 0 91.1%
cos-neg91.1%
Simplified91.1%
Taylor expanded in M around 0 92.8%
Taylor expanded in l around inf 74.5%
mul-1-neg74.5%
Simplified74.5%
if -3.39999999999999987e-65 < M < 27Initial program 75.9%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in M around 0 94.7%
Taylor expanded in m around inf 59.8%
Final simplification79.5%
(FPCore (K m n M l) :precision binary64 (if (<= m -2.46e+30) (exp (* -0.25 (pow m 2.0))) (if (<= m 2e-187) (exp (- (pow M 2.0))) (exp (* -0.25 (pow n 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2.46e+30) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 2e-187) {
tmp = exp(-pow(M, 2.0));
} else {
tmp = exp((-0.25 * pow(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) :: tmp
if (m <= (-2.46d+30)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 2d-187) then
tmp = exp(-(m_1 ** 2.0d0))
else
tmp = exp(((-0.25d0) * (n ** 2.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 <= -2.46e+30) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 2e-187) {
tmp = Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -2.46e+30: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 2e-187: tmp = math.exp(-math.pow(M, 2.0)) else: tmp = math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -2.46e+30) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 2e-187) tmp = exp(Float64(-(M ^ 2.0))); else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -2.46e+30) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= 2e-187) tmp = exp(-(M ^ 2.0)); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -2.46e+30], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 2e-187], N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.46 \cdot 10^{+30}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 2 \cdot 10^{-187}:\\
\;\;\;\;e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if m < -2.4599999999999999e30Initial program 70.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 98.1%
Taylor expanded in m around inf 98.2%
if -2.4599999999999999e30 < m < 2e-187Initial program 80.4%
Taylor expanded in K around 0 96.1%
cos-neg96.1%
Simplified96.1%
Taylor expanded in M around 0 95.3%
Taylor expanded in M around inf 61.7%
mul-1-neg61.7%
Simplified61.7%
if 2e-187 < m Initial program 72.3%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in M around 0 97.1%
Taylor expanded in n around inf 51.0%
Final simplification65.2%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -300000.0) (not (<= M 1.95e-14))) (exp (- (pow M 2.0))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -300000.0) || !(M <= 1.95e-14)) {
tmp = exp(-pow(M, 2.0));
} else {
tmp = 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 ((m_1 <= (-300000.0d0)) .or. (.not. (m_1 <= 1.95d-14))) then
tmp = exp(-(m_1 ** 2.0d0))
else
tmp = 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 ((M <= -300000.0) || !(M <= 1.95e-14)) {
tmp = Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -300000.0) or not (M <= 1.95e-14): tmp = math.exp(-math.pow(M, 2.0)) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -300000.0) || !(M <= 1.95e-14)) tmp = exp(Float64(-(M ^ 2.0))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -300000.0) || ~((M <= 1.95e-14))) tmp = exp(-(M ^ 2.0)); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -300000.0], N[Not[LessEqual[M, 1.95e-14]], $MachinePrecision]], N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -300000 \lor \neg \left(M \leq 1.95 \cdot 10^{-14}\right):\\
\;\;\;\;e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if M < -3e5 or 1.9499999999999999e-14 < M Initial program 74.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 98.5%
Taylor expanded in M around inf 94.3%
mul-1-neg94.3%
Simplified94.3%
if -3e5 < M < 1.9499999999999999e-14Initial program 75.8%
Taylor expanded in K around 0 94.2%
cos-neg94.2%
Simplified94.2%
Taylor expanded in M around 0 94.3%
Taylor expanded in l around inf 44.4%
mul-1-neg44.4%
Simplified44.4%
Final simplification71.1%
(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 75.1%
Taylor expanded in l around inf 30.2%
mul-1-neg35.7%
Simplified30.2%
Taylor expanded in K around 0 36.5%
cos-neg36.5%
Simplified36.5%
(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.1%
Taylor expanded in K around 0 97.3%
cos-neg97.3%
Simplified97.3%
Taylor expanded in M around 0 96.6%
Taylor expanded in l around inf 35.7%
mul-1-neg35.7%
Simplified35.7%
Final simplification35.7%
(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.1%
Taylor expanded in l around inf 30.2%
mul-1-neg35.7%
Simplified30.2%
Taylor expanded in l around 0 4.7%
Taylor expanded in K around 0 5.3%
cos-neg5.3%
Simplified5.3%
Taylor expanded in M around 0 5.4%
herbie shell --seed 2024157
(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)))))))