
(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 11 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 (pow (cbrt (* (cos M) (exp (- (fabs (- n m)) (+ l (pow (- (* (+ m n) 0.5) M) 2.0)))))) 3.0))
double code(double K, double m, double n, double M, double l) {
return pow(cbrt((cos(M) * exp((fabs((n - m)) - (l + pow((((m + n) * 0.5) - M), 2.0)))))), 3.0);
}
public static double code(double K, double m, double n, double M, double l) {
return Math.pow(Math.cbrt((Math.cos(M) * Math.exp((Math.abs((n - m)) - (l + Math.pow((((m + n) * 0.5) - M), 2.0)))))), 3.0);
}
function code(K, m, n, M, l) return cbrt(Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64(l + (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)))))) ^ 3.0 end
code[K_, m_, n_, M_, l_] := N[Power[N[Power[N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(\sqrt[3]{\cos M \cdot e^{\left|n - m\right| - \left(\ell + {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}\right)}}\right)}^{3}
\end{array}
Initial program 73.1%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
add-cube-cbrt97.5%
pow397.5%
Applied egg-rr97.5%
Final simplification97.5%
(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 73.1%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -1.5e+20) (not (<= M 1.06e+77))) (exp (- (pow M 2.0))) (exp (- (- (fabs (- n m)) 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.5e+20) || !(M <= 1.06e+77)) {
tmp = exp(-pow(M, 2.0));
} else {
tmp = exp(((fabs((n - m)) - 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.5d+20)) .or. (.not. (m_1 <= 1.06d+77))) then
tmp = exp(-(m_1 ** 2.0d0))
else
tmp = exp(((abs((n - m)) - 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.5e+20) || !(M <= 1.06e+77)) {
tmp = Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp(((Math.abs((n - m)) - l) - (0.25 * Math.pow((m + n), 2.0))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -1.5e+20) or not (M <= 1.06e+77): tmp = math.exp(-math.pow(M, 2.0)) else: tmp = math.exp(((math.fabs((n - m)) - l) - (0.25 * math.pow((m + n), 2.0)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -1.5e+20) || !(M <= 1.06e+77)) tmp = exp(Float64(-(M ^ 2.0))); else tmp = exp(Float64(Float64(abs(Float64(n - m)) - 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.5e+20) || ~((M <= 1.06e+77))) tmp = exp(-(M ^ 2.0)); else tmp = exp(((abs((n - m)) - l) - (0.25 * ((m + n) ^ 2.0)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -1.5e+20], N[Not[LessEqual[M, 1.06e+77]], $MachinePrecision]], N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision], N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $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.5 \cdot 10^{+20} \lor \neg \left(M \leq 1.06 \cdot 10^{+77}\right):\\
\;\;\;\;e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(\left|n - m\right| - \ell\right) - 0.25 \cdot {\left(m + n\right)}^{2}}\\
\end{array}
\end{array}
if M < -1.5e20 or 1.06000000000000003e77 < M Initial program 80.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
if -1.5e20 < M < 1.06000000000000003e77Initial program 67.9%
Taylor expanded in K around 0 95.7%
cos-neg95.7%
Simplified95.7%
Taylor expanded in M around 0 95.0%
associate--r+95.0%
Simplified95.0%
Final simplification97.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (* n 0.5) M)))
(if (<= n -2.15e-162)
(* (cos M) (exp (* -0.25 (* m m))))
(if (<= n 3e-218)
(*
(cos (- (/ (* (+ m n) K) 2.0) M))
(exp (+ (- m n) (- (* t_0 (+ m t_0)) l))))
(if (<= n 54.0)
(exp (- (pow M 2.0)))
(* (cos M) (exp (* -0.25 (pow n 2.0)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (n * 0.5) - M;
double tmp;
if (n <= -2.15e-162) {
tmp = cos(M) * exp((-0.25 * (m * m)));
} else if (n <= 3e-218) {
tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((m - n) + ((t_0 * (m + t_0)) - l)));
} else if (n <= 54.0) {
tmp = exp(-pow(M, 2.0));
} else {
tmp = cos(M) * 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) :: t_0
real(8) :: tmp
t_0 = (n * 0.5d0) - m_1
if (n <= (-2.15d-162)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m * m)))
else if (n <= 3d-218) then
tmp = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp(((m - n) + ((t_0 * (m + t_0)) - l)))
else if (n <= 54.0d0) then
tmp = exp(-(m_1 ** 2.0d0))
else
tmp = cos(m_1) * 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 t_0 = (n * 0.5) - M;
double tmp;
if (n <= -2.15e-162) {
tmp = Math.cos(M) * Math.exp((-0.25 * (m * m)));
} else if (n <= 3e-218) {
tmp = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp(((m - n) + ((t_0 * (m + t_0)) - l)));
} else if (n <= 54.0) {
tmp = Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (n * 0.5) - M tmp = 0 if n <= -2.15e-162: tmp = math.cos(M) * math.exp((-0.25 * (m * m))) elif n <= 3e-218: tmp = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp(((m - n) + ((t_0 * (m + t_0)) - l))) elif n <= 54.0: tmp = math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(n * 0.5) - M) tmp = 0.0 if (n <= -2.15e-162) tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(m * m)))); elseif (n <= 3e-218) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(Float64(m - n) + Float64(Float64(t_0 * Float64(m + t_0)) - l)))); elseif (n <= 54.0) tmp = exp(Float64(-(M ^ 2.0))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (n * 0.5) - M; tmp = 0.0; if (n <= -2.15e-162) tmp = cos(M) * exp((-0.25 * (m * m))); elseif (n <= 3e-218) tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((m - n) + ((t_0 * (m + t_0)) - l))); elseif (n <= 54.0) tmp = exp(-(M ^ 2.0)); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision]}, If[LessEqual[n, -2.15e-162], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3e-218], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(t$95$0 * N[(m + t$95$0), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot 0.5 - M\\
\mathbf{if}\;n \leq -2.15 \cdot 10^{-162}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 3 \cdot 10^{-218}:\\
\;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{\left(m - n\right) + \left(t\_0 \cdot \left(m + t\_0\right) - \ell\right)}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < -2.14999999999999998e-162Initial program 67.4%
Taylor expanded in K around 0 99.1%
cos-neg99.1%
Simplified99.1%
Taylor expanded in m around inf 58.2%
unpow258.2%
Applied egg-rr58.2%
if -2.14999999999999998e-162 < n < 2.9999999999999998e-218Initial program 89.5%
sub-neg89.5%
add-sqr-sqrt6.5%
sqrt-unprod29.6%
sqr-neg29.6%
sqrt-unprod29.6%
add-sqr-sqrt29.6%
div-inv29.6%
fmm-def29.6%
metadata-eval29.6%
add-sqr-sqrt7.2%
fabs-sqr7.2%
add-sqr-sqrt29.6%
Applied egg-rr29.6%
unsub-neg29.6%
associate-+l-29.6%
+-commutative29.6%
fmm-undef29.6%
*-commutative29.6%
Simplified29.6%
Taylor expanded in m around 0 33.9%
+-commutative33.9%
unpow233.9%
distribute-rgt-out33.9%
*-commutative33.9%
*-commutative33.9%
Simplified33.9%
if 2.9999999999999998e-218 < n < 54Initial program 80.1%
Taylor expanded in K around 0 93.5%
cos-neg93.5%
Simplified93.5%
Taylor expanded in M around inf 67.1%
mul-1-neg67.1%
Simplified67.1%
Taylor expanded in M around 0 67.1%
if 54 < n Initial program 63.5%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in n around inf 96.9%
Final simplification65.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* -0.25 (pow m 2.0))))
(t_1 (- (* m 0.5) M))
(t_2 (exp (- (pow M 2.0)))))
(if (<= M -26.0)
(* (cos M) t_2)
(if (<= M 3.45e-189)
t_0
(if (<= M 4e-105)
(*
(cos (- (/ (* (+ m n) K) 2.0) M))
(exp (+ (- m n) (- (* t_1 (+ n t_1)) l))))
(if (<= M 27.0) t_0 t_2))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-0.25 * pow(m, 2.0)));
double t_1 = (m * 0.5) - M;
double t_2 = exp(-pow(M, 2.0));
double tmp;
if (M <= -26.0) {
tmp = cos(M) * t_2;
} else if (M <= 3.45e-189) {
tmp = t_0;
} else if (M <= 4e-105) {
tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((m - n) + ((t_1 * (n + t_1)) - l)));
} else if (M <= 27.0) {
tmp = t_0;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = exp(((-0.25d0) * (m ** 2.0d0)))
t_1 = (m * 0.5d0) - m_1
t_2 = exp(-(m_1 ** 2.0d0))
if (m_1 <= (-26.0d0)) then
tmp = cos(m_1) * t_2
else if (m_1 <= 3.45d-189) then
tmp = t_0
else if (m_1 <= 4d-105) then
tmp = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp(((m - n) + ((t_1 * (n + t_1)) - l)))
else if (m_1 <= 27.0d0) then
tmp = t_0
else
tmp = t_2
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((-0.25 * Math.pow(m, 2.0)));
double t_1 = (m * 0.5) - M;
double t_2 = Math.exp(-Math.pow(M, 2.0));
double tmp;
if (M <= -26.0) {
tmp = Math.cos(M) * t_2;
} else if (M <= 3.45e-189) {
tmp = t_0;
} else if (M <= 4e-105) {
tmp = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp(((m - n) + ((t_1 * (n + t_1)) - l)));
} else if (M <= 27.0) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-0.25 * math.pow(m, 2.0))) t_1 = (m * 0.5) - M t_2 = math.exp(-math.pow(M, 2.0)) tmp = 0 if M <= -26.0: tmp = math.cos(M) * t_2 elif M <= 3.45e-189: tmp = t_0 elif M <= 4e-105: tmp = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp(((m - n) + ((t_1 * (n + t_1)) - l))) elif M <= 27.0: tmp = t_0 else: tmp = t_2 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-0.25 * (m ^ 2.0))) t_1 = Float64(Float64(m * 0.5) - M) t_2 = exp(Float64(-(M ^ 2.0))) tmp = 0.0 if (M <= -26.0) tmp = Float64(cos(M) * t_2); elseif (M <= 3.45e-189) tmp = t_0; elseif (M <= 4e-105) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(Float64(m - n) + Float64(Float64(t_1 * Float64(n + t_1)) - l)))); elseif (M <= 27.0) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-0.25 * (m ^ 2.0))); t_1 = (m * 0.5) - M; t_2 = exp(-(M ^ 2.0)); tmp = 0.0; if (M <= -26.0) tmp = cos(M) * t_2; elseif (M <= 3.45e-189) tmp = t_0; elseif (M <= 4e-105) tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((m - n) + ((t_1 * (n + t_1)) - l))); elseif (M <= 27.0) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]}, If[LessEqual[M, -26.0], N[(N[Cos[M], $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[M, 3.45e-189], t$95$0, If[LessEqual[M, 4e-105], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(t$95$1 * N[(n + t$95$1), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 27.0], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot {m}^{2}}\\
t_1 := m \cdot 0.5 - M\\
t_2 := e^{-{M}^{2}}\\
\mathbf{if}\;M \leq -26:\\
\;\;\;\;\cos M \cdot t\_2\\
\mathbf{elif}\;M \leq 3.45 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 4 \cdot 10^{-105}:\\
\;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{\left(m - n\right) + \left(t\_1 \cdot \left(n + t\_1\right) - \ell\right)}\\
\mathbf{elif}\;M \leq 27:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if M < -26Initial program 81.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 98.7%
mul-1-neg98.7%
Simplified98.7%
if -26 < M < 3.4500000000000001e-189 or 3.99999999999999986e-105 < M < 27Initial program 62.2%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in m around inf 67.7%
Taylor expanded in M around 0 67.7%
if 3.4500000000000001e-189 < M < 3.99999999999999986e-105Initial program 86.2%
sub-neg86.2%
add-sqr-sqrt0.0%
sqrt-unprod48.9%
sqr-neg48.9%
sqrt-unprod48.9%
add-sqr-sqrt48.9%
div-inv48.9%
fmm-def48.9%
metadata-eval48.9%
add-sqr-sqrt28.0%
fabs-sqr28.0%
add-sqr-sqrt48.9%
Applied egg-rr48.9%
unsub-neg48.9%
associate-+l-48.9%
+-commutative48.9%
fmm-undef48.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in n around 0 52.2%
+-commutative52.2%
unpow252.2%
distribute-rgt-out55.7%
*-commutative55.7%
*-commutative55.7%
Simplified55.7%
if 27 < M Initial program 75.4%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in M around inf 95.2%
mul-1-neg95.2%
Simplified95.2%
Taylor expanded in M around 0 95.2%
Final simplification80.9%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* -0.25 (pow m 2.0))))
(t_1 (- (* m 0.5) M))
(t_2 (exp (- (pow M 2.0)))))
(if (<= M -26.0)
t_2
(if (<= M 8.2e-188)
t_0
(if (<= M 7.5e-108)
(*
(cos (- (/ (* (+ m n) K) 2.0) M))
(exp (+ (- m n) (- (* t_1 (+ n t_1)) l))))
(if (<= M 27.0) t_0 t_2))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-0.25 * pow(m, 2.0)));
double t_1 = (m * 0.5) - M;
double t_2 = exp(-pow(M, 2.0));
double tmp;
if (M <= -26.0) {
tmp = t_2;
} else if (M <= 8.2e-188) {
tmp = t_0;
} else if (M <= 7.5e-108) {
tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((m - n) + ((t_1 * (n + t_1)) - l)));
} else if (M <= 27.0) {
tmp = t_0;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = exp(((-0.25d0) * (m ** 2.0d0)))
t_1 = (m * 0.5d0) - m_1
t_2 = exp(-(m_1 ** 2.0d0))
if (m_1 <= (-26.0d0)) then
tmp = t_2
else if (m_1 <= 8.2d-188) then
tmp = t_0
else if (m_1 <= 7.5d-108) then
tmp = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp(((m - n) + ((t_1 * (n + t_1)) - l)))
else if (m_1 <= 27.0d0) then
tmp = t_0
else
tmp = t_2
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((-0.25 * Math.pow(m, 2.0)));
double t_1 = (m * 0.5) - M;
double t_2 = Math.exp(-Math.pow(M, 2.0));
double tmp;
if (M <= -26.0) {
tmp = t_2;
} else if (M <= 8.2e-188) {
tmp = t_0;
} else if (M <= 7.5e-108) {
tmp = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp(((m - n) + ((t_1 * (n + t_1)) - l)));
} else if (M <= 27.0) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-0.25 * math.pow(m, 2.0))) t_1 = (m * 0.5) - M t_2 = math.exp(-math.pow(M, 2.0)) tmp = 0 if M <= -26.0: tmp = t_2 elif M <= 8.2e-188: tmp = t_0 elif M <= 7.5e-108: tmp = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp(((m - n) + ((t_1 * (n + t_1)) - l))) elif M <= 27.0: tmp = t_0 else: tmp = t_2 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-0.25 * (m ^ 2.0))) t_1 = Float64(Float64(m * 0.5) - M) t_2 = exp(Float64(-(M ^ 2.0))) tmp = 0.0 if (M <= -26.0) tmp = t_2; elseif (M <= 8.2e-188) tmp = t_0; elseif (M <= 7.5e-108) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(Float64(m - n) + Float64(Float64(t_1 * Float64(n + t_1)) - l)))); elseif (M <= 27.0) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-0.25 * (m ^ 2.0))); t_1 = (m * 0.5) - M; t_2 = exp(-(M ^ 2.0)); tmp = 0.0; if (M <= -26.0) tmp = t_2; elseif (M <= 8.2e-188) tmp = t_0; elseif (M <= 7.5e-108) tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((m - n) + ((t_1 * (n + t_1)) - l))); elseif (M <= 27.0) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]}, If[LessEqual[M, -26.0], t$95$2, If[LessEqual[M, 8.2e-188], t$95$0, If[LessEqual[M, 7.5e-108], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(t$95$1 * N[(n + t$95$1), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 27.0], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot {m}^{2}}\\
t_1 := m \cdot 0.5 - M\\
t_2 := e^{-{M}^{2}}\\
\mathbf{if}\;M \leq -26:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;M \leq 8.2 \cdot 10^{-188}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 7.5 \cdot 10^{-108}:\\
\;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{\left(m - n\right) + \left(t\_1 \cdot \left(n + t\_1\right) - \ell\right)}\\
\mathbf{elif}\;M \leq 27:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if M < -26 or 27 < M Initial program 78.7%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in M around inf 97.0%
mul-1-neg97.0%
Simplified97.0%
Taylor expanded in M around 0 97.0%
if -26 < M < 8.19999999999999965e-188 or 7.4999999999999993e-108 < M < 27Initial program 62.2%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in m around inf 67.7%
Taylor expanded in M around 0 67.7%
if 8.19999999999999965e-188 < M < 7.4999999999999993e-108Initial program 86.2%
sub-neg86.2%
add-sqr-sqrt0.0%
sqrt-unprod48.9%
sqr-neg48.9%
sqrt-unprod48.9%
add-sqr-sqrt48.9%
div-inv48.9%
fmm-def48.9%
metadata-eval48.9%
add-sqr-sqrt28.0%
fabs-sqr28.0%
add-sqr-sqrt48.9%
Applied egg-rr48.9%
unsub-neg48.9%
associate-+l-48.9%
+-commutative48.9%
fmm-undef48.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in n around 0 52.2%
+-commutative52.2%
unpow252.2%
distribute-rgt-out55.7%
*-commutative55.7%
*-commutative55.7%
Simplified55.7%
Final simplification80.9%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -26.0) (not (<= M 26.5))) (exp (- (pow M 2.0))) (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 <= 26.5)) {
tmp = exp(-pow(M, 2.0));
} else {
tmp = 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 <= 26.5d0))) then
tmp = exp(-(m_1 ** 2.0d0))
else
tmp = 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 <= 26.5)) {
tmp = Math.exp(-Math.pow(M, 2.0));
} else {
tmp = 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 <= 26.5): tmp = math.exp(-math.pow(M, 2.0)) else: tmp = 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 <= 26.5)) tmp = exp(Float64(-(M ^ 2.0))); else tmp = 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 <= 26.5))) tmp = exp(-(M ^ 2.0)); else tmp = 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, 26.5]], $MachinePrecision]], N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -26 \lor \neg \left(M \leq 26.5\right):\\
\;\;\;\;e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\end{array}
\end{array}
if M < -26 or 26.5 < M Initial program 78.7%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in M around inf 97.0%
mul-1-neg97.0%
Simplified97.0%
Taylor expanded in M around 0 97.0%
if -26 < M < 26.5Initial program 67.6%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in m around inf 62.1%
Taylor expanded in M around 0 62.1%
Final simplification79.4%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -11.0) (not (<= m 0.000105))) (exp (* -0.25 (pow m 2.0))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -11.0) || !(m <= 0.000105)) {
tmp = exp((-0.25 * 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 <= (-11.0d0)) .or. (.not. (m <= 0.000105d0))) then
tmp = exp(((-0.25d0) * (m ** 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 <= -11.0) || !(m <= 0.000105)) {
tmp = Math.exp((-0.25 * 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 <= -11.0) or not (m <= 0.000105): tmp = math.exp((-0.25 * 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 <= -11.0) || !(m <= 0.000105)) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -11.0) || ~((m <= 0.000105))) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -11.0], N[Not[LessEqual[m, 0.000105]], $MachinePrecision]], N[Exp[N[(-0.25 * 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 -11 \lor \neg \left(m \leq 0.000105\right):\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -11 or 1.05e-4 < m Initial program 63.0%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in m around inf 96.5%
Taylor expanded in M around 0 96.5%
if -11 < m < 1.05e-4Initial program 84.9%
Taylor expanded in l around inf 37.9%
mul-1-neg37.9%
Simplified37.9%
Taylor expanded in K around 0 41.0%
cos-neg41.0%
Simplified41.0%
Final simplification70.9%
(FPCore (K m n M l) :precision binary64 (exp (* -0.25 (pow m 2.0))))
double code(double K, double m, double n, double M, double l) {
return exp((-0.25 * pow(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(((-0.25d0) * (m ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((-0.25 * Math.pow(m, 2.0)));
}
def code(K, m, n, M, l): return math.exp((-0.25 * math.pow(m, 2.0)))
function code(K, m, n, M, l) return exp(Float64(-0.25 * (m ^ 2.0))) end
function tmp = code(K, m, n, M, l) tmp = exp((-0.25 * (m ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{-0.25 \cdot {m}^{2}}
\end{array}
Initial program 73.1%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in m around inf 55.9%
Taylor expanded in M around 0 55.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 73.1%
Taylor expanded in l around inf 24.9%
mul-1-neg24.9%
Simplified24.9%
Taylor expanded in l around 0 4.7%
*-commutative4.7%
*-commutative4.7%
*-commutative4.7%
associate-*r*4.7%
fmm-undef4.7%
fmm-undef4.7%
associate-*r*4.7%
*-commutative4.7%
*-commutative4.7%
*-commutative4.7%
associate-*r*4.7%
Simplified4.7%
Taylor expanded in K around 0 5.6%
cos-neg5.6%
Simplified5.6%
(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 73.1%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in M around inf 52.2%
mul-1-neg52.2%
Simplified52.2%
Taylor expanded in M around 0 5.6%
herbie shell --seed 2024180
(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)))))))