
(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 (fabs (- m n)))
(t_1 (exp (- (- t_0 l) (pow (- (/ (+ m n) 2.0) M) 2.0))))
(t_2 (* K (+ m n))))
(if (<= (* (cos (- (/ t_2 2.0) M)) t_1) INFINITY)
(* t_1 (cos (- (/ (pow (cbrt t_2) 3.0) 2.0) M)))
(exp (- t_0 (+ l (* (pow (+ m n) 2.0) 0.25)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double t_1 = exp(((t_0 - l) - pow((((m + n) / 2.0) - M), 2.0)));
double t_2 = K * (m + n);
double tmp;
if ((cos(((t_2 / 2.0) - M)) * t_1) <= ((double) INFINITY)) {
tmp = t_1 * cos(((pow(cbrt(t_2), 3.0) / 2.0) - M));
} else {
tmp = exp((t_0 - (l + (pow((m + n), 2.0) * 0.25))));
}
return tmp;
}
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.abs((m - n));
double t_1 = Math.exp(((t_0 - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
double t_2 = K * (m + n);
double tmp;
if ((Math.cos(((t_2 / 2.0) - M)) * t_1) <= Double.POSITIVE_INFINITY) {
tmp = t_1 * Math.cos(((Math.pow(Math.cbrt(t_2), 3.0) / 2.0) - M));
} else {
tmp = Math.exp((t_0 - (l + (Math.pow((m + n), 2.0) * 0.25))));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) t_1 = exp(Float64(Float64(t_0 - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) t_2 = Float64(K * Float64(m + n)) tmp = 0.0 if (Float64(cos(Float64(Float64(t_2 / 2.0) - M)) * t_1) <= Inf) tmp = Float64(t_1 * cos(Float64(Float64((cbrt(t_2) ^ 3.0) / 2.0) - M))); else tmp = exp(Float64(t_0 - Float64(l + Float64((Float64(m + n) ^ 2.0) * 0.25)))); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(t$95$0 - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(t$95$2 / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], Infinity], N[(t$95$1 * N[Cos[N[(N[(N[Power[N[Power[t$95$2, 1/3], $MachinePrecision], 3.0], $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(l + N[(N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
t_1 := e^{\left(t_0 - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
t_2 := K \cdot \left(m + n\right)\\
\mathbf{if}\;\cos \left(\frac{t_2}{2} - M\right) \cdot t_1 \leq \infty:\\
\;\;\;\;t_1 \cdot \cos \left(\frac{{\left(\sqrt[3]{t_2}\right)}^{3}}{2} - M\right)\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \left(\ell + {\left(m + n\right)}^{2} \cdot 0.25\right)}\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) < +inf.0Initial program 93.3%
add-cube-cbrt94.7%
pow394.8%
Applied egg-rr94.8%
if +inf.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 0.0%
Taylor expanded in M around 0 0.0%
associate-*r*0.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
Simplified0.0%
Taylor expanded in K around 0 100.0%
Final simplification95.9%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- m n)) (pow (- (* (+ m n) 0.5) 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) * 0.5) - 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) * 0.5d0) - 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) * 0.5) - 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) * 0.5) - M), 2.0)) - l))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)) - l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - ((((m + n) * 0.5) - M) ^ 2.0)) - l)); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}\right) - \ell}
\end{array}
Initial program 72.9%
Taylor expanded in K around 0 94.0%
Simplified94.0%
Final simplification94.0%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -2e+103) (not (<= M 6.5e+31))) (* (cos M) (exp (- (* M (- M)) l))) (exp (- (fabs (- m n)) (+ l (* (pow (+ m n) 2.0) 0.25))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -2e+103) || !(M <= 6.5e+31)) {
tmp = cos(M) * exp(((M * -M) - l));
} else {
tmp = exp((fabs((m - n)) - (l + (pow((m + n), 2.0) * 0.25))));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if ((m_1 <= (-2d+103)) .or. (.not. (m_1 <= 6.5d+31))) then
tmp = cos(m_1) * exp(((m_1 * -m_1) - l))
else
tmp = exp((abs((m - n)) - (l + (((m + n) ** 2.0d0) * 0.25d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -2e+103) || !(M <= 6.5e+31)) {
tmp = Math.cos(M) * Math.exp(((M * -M) - l));
} else {
tmp = Math.exp((Math.abs((m - n)) - (l + (Math.pow((m + n), 2.0) * 0.25))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -2e+103) or not (M <= 6.5e+31): tmp = math.cos(M) * math.exp(((M * -M) - l)) else: tmp = math.exp((math.fabs((m - n)) - (l + (math.pow((m + n), 2.0) * 0.25)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -2e+103) || !(M <= 6.5e+31)) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(-M)) - l))); else tmp = exp(Float64(abs(Float64(m - n)) - Float64(l + Float64((Float64(m + n) ^ 2.0) * 0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -2e+103) || ~((M <= 6.5e+31))) tmp = cos(M) * exp(((M * -M) - l)); else tmp = exp((abs((m - n)) - (l + (((m + n) ^ 2.0) * 0.25)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -2e+103], N[Not[LessEqual[M, 6.5e+31]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * (-M)), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[(N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -2 \cdot 10^{+103} \lor \neg \left(M \leq 6.5 \cdot 10^{+31}\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{\left|m - n\right| - \left(\ell + {\left(m + n\right)}^{2} \cdot 0.25\right)}\\
\end{array}
\end{array}
if M < -2e103 or 6.5000000000000004e31 < M Initial program 73.5%
Taylor expanded in K around 0 99.0%
Simplified99.0%
Taylor expanded in M around inf 99.0%
neg-mul-199.0%
unpow299.0%
distribute-rgt-neg-in99.0%
Simplified99.0%
if -2e103 < M < 6.5000000000000004e31Initial program 72.5%
Taylor expanded in M around 0 71.9%
associate-*r*71.9%
*-commutative71.9%
*-commutative71.9%
*-commutative71.9%
Simplified71.9%
Taylor expanded in K around 0 90.6%
Final simplification94.0%
(FPCore (K m n M l)
:precision binary64
(if (<= n -8e-153)
(* (cos M) (exp (- (* (* m m) -0.25) l)))
(if (<= n 6.8e-10)
(* (cos M) (exp (- (* M (- M)) l)))
(* (cos M) (exp (- (* -0.25 (* n n)) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -8e-153) {
tmp = cos(M) * exp((((m * m) * -0.25) - l));
} else if (n <= 6.8e-10) {
tmp = cos(M) * exp(((M * -M) - l));
} else {
tmp = cos(M) * exp(((-0.25 * (n * n)) - 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 (n <= (-8d-153)) then
tmp = cos(m_1) * exp((((m * m) * (-0.25d0)) - l))
else if (n <= 6.8d-10) then
tmp = cos(m_1) * exp(((m_1 * -m_1) - l))
else
tmp = cos(m_1) * exp((((-0.25d0) * (n * n)) - l))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -8e-153) {
tmp = Math.cos(M) * Math.exp((((m * m) * -0.25) - l));
} else if (n <= 6.8e-10) {
tmp = Math.cos(M) * Math.exp(((M * -M) - l));
} else {
tmp = Math.cos(M) * Math.exp(((-0.25 * (n * n)) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= -8e-153: tmp = math.cos(M) * math.exp((((m * m) * -0.25) - l)) elif n <= 6.8e-10: tmp = math.cos(M) * math.exp(((M * -M) - l)) else: tmp = math.cos(M) * math.exp(((-0.25 * (n * n)) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= -8e-153) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(m * m) * -0.25) - l))); elseif (n <= 6.8e-10) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(-M)) - l))); else tmp = Float64(cos(M) * exp(Float64(Float64(-0.25 * Float64(n * n)) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= -8e-153) tmp = cos(M) * exp((((m * m) * -0.25) - l)); elseif (n <= 6.8e-10) tmp = cos(M) * exp(((M * -M) - l)); else tmp = cos(M) * exp(((-0.25 * (n * n)) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, -8e-153], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 6.8e-10], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * (-M)), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8 \cdot 10^{-153}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25 - \ell}\\
\mathbf{elif}\;n \leq 6.8 \cdot 10^{-10}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right) - \ell}\\
\end{array}
\end{array}
if n < -8.00000000000000031e-153Initial program 65.3%
Taylor expanded in K around 0 91.1%
Simplified91.1%
Taylor expanded in m around inf 70.0%
*-commutative70.0%
unpow270.0%
Simplified70.0%
if -8.00000000000000031e-153 < n < 6.8000000000000003e-10Initial program 84.3%
Taylor expanded in K around 0 93.4%
Simplified93.4%
Taylor expanded in M around inf 82.5%
neg-mul-182.5%
unpow282.5%
distribute-rgt-neg-in82.5%
Simplified82.5%
if 6.8000000000000003e-10 < n Initial program 66.7%
Taylor expanded in K around 0 100.0%
Simplified100.0%
Taylor expanded in n around inf 89.7%
*-commutative89.7%
unpow289.7%
Simplified89.7%
Final simplification79.2%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -8.5e-153) (not (<= n 32000.0))) (exp (* n (+ (* m -0.5) (* n -0.25)))) (* (cos M) (exp (- (* M (- M)) l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -8.5e-153) || !(n <= 32000.0)) {
tmp = exp((n * ((m * -0.5) + (n * -0.25))));
} else {
tmp = cos(M) * exp(((M * -M) - 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 ((n <= (-8.5d-153)) .or. (.not. (n <= 32000.0d0))) then
tmp = exp((n * ((m * (-0.5d0)) + (n * (-0.25d0)))))
else
tmp = cos(m_1) * exp(((m_1 * -m_1) - l))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -8.5e-153) || !(n <= 32000.0)) {
tmp = Math.exp((n * ((m * -0.5) + (n * -0.25))));
} else {
tmp = Math.cos(M) * Math.exp(((M * -M) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -8.5e-153) or not (n <= 32000.0): tmp = math.exp((n * ((m * -0.5) + (n * -0.25)))) else: tmp = math.cos(M) * math.exp(((M * -M) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -8.5e-153) || !(n <= 32000.0)) tmp = exp(Float64(n * Float64(Float64(m * -0.5) + Float64(n * -0.25)))); else tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(-M)) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((n <= -8.5e-153) || ~((n <= 32000.0))) tmp = exp((n * ((m * -0.5) + (n * -0.25)))); else tmp = cos(M) * exp(((M * -M) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -8.5e-153], N[Not[LessEqual[n, 32000.0]], $MachinePrecision]], N[Exp[N[(n * N[(N[(m * -0.5), $MachinePrecision] + N[(n * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * (-M)), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.5 \cdot 10^{-153} \lor \neg \left(n \leq 32000\right):\\
\;\;\;\;e^{n \cdot \left(m \cdot -0.5 + n \cdot -0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right) - \ell}\\
\end{array}
\end{array}
if n < -8.4999999999999996e-153 or 32000 < n Initial program 65.5%
Taylor expanded in M around 0 61.7%
associate-*r*61.7%
*-commutative61.7%
*-commutative61.7%
*-commutative61.7%
Simplified61.7%
Taylor expanded in n around inf 42.1%
+-commutative42.1%
*-commutative42.1%
fma-def42.1%
unpow242.1%
associate-*r*42.1%
metadata-eval42.1%
*-commutative42.1%
metadata-eval42.1%
*-commutative42.1%
Simplified42.1%
Taylor expanded in K around 0 58.4%
associate-*r*58.4%
*-commutative58.4%
*-commutative58.4%
unpow258.4%
associate-*l*58.4%
distribute-lft-out63.1%
Simplified63.1%
if -8.4999999999999996e-153 < n < 32000Initial program 83.9%
Taylor expanded in K around 0 93.6%
Simplified93.6%
Taylor expanded in M around inf 82.3%
neg-mul-182.3%
unpow282.3%
distribute-rgt-neg-in82.3%
Simplified82.3%
Final simplification70.8%
(FPCore (K m n M l)
:precision binary64
(if (<= m -86000000000000.0)
(* (cos M) (exp (- (* (* m m) -0.25) l)))
(if (<= m 4.8e-180)
(* (cos M) (exp (- (* M (- M)) l)))
(exp (* n (+ (* m -0.5) (* n -0.25)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -86000000000000.0) {
tmp = cos(M) * exp((((m * m) * -0.25) - l));
} else if (m <= 4.8e-180) {
tmp = cos(M) * exp(((M * -M) - l));
} else {
tmp = exp((n * ((m * -0.5) + (n * -0.25))));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-86000000000000.0d0)) then
tmp = cos(m_1) * exp((((m * m) * (-0.25d0)) - l))
else if (m <= 4.8d-180) then
tmp = cos(m_1) * exp(((m_1 * -m_1) - l))
else
tmp = exp((n * ((m * (-0.5d0)) + (n * (-0.25d0)))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -86000000000000.0) {
tmp = Math.cos(M) * Math.exp((((m * m) * -0.25) - l));
} else if (m <= 4.8e-180) {
tmp = Math.cos(M) * Math.exp(((M * -M) - l));
} else {
tmp = Math.exp((n * ((m * -0.5) + (n * -0.25))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -86000000000000.0: tmp = math.cos(M) * math.exp((((m * m) * -0.25) - l)) elif m <= 4.8e-180: tmp = math.cos(M) * math.exp(((M * -M) - l)) else: tmp = math.exp((n * ((m * -0.5) + (n * -0.25)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -86000000000000.0) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(m * m) * -0.25) - l))); elseif (m <= 4.8e-180) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(-M)) - l))); else tmp = exp(Float64(n * Float64(Float64(m * -0.5) + Float64(n * -0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -86000000000000.0) tmp = cos(M) * exp((((m * m) * -0.25) - l)); elseif (m <= 4.8e-180) tmp = cos(M) * exp(((M * -M) - l)); else tmp = exp((n * ((m * -0.5) + (n * -0.25)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -86000000000000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4.8e-180], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * (-M)), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(n * N[(N[(m * -0.5), $MachinePrecision] + N[(n * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -86000000000000:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25 - \ell}\\
\mathbf{elif}\;m \leq 4.8 \cdot 10^{-180}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{n \cdot \left(m \cdot -0.5 + n \cdot -0.25\right)}\\
\end{array}
\end{array}
if m < -8.6e13Initial program 70.7%
Taylor expanded in K around 0 98.3%
Simplified98.3%
Taylor expanded in m around inf 96.6%
*-commutative96.6%
unpow296.6%
Simplified96.6%
if -8.6e13 < m < 4.79999999999999959e-180Initial program 77.8%
Taylor expanded in K around 0 87.7%
Simplified87.7%
Taylor expanded in M around inf 75.9%
neg-mul-175.9%
unpow275.9%
distribute-rgt-neg-in75.9%
Simplified75.9%
if 4.79999999999999959e-180 < m Initial program 70.2%
Taylor expanded in M around 0 62.2%
associate-*r*62.2%
*-commutative62.2%
*-commutative62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in n around inf 26.3%
+-commutative26.3%
*-commutative26.3%
fma-def26.3%
unpow226.3%
associate-*r*26.3%
metadata-eval26.3%
*-commutative26.3%
metadata-eval26.3%
*-commutative26.3%
Simplified26.3%
Taylor expanded in K around 0 42.9%
associate-*r*42.9%
*-commutative42.9%
*-commutative42.9%
unpow242.9%
associate-*l*42.9%
distribute-lft-out45.7%
Simplified45.7%
Final simplification67.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -3.25e-167) (not (<= n 54.0))) (exp (* n (+ (* m -0.5) (* n -0.25)))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -3.25e-167) || !(n <= 54.0)) {
tmp = exp((n * ((m * -0.5) + (n * -0.25))));
} 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 ((n <= (-3.25d-167)) .or. (.not. (n <= 54.0d0))) then
tmp = exp((n * ((m * (-0.5d0)) + (n * (-0.25d0)))))
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 ((n <= -3.25e-167) || !(n <= 54.0)) {
tmp = Math.exp((n * ((m * -0.5) + (n * -0.25))));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -3.25e-167) or not (n <= 54.0): tmp = math.exp((n * ((m * -0.5) + (n * -0.25)))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -3.25e-167) || !(n <= 54.0)) tmp = exp(Float64(n * Float64(Float64(m * -0.5) + Float64(n * -0.25)))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((n <= -3.25e-167) || ~((n <= 54.0))) tmp = exp((n * ((m * -0.5) + (n * -0.25)))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -3.25e-167], N[Not[LessEqual[n, 54.0]], $MachinePrecision]], N[Exp[N[(n * N[(N[(m * -0.5), $MachinePrecision] + N[(n * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.25 \cdot 10^{-167} \lor \neg \left(n \leq 54\right):\\
\;\;\;\;e^{n \cdot \left(m \cdot -0.5 + n \cdot -0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if n < -3.24999999999999987e-167 or 54 < n Initial program 65.5%
Taylor expanded in M around 0 61.7%
associate-*r*61.7%
*-commutative61.7%
*-commutative61.7%
*-commutative61.7%
Simplified61.7%
Taylor expanded in n around inf 42.1%
+-commutative42.1%
*-commutative42.1%
fma-def42.1%
unpow242.1%
associate-*r*42.1%
metadata-eval42.1%
*-commutative42.1%
metadata-eval42.1%
*-commutative42.1%
Simplified42.1%
Taylor expanded in K around 0 58.4%
associate-*r*58.4%
*-commutative58.4%
*-commutative58.4%
unpow258.4%
associate-*l*58.4%
distribute-lft-out63.1%
Simplified63.1%
if -3.24999999999999987e-167 < n < 54Initial program 83.9%
Taylor expanded in M around 0 75.4%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
*-commutative75.4%
Simplified75.4%
Taylor expanded in K around 0 86.1%
Taylor expanded in l around inf 45.4%
neg-mul-145.4%
Simplified45.4%
Final simplification56.0%
(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 72.9%
Taylor expanded in M around 0 67.2%
associate-*r*67.2%
*-commutative67.2%
*-commutative67.2%
*-commutative67.2%
Simplified67.2%
Taylor expanded in K around 0 88.2%
Taylor expanded in l around inf 37.8%
neg-mul-137.8%
Simplified37.8%
Final simplification37.8%
(FPCore (K m n M l) :precision binary64 (+ 1.0 (* -0.125 (* (* m m) (* K K)))))
double code(double K, double m, double n, double M, double l) {
return 1.0 + (-0.125 * ((m * m) * (K * K)));
}
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 + ((-0.125d0) * ((m * m) * (k * k)))
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0 + (-0.125 * ((m * m) * (K * K)));
}
def code(K, m, n, M, l): return 1.0 + (-0.125 * ((m * m) * (K * K)))
function code(K, m, n, M, l) return Float64(1.0 + Float64(-0.125 * Float64(Float64(m * m) * Float64(K * K)))) end
function tmp = code(K, m, n, M, l) tmp = 1.0 + (-0.125 * ((m * m) * (K * K))); end
code[K_, m_, n_, M_, l_] := N[(1.0 + N[(-0.125 * N[(N[(m * m), $MachinePrecision] * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + -0.125 \cdot \left(\left(m \cdot m\right) \cdot \left(K \cdot K\right)\right)
\end{array}
Initial program 72.9%
Taylor expanded in M around 0 67.2%
associate-*r*67.2%
*-commutative67.2%
*-commutative67.2%
*-commutative67.2%
Simplified67.2%
Taylor expanded in n around inf 29.9%
+-commutative29.9%
*-commutative29.9%
fma-def29.9%
unpow229.9%
associate-*r*29.9%
metadata-eval29.9%
*-commutative29.9%
metadata-eval29.9%
*-commutative29.9%
Simplified29.9%
Taylor expanded in K around 0 13.6%
*-commutative13.6%
+-commutative13.6%
unpow213.6%
Simplified13.6%
Taylor expanded in n around 0 5.8%
unpow25.8%
unpow25.8%
Simplified5.8%
Final simplification5.8%
herbie shell --seed 2023277
(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)))))))