
(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 (- n m)) 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((n - m)) - 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((n - m)) - 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((n - m)) - 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((n - m)) - 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(n - m)) - 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((n - m)) - 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[(n - m), $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|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 78.0%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
Simplified96.7%
Final simplification96.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (- (pow M 2.0))))))
(if (<= m -55.0)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= m -2.6e-46)
t_0
(if (<= m -3.2e-56)
(/ (cos M) (exp l))
(if (<= m 3.1e-173) t_0 (* (cos M) (exp (* (pow n 2.0) -0.25)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp(-pow(M, 2.0));
double tmp;
if (m <= -55.0) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (m <= -2.6e-46) {
tmp = t_0;
} else if (m <= -3.2e-56) {
tmp = cos(M) / exp(l);
} else if (m <= 3.1e-173) {
tmp = t_0;
} else {
tmp = cos(M) * exp((pow(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) :: t_0
real(8) :: tmp
t_0 = cos(m_1) * exp(-(m_1 ** 2.0d0))
if (m <= (-55.0d0)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= (-2.6d-46)) then
tmp = t_0
else if (m <= (-3.2d-56)) then
tmp = cos(m_1) / exp(l)
else if (m <= 3.1d-173) then
tmp = t_0
else
tmp = cos(m_1) * exp(((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 t_0 = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
double tmp;
if (m <= -55.0) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= -2.6e-46) {
tmp = t_0;
} else if (m <= -3.2e-56) {
tmp = Math.cos(M) / Math.exp(l);
} else if (m <= 3.1e-173) {
tmp = t_0;
} else {
tmp = Math.cos(M) * Math.exp((Math.pow(n, 2.0) * -0.25));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(M) * math.exp(-math.pow(M, 2.0)) tmp = 0 if m <= -55.0: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif m <= -2.6e-46: tmp = t_0 elif m <= -3.2e-56: tmp = math.cos(M) / math.exp(l) elif m <= 3.1e-173: tmp = t_0 else: tmp = math.cos(M) * math.exp((math.pow(n, 2.0) * -0.25)) return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))) tmp = 0.0 if (m <= -55.0) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (m <= -2.6e-46) tmp = t_0; elseif (m <= -3.2e-56) tmp = Float64(cos(M) / exp(l)); elseif (m <= 3.1e-173) tmp = t_0; else tmp = Float64(cos(M) * exp(Float64((n ^ 2.0) * -0.25))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) * exp(-(M ^ 2.0)); tmp = 0.0; if (m <= -55.0) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); elseif (m <= -2.6e-46) tmp = t_0; elseif (m <= -3.2e-56) tmp = cos(M) / exp(l); elseif (m <= 3.1e-173) tmp = t_0; else tmp = cos(M) * exp(((n ^ 2.0) * -0.25)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -55.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -2.6e-46], t$95$0, If[LessEqual[m, -3.2e-56], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 3.1e-173], t$95$0, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[n, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{-{M}^{2}}\\
\mathbf{if}\;m \leq -55:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq -2.6 \cdot 10^{-46}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq -3.2 \cdot 10^{-56}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{elif}\;m \leq 3.1 \cdot 10^{-173}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{{n}^{2} \cdot -0.25}\\
\end{array}
\end{array}
if m < -55Initial program 72.9%
Taylor expanded in K around 0 98.3%
cos-neg98.3%
Simplified98.3%
Taylor expanded in m around inf 96.7%
*-commutative96.7%
Simplified96.7%
if -55 < m < -2.6000000000000002e-46 or -3.19999999999999986e-56 < m < 3.10000000000000005e-173Initial program 81.7%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
Taylor expanded in M around inf 57.7%
mul-1-neg57.7%
Simplified57.7%
if -2.6000000000000002e-46 < m < -3.19999999999999986e-56Initial program 100.0%
Taylor expanded in l around inf 35.2%
mul-1-neg35.2%
Simplified35.2%
Taylor expanded in K around 0 35.2%
exp-neg35.2%
associate-*r/35.2%
*-rgt-identity35.2%
cos-neg35.2%
Simplified35.2%
if 3.10000000000000005e-173 < m Initial program 76.8%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Taylor expanded in n around inf 56.8%
*-commutative56.8%
Simplified56.8%
Final simplification65.7%
(FPCore (K m n M l)
:precision binary64
(if (<= n 5e+31)
(*
(cos M)
(exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) (- (fabs (- n m)) l))))
(* (cos M) (exp (* (pow n 2.0) -0.25)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 5e+31) {
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (fabs((n - m)) - l)));
} else {
tmp = cos(M) * exp((pow(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 (n <= 5d+31) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + (abs((n - m)) - l)))
else
tmp = cos(m_1) * exp(((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 (n <= 5e+31) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (Math.abs((n - m)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((Math.pow(n, 2.0) * -0.25));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 5e+31: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (math.fabs((n - m)) - l))) else: tmp = math.cos(M) * math.exp((math.pow(n, 2.0) * -0.25)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 5e+31) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + Float64(abs(Float64(n - m)) - l)))); else tmp = Float64(cos(M) * exp(Float64((n ^ 2.0) * -0.25))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 5e+31) tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (abs((n - m)) - l))); else tmp = cos(M) * exp(((n ^ 2.0) * -0.25)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 5e+31], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[n, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 5 \cdot 10^{+31}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + \left(\left|n - m\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{{n}^{2} \cdot -0.25}\\
\end{array}
\end{array}
if n < 5.00000000000000027e31Initial program 80.4%
Taylor expanded in K around 0 95.7%
cos-neg95.7%
Simplified95.7%
Taylor expanded in n around 0 78.4%
+-commutative78.4%
unpow278.4%
distribute-rgt-out82.0%
*-commutative82.0%
*-commutative82.0%
Simplified82.0%
if 5.00000000000000027e31 < n Initial program 69.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 98.2%
*-commutative98.2%
Simplified98.2%
Final simplification85.5%
(FPCore (K m n M l)
:precision binary64
(if (<= m -3.15e+25)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= m 5e-173)
(* (cos M) (exp (+ (* M (- n M)) (- (fabs (- n m)) l))))
(* (cos M) (exp (* (pow n 2.0) -0.25))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -3.15e+25) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (m <= 5e-173) {
tmp = cos(M) * exp(((M * (n - M)) + (fabs((n - m)) - l)));
} else {
tmp = cos(M) * exp((pow(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 <= (-3.15d+25)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 5d-173) then
tmp = cos(m_1) * exp(((m_1 * (n - m_1)) + (abs((n - m)) - l)))
else
tmp = cos(m_1) * exp(((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 <= -3.15e+25) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 5e-173) {
tmp = Math.cos(M) * Math.exp(((M * (n - M)) + (Math.abs((n - m)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((Math.pow(n, 2.0) * -0.25));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -3.15e+25: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 5e-173: tmp = math.cos(M) * math.exp(((M * (n - M)) + (math.fabs((n - m)) - l))) else: tmp = math.cos(M) * math.exp((math.pow(n, 2.0) * -0.25)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -3.15e+25) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (m <= 5e-173) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(n - M)) + Float64(abs(Float64(n - m)) - l)))); else tmp = Float64(cos(M) * exp(Float64((n ^ 2.0) * -0.25))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -3.15e+25) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); elseif (m <= 5e-173) tmp = cos(M) * exp(((M * (n - M)) + (abs((n - m)) - l))); else tmp = cos(M) * exp(((n ^ 2.0) * -0.25)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -3.15e+25], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 5e-173], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[n, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.15 \cdot 10^{+25}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 5 \cdot 10^{-173}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(n - M\right) + \left(\left|n - m\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{{n}^{2} \cdot -0.25}\\
\end{array}
\end{array}
if m < -3.14999999999999987e25Initial program 72.7%
Taylor expanded in K around 0 98.2%
cos-neg98.2%
Simplified98.2%
Taylor expanded in m around inf 96.4%
*-commutative96.4%
Simplified96.4%
if -3.14999999999999987e25 < m < 5.0000000000000002e-173Initial program 82.6%
Taylor expanded in K around 0 96.1%
cos-neg96.1%
Simplified96.1%
Taylor expanded in n around 0 67.9%
+-commutative67.9%
unpow267.9%
distribute-rgt-out70.1%
*-commutative70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in m around 0 69.6%
mul-1-neg69.6%
*-commutative69.6%
distribute-rgt-neg-in69.6%
Simplified69.6%
if 5.0000000000000002e-173 < m Initial program 76.8%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Taylor expanded in n around inf 56.8%
*-commutative56.8%
Simplified56.8%
Final simplification69.8%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -26.0) (not (<= M 27.0))) (* (cos M) (exp (- (pow M 2.0)))) (* (cos M) (exp (* -0.25 (pow m 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -26.0) || !(M <= 27.0)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = cos(M) * exp((-0.25 * pow(m, 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 <= (-26.0d0)) .or. (.not. (m_1 <= 27.0d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 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 <= -26.0) || !(M <= 27.0)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -26.0) or not (M <= 27.0): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -26.0) || !(M <= 27.0)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -26.0) || ~((M <= 27.0))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -26.0], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -26 \lor \neg \left(M \leq 27\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\end{array}
\end{array}
if M < -26 or 27 < M Initial program 80.5%
Taylor expanded in K around 0 98.5%
cos-neg98.5%
Simplified98.5%
Taylor expanded in M around inf 95.6%
mul-1-neg95.6%
Simplified95.6%
if -26 < M < 27Initial program 75.4%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in m around inf 51.6%
*-commutative51.6%
Simplified51.6%
Final simplification74.4%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -26.0) (not (<= M 27.0))) (* (cos M) (exp (- (pow M 2.0)))) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -26.0) || !(M <= 27.0)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = cos(M) / 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 <= (-26.0d0)) .or. (.not. (m_1 <= 27.0d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = cos(m_1) / 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 <= -26.0) || !(M <= 27.0)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -26.0) or not (M <= 27.0): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -26.0) || !(M <= 27.0)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -26.0) || ~((M <= 27.0))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -26.0], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -26 \lor \neg \left(M \leq 27\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if M < -26 or 27 < M Initial program 80.5%
Taylor expanded in K around 0 98.5%
cos-neg98.5%
Simplified98.5%
Taylor expanded in M around inf 95.6%
mul-1-neg95.6%
Simplified95.6%
if -26 < M < 27Initial program 75.4%
Taylor expanded in l around inf 36.8%
mul-1-neg36.8%
Simplified36.8%
Taylor expanded in K around 0 42.7%
exp-neg42.7%
associate-*r/42.7%
*-rgt-identity42.7%
cos-neg42.7%
Simplified42.7%
Final simplification70.2%
(FPCore (K m n M l) :precision binary64 (if (<= l -680.0) (* (exp l) (cos (- (* (+ m n) (* 0.5 K)) M))) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -680.0) {
tmp = exp(l) * cos((((m + n) * (0.5 * K)) - M));
} else {
tmp = cos(M) / 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 (l <= (-680.0d0)) then
tmp = exp(l) * cos((((m + n) * (0.5d0 * k)) - m_1))
else
tmp = cos(m_1) / 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 (l <= -680.0) {
tmp = Math.exp(l) * Math.cos((((m + n) * (0.5 * K)) - M));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -680.0: tmp = math.exp(l) * math.cos((((m + n) * (0.5 * K)) - M)) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -680.0) tmp = Float64(exp(l) * cos(Float64(Float64(Float64(m + n) * Float64(0.5 * K)) - M))); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -680.0) tmp = exp(l) * cos((((m + n) * (0.5 * K)) - M)); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -680.0], N[(N[Exp[l], $MachinePrecision] * N[Cos[N[(N[(N[(m + n), $MachinePrecision] * N[(0.5 * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -680:\\
\;\;\;\;e^{\ell} \cdot \cos \left(\left(m + n\right) \cdot \left(0.5 \cdot K\right) - M\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if l < -680Initial program 85.7%
Taylor expanded in l around inf 26.7%
mul-1-neg26.7%
Simplified26.7%
pow126.7%
expm1-log1p-u19.2%
expm1-log1p-u26.7%
associate-/l*26.7%
fma-neg26.7%
div-inv26.7%
metadata-eval26.7%
add-sqr-sqrt26.7%
sqrt-unprod26.7%
sqr-neg26.7%
sqrt-unprod0.0%
add-sqr-sqrt60.4%
Applied egg-rr60.4%
unpow160.4%
*-commutative60.4%
fma-neg60.4%
associate-*r*60.4%
*-commutative60.4%
associate-*r*60.4%
fma-neg60.4%
+-commutative60.4%
remove-double-neg60.4%
sub-neg60.4%
neg-mul-160.4%
fma-neg60.4%
*-commutative60.4%
sub-neg60.4%
neg-mul-160.4%
remove-double-neg60.4%
+-commutative60.4%
Simplified60.4%
if -680 < l Initial program 75.1%
Taylor expanded in l around inf 32.1%
mul-1-neg32.1%
Simplified32.1%
Taylor expanded in K around 0 39.9%
exp-neg39.9%
associate-*r/39.9%
*-rgt-identity39.9%
cos-neg39.9%
Simplified39.9%
Final simplification45.5%
(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(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}
\\
\frac{\cos M}{e^{\ell}}
\end{array}
Initial program 78.0%
Taylor expanded in l around inf 30.6%
mul-1-neg30.6%
Simplified30.6%
Taylor expanded in K around 0 35.9%
exp-neg35.9%
associate-*r/35.9%
*-rgt-identity35.9%
cos-neg35.9%
Simplified35.9%
Final simplification35.9%
(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 78.0%
Taylor expanded in l around inf 30.6%
mul-1-neg30.6%
Simplified30.6%
Taylor expanded in l around 0 5.9%
associate-*r*5.9%
fma-neg5.9%
+-commutative5.9%
remove-double-neg5.9%
sub-neg5.9%
neg-mul-15.9%
fma-neg5.9%
*-commutative5.9%
sub-neg5.9%
neg-mul-15.9%
remove-double-neg5.9%
+-commutative5.9%
Simplified5.9%
Taylor expanded in K around 0 6.4%
cos-neg6.4%
Simplified6.4%
Final simplification6.4%
herbie shell --seed 2024085
(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)))))))