
(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 (* (cos M) (exp (- (fabs (- m n)) (+ (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((m - n)) - (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((m - n)) - (((((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((m - n)) - (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((m - n)) - (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(m - n)) - 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((m - n)) - (((((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[(m - n), $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|m - n\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 71.6%
associate-/l*71.6%
associate--r-71.6%
Simplified71.6%
Taylor expanded in K around 0 97.8%
cos-neg97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (<= M -1.12e+72)
(* (cos M) (exp (- t_0 (* M M))))
(exp (- t_0 (+ l (* 0.25 (pow (+ m n) 2.0))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if (M <= -1.12e+72) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = exp((t_0 - (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) :: t_0
real(8) :: tmp
t_0 = abs((m - n))
if (m_1 <= (-1.12d+72)) then
tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
else
tmp = exp((t_0 - (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 t_0 = Math.abs((m - n));
double tmp;
if (M <= -1.12e+72) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
} else {
tmp = Math.exp((t_0 - (l + (0.25 * Math.pow((m + n), 2.0)))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if M <= -1.12e+72: tmp = math.cos(M) * math.exp((t_0 - (M * M))) else: tmp = math.exp((t_0 - (l + (0.25 * math.pow((m + n), 2.0))))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if (M <= -1.12e+72) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * (Float64(m + n) ^ 2.0))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if (M <= -1.12e+72) tmp = cos(M) * exp((t_0 - (M * M))); else tmp = exp((t_0 - (l + (0.25 * ((m + n) ^ 2.0))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -1.12e+72], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;M \leq -1.12 \cdot 10^{+72}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot {\left(m + n\right)}^{2}\right)}\\
\end{array}
\end{array}
if M < -1.12000000000000001e72Initial program 74.5%
associate-/l*74.5%
associate--r-74.5%
Simplified74.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 92.3%
mul-1-neg92.3%
unpow292.3%
distribute-rgt-neg-in92.3%
Simplified92.3%
Taylor expanded in M around inf 92.3%
cos-neg92.3%
*-commutative92.3%
sub-neg92.3%
mul-1-neg92.3%
cos-neg92.3%
mul-1-neg92.3%
sub-neg92.3%
unpow292.3%
Simplified92.3%
if -1.12000000000000001e72 < M Initial program 70.9%
associate-/l*70.9%
associate--r-70.9%
Simplified70.9%
Taylor expanded in K around 0 97.3%
cos-neg97.3%
Simplified97.3%
Taylor expanded in M around 0 93.2%
fabs-sub93.2%
Simplified93.2%
Final simplification93.0%
(FPCore (K m n M l) :precision binary64 (if (<= m -2000.0) (exp (* (* m m) -0.25)) (exp (- (fabs (- m n)) (+ l (* 0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2000.0) {
tmp = exp(((m * m) * -0.25));
} else {
tmp = exp((fabs((m - n)) - (l + (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 <= (-2000.0d0)) then
tmp = exp(((m * m) * (-0.25d0)))
else
tmp = exp((abs((m - n)) - (l + (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 <= -2000.0) {
tmp = Math.exp(((m * m) * -0.25));
} else {
tmp = Math.exp((Math.abs((m - n)) - (l + (0.25 * (n * n)))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -2000.0: tmp = math.exp(((m * m) * -0.25)) else: tmp = math.exp((math.fabs((m - n)) - (l + (0.25 * (n * n))))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -2000.0) tmp = exp(Float64(Float64(m * m) * -0.25)); else tmp = exp(Float64(abs(Float64(m - n)) - Float64(l + Float64(0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -2000.0) tmp = exp(((m * m) * -0.25)); else tmp = exp((abs((m - n)) - (l + (0.25 * (n * n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -2000.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2000:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;e^{\left|m - n\right| - \left(\ell + 0.25 \cdot \left(n \cdot n\right)\right)}\\
\end{array}
\end{array}
if m < -2e3Initial program 57.4%
associate-/l*57.4%
associate--r-57.4%
Simplified57.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
fabs-sub100.0%
Simplified100.0%
Taylor expanded in m around inf 100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
if -2e3 < m Initial program 76.1%
associate-/l*76.1%
associate--r-76.1%
Simplified76.1%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in M around 0 87.3%
fabs-sub87.3%
Simplified87.3%
Taylor expanded in m around 0 65.1%
*-commutative65.1%
unpow265.1%
Simplified65.1%
Final simplification73.4%
(FPCore (K m n M l) :precision binary64 (if (<= m -54.0) (exp (* (* m m) -0.25)) (if (<= m -8e-216) (/ (cos M) (exp l)) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = exp(((m * m) * -0.25));
} else if (m <= -8e-216) {
tmp = cos(M) / exp(l);
} 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 <= (-54.0d0)) then
tmp = exp(((m * m) * (-0.25d0)))
else if (m <= (-8d-216)) then
tmp = cos(m_1) / exp(l)
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 <= -54.0) {
tmp = Math.exp(((m * m) * -0.25));
} else if (m <= -8e-216) {
tmp = Math.cos(M) / Math.exp(l);
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -54.0: tmp = math.exp(((m * m) * -0.25)) elif m <= -8e-216: tmp = math.cos(M) / math.exp(l) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -54.0) tmp = exp(Float64(Float64(m * m) * -0.25)); elseif (m <= -8e-216) tmp = Float64(cos(M) / exp(l)); 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 <= -54.0) tmp = exp(((m * m) * -0.25)); elseif (m <= -8e-216) tmp = cos(M) / exp(l); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -54.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -8e-216], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -54:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;m \leq -8 \cdot 10^{-216}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -54Initial program 57.4%
associate-/l*57.4%
associate--r-57.4%
Simplified57.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
fabs-sub100.0%
Simplified100.0%
Taylor expanded in m around inf 100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
if -54 < m < -8.0000000000000003e-216Initial program 84.6%
Simplified84.6%
Taylor expanded in l around inf 52.1%
Taylor expanded in K around 0 56.8%
cos-neg56.8%
Simplified56.8%
if -8.0000000000000003e-216 < m Initial program 73.6%
associate-/l*73.8%
associate--r-73.8%
Simplified73.8%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in M around 0 90.5%
fabs-sub90.5%
Simplified90.5%
Taylor expanded in n around inf 53.8%
*-commutative53.8%
unpow253.8%
Simplified53.8%
Final simplification65.3%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -54.0) (not (<= m 53.0))) (exp (* (* m m) -0.25)) (/ 1.0 (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -54.0) || !(m <= 53.0)) {
tmp = exp(((m * m) * -0.25));
} else {
tmp = 1.0 / 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 <= (-54.0d0)) .or. (.not. (m <= 53.0d0))) then
tmp = exp(((m * m) * (-0.25d0)))
else
tmp = 1.0d0 / 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 <= -54.0) || !(m <= 53.0)) {
tmp = Math.exp(((m * m) * -0.25));
} else {
tmp = 1.0 / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -54.0) or not (m <= 53.0): tmp = math.exp(((m * m) * -0.25)) else: tmp = 1.0 / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -54.0) || !(m <= 53.0)) tmp = exp(Float64(Float64(m * m) * -0.25)); else tmp = Float64(1.0 / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -54.0) || ~((m <= 53.0))) tmp = exp(((m * m) * -0.25)); else tmp = 1.0 / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -54.0], N[Not[LessEqual[m, 53.0]], $MachinePrecision]], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[(1.0 / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -54 \lor \neg \left(m \leq 53\right):\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{e^{\ell}}\\
\end{array}
\end{array}
if m < -54 or 53 < m Initial program 63.7%
associate-/l*63.7%
associate--r-63.7%
Simplified63.7%
Taylor expanded in K around 0 99.3%
cos-neg99.3%
Simplified99.3%
Taylor expanded in M around 0 98.5%
fabs-sub98.5%
Simplified98.5%
Taylor expanded in m around inf 97.8%
*-commutative97.8%
unpow297.8%
Simplified97.8%
if -54 < m < 53Initial program 80.5%
Simplified80.5%
Taylor expanded in l around inf 43.3%
Taylor expanded in K around 0 48.5%
cos-neg48.5%
Simplified48.5%
Taylor expanded in M around 0 48.5%
Final simplification74.5%
(FPCore (K m n M l) :precision binary64 (if (<= m -54.0) (exp (* (* m m) -0.25)) (if (<= m -1.8e-215) (/ 1.0 (exp l)) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = exp(((m * m) * -0.25));
} else if (m <= -1.8e-215) {
tmp = 1.0 / exp(l);
} 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 <= (-54.0d0)) then
tmp = exp(((m * m) * (-0.25d0)))
else if (m <= (-1.8d-215)) then
tmp = 1.0d0 / exp(l)
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 <= -54.0) {
tmp = Math.exp(((m * m) * -0.25));
} else if (m <= -1.8e-215) {
tmp = 1.0 / Math.exp(l);
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -54.0: tmp = math.exp(((m * m) * -0.25)) elif m <= -1.8e-215: tmp = 1.0 / math.exp(l) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -54.0) tmp = exp(Float64(Float64(m * m) * -0.25)); elseif (m <= -1.8e-215) tmp = Float64(1.0 / exp(l)); 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 <= -54.0) tmp = exp(((m * m) * -0.25)); elseif (m <= -1.8e-215) tmp = 1.0 / exp(l); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -54.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -1.8e-215], N[(1.0 / N[Exp[l], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -54:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;m \leq -1.8 \cdot 10^{-215}:\\
\;\;\;\;\frac{1}{e^{\ell}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -54Initial program 57.4%
associate-/l*57.4%
associate--r-57.4%
Simplified57.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
fabs-sub100.0%
Simplified100.0%
Taylor expanded in m around inf 100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
if -54 < m < -1.7999999999999999e-215Initial program 84.6%
Simplified84.6%
Taylor expanded in l around inf 52.1%
Taylor expanded in K around 0 56.8%
cos-neg56.8%
Simplified56.8%
Taylor expanded in M around 0 56.7%
if -1.7999999999999999e-215 < m Initial program 73.6%
associate-/l*73.8%
associate--r-73.8%
Simplified73.8%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in M around 0 90.5%
fabs-sub90.5%
Simplified90.5%
Taylor expanded in n around inf 53.8%
*-commutative53.8%
unpow253.8%
Simplified53.8%
Final simplification65.3%
(FPCore (K m n M l) :precision binary64 (/ 1.0 (exp l)))
double code(double K, double m, double n, double M, double l) {
return 1.0 / 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 = 1.0d0 / exp(l)
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0 / Math.exp(l);
}
def code(K, m, n, M, l): return 1.0 / math.exp(l)
function code(K, m, n, M, l) return Float64(1.0 / exp(l)) end
function tmp = code(K, m, n, M, l) tmp = 1.0 / exp(l); end
code[K_, m_, n_, M_, l_] := N[(1.0 / N[Exp[l], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e^{\ell}}
\end{array}
Initial program 71.6%
Simplified71.6%
Taylor expanded in l around inf 30.5%
Taylor expanded in K around 0 39.1%
cos-neg39.1%
Simplified39.1%
Taylor expanded in M around 0 39.1%
Final simplification39.1%
(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 71.6%
associate-/l*71.6%
associate--r-71.6%
Simplified71.6%
Taylor expanded in K around 0 97.8%
cos-neg97.8%
Simplified97.8%
Taylor expanded in M around 0 90.4%
fabs-sub90.4%
Simplified90.4%
Taylor expanded in l around inf 39.1%
mul-1-neg39.1%
Simplified39.1%
Final simplification39.1%
(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 71.6%
Simplified71.6%
Taylor expanded in l around inf 30.5%
Taylor expanded in K around 0 39.1%
cos-neg39.1%
Simplified39.1%
Taylor expanded in l around 0 5.6%
Final simplification5.6%
herbie shell --seed 2023218
(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)))))))