
(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 (* (+ m n) 0.5))
(t_1 (cbrt t_0))
(t_2 (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_2) INFINITY)
(* t_2 (cos (- (* t_1 (* K (pow t_1 2.0))) M)))
(exp (+ (- n m) (* (- t_0 M) (- M t_0)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m + n) * 0.5;
double t_1 = cbrt(t_0);
double t_2 = exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_2) <= ((double) INFINITY)) {
tmp = t_2 * cos(((t_1 * (K * pow(t_1, 2.0))) - M));
} else {
tmp = exp(((n - m) + ((t_0 - M) * (M - t_0))));
}
return tmp;
}
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (m + n) * 0.5;
double t_1 = Math.cbrt(t_0);
double t_2 = Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((Math.cos((((K * (m + n)) / 2.0) - M)) * t_2) <= Double.POSITIVE_INFINITY) {
tmp = t_2 * Math.cos(((t_1 * (K * Math.pow(t_1, 2.0))) - M));
} else {
tmp = Math.exp(((n - m) + ((t_0 - M) * (M - t_0))));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = Float64(Float64(m + n) * 0.5) t_1 = cbrt(t_0) t_2 = exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_2) <= Inf) tmp = Float64(t_2 * cos(Float64(Float64(t_1 * Float64(K * (t_1 ^ 2.0))) - M))); else tmp = exp(Float64(Float64(n - m) + Float64(Float64(t_0 - M) * Float64(M - t_0)))); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 1/3], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], Infinity], N[(t$95$2 * N[Cos[N[(N[(t$95$1 * N[(K * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(n - m), $MachinePrecision] + N[(N[(t$95$0 - M), $MachinePrecision] * N[(M - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(m + n\right) \cdot 0.5\\
t_1 := \sqrt[3]{t\_0}\\
t_2 := e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t\_2 \leq \infty:\\
\;\;\;\;t\_2 \cdot \cos \left(t\_1 \cdot \left(K \cdot {t\_1}^{2}\right) - M\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\left(n - m\right) + \left(t\_0 - M\right) \cdot \left(M - t\_0\right)}\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < +inf.0Initial program 94.0%
associate-/l*94.0%
add-cube-cbrt96.5%
associate-*r*96.5%
pow296.5%
div-inv96.5%
metadata-eval96.5%
div-inv96.5%
metadata-eval96.5%
Applied egg-rr96.5%
if +inf.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 0.0%
Taylor expanded in K around 0 100.0%
*-commutative100.0%
associate--r+100.0%
sub-neg100.0%
mul-1-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
fabs-sub100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around 0 100.0%
rem-square-sqrt50.0%
fabs-sqr50.0%
rem-square-sqrt100.0%
Simplified100.0%
unpow2100.0%
+-commutative100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in M around 0 100.0%
Final simplification97.1%
(FPCore (K m n M l) :precision binary64 (* (exp (- (- (fabs (- m n)) l) (pow (- (* (+ m n) 0.5) M) 2.0))) (cos M)))
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((m - n)) - l) - pow((((m + n) * 0.5) - M), 2.0))) * 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 = exp(((abs((m - n)) - l) - ((((m + n) * 0.5d0) - m_1) ** 2.0d0))) * cos(m_1)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) * 0.5) - M), 2.0))) * Math.cos(M);
}
def code(K, m, n, M, l): return math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) * 0.5) - M), 2.0))) * math.cos(M)
function code(K, m, n, M, l) return Float64(exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0))) * cos(M)) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((m - n)) - l) - ((((m + n) * 0.5) - M) ^ 2.0))) * cos(M); end
code[K_, m_, n_, M_, l_] := N[(N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\left|m - n\right| - \ell\right) - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}} \cdot \cos M
\end{array}
Initial program 77.9%
Taylor expanded in K around 0 95.3%
*-commutative95.3%
associate--r+95.3%
sub-neg95.3%
mul-1-neg95.3%
mul-1-neg95.3%
sub-neg95.3%
fabs-sub95.3%
cos-neg95.3%
Simplified95.3%
Final simplification95.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (+ m n) 0.5)) (t_1 (* (- t_0 M) (- M t_0))))
(if (<= l -1.65e+24)
(* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (+ (- (- m n) l) t_1)))
(if (<= l 1000.0)
(* (exp (+ (- n m) t_1)) (cos M))
(* (cos M) (exp (- l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m + n) * 0.5;
double t_1 = (t_0 - M) * (M - t_0);
double tmp;
if (l <= -1.65e+24) {
tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((((m - n) - l) + t_1));
} else if (l <= 1000.0) {
tmp = exp(((n - m) + t_1)) * cos(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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (m + n) * 0.5d0
t_1 = (t_0 - m_1) * (m_1 - t_0)
if (l <= (-1.65d+24)) then
tmp = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((((m - n) - l) + t_1))
else if (l <= 1000.0d0) then
tmp = exp(((n - m) + t_1)) * cos(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 t_0 = (m + n) * 0.5;
double t_1 = (t_0 - M) * (M - t_0);
double tmp;
if (l <= -1.65e+24) {
tmp = Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((((m - n) - l) + t_1));
} else if (l <= 1000.0) {
tmp = Math.exp(((n - m) + t_1)) * Math.cos(M);
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (m + n) * 0.5 t_1 = (t_0 - M) * (M - t_0) tmp = 0 if l <= -1.65e+24: tmp = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((((m - n) - l) + t_1)) elif l <= 1000.0: tmp = math.exp(((n - m) + t_1)) * math.cos(M) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(m + n) * 0.5) t_1 = Float64(Float64(t_0 - M) * Float64(M - t_0)) tmp = 0.0 if (l <= -1.65e+24) tmp = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(Float64(m - n) - l) + t_1))); elseif (l <= 1000.0) tmp = Float64(exp(Float64(Float64(n - m) + t_1)) * cos(M)); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (m + n) * 0.5; t_1 = (t_0 - M) * (M - t_0); tmp = 0.0; if (l <= -1.65e+24) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((((m - n) - l) + t_1)); elseif (l <= 1000.0) tmp = exp(((n - m) + t_1)) * cos(M); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - M), $MachinePrecision] * N[(M - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.65e+24], N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1000.0], N[(N[Exp[N[(N[(n - m), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(m + n\right) \cdot 0.5\\
t_1 := \left(t\_0 - M\right) \cdot \left(M - t\_0\right)\\
\mathbf{if}\;\ell \leq -1.65 \cdot 10^{+24}:\\
\;\;\;\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(\left(m - n\right) - \ell\right) + t\_1}\\
\mathbf{elif}\;\ell \leq 1000:\\
\;\;\;\;e^{\left(n - m\right) + t\_1} \cdot \cos M\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < -1.6499999999999999e24Initial program 74.5%
sub-neg74.5%
distribute-neg-out74.5%
div-inv74.5%
fma-neg74.5%
metadata-eval74.5%
add-sqr-sqrt33.3%
fabs-sqr33.3%
add-sqr-sqrt74.5%
Applied egg-rr74.5%
+-commutative74.5%
distribute-neg-in74.5%
sub-neg74.5%
sub-neg74.5%
distribute-neg-in74.5%
sub-neg74.5%
mul-1-neg74.5%
distribute-neg-in74.5%
mul-1-neg74.5%
mul-1-neg74.5%
remove-double-neg74.5%
distribute-neg-in74.5%
mul-1-neg74.5%
remove-double-neg74.5%
sub-neg74.5%
fma-neg74.5%
*-commutative74.5%
Simplified74.5%
unpow250.0%
+-commutative50.0%
+-commutative50.0%
Applied egg-rr74.5%
if -1.6499999999999999e24 < l < 1e3Initial program 75.9%
Taylor expanded in K around 0 97.2%
*-commutative97.2%
associate--r+97.2%
sub-neg97.2%
mul-1-neg97.2%
mul-1-neg97.2%
sub-neg97.2%
fabs-sub97.2%
cos-neg97.2%
Simplified97.2%
Taylor expanded in l around 0 97.2%
rem-square-sqrt50.0%
fabs-sqr50.0%
rem-square-sqrt97.2%
Simplified97.2%
unpow297.2%
+-commutative97.2%
+-commutative97.2%
Applied egg-rr97.2%
if 1e3 < l Initial program 85.2%
Taylor expanded in l around inf 85.2%
mul-1-neg85.2%
Simplified85.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
*-commutative100.0%
Simplified100.0%
Final simplification93.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- l))) (t_1 (* (+ m n) 0.5)))
(if (<= l -1.9e+236)
(* t_0 (cos (- (* 0.5 (* K n)) M)))
(if (<= l 200.0)
(* (exp (+ (- n m) (* (- t_1 M) (- M t_1)))) (cos M))
(* (cos M) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-l);
double t_1 = (m + n) * 0.5;
double tmp;
if (l <= -1.9e+236) {
tmp = t_0 * cos(((0.5 * (K * n)) - M));
} else if (l <= 200.0) {
tmp = exp(((n - m) + ((t_1 - M) * (M - t_1)))) * cos(M);
} else {
tmp = cos(M) * t_0;
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(-l)
t_1 = (m + n) * 0.5d0
if (l <= (-1.9d+236)) then
tmp = t_0 * cos(((0.5d0 * (k * n)) - m_1))
else if (l <= 200.0d0) then
tmp = exp(((n - m) + ((t_1 - m_1) * (m_1 - t_1)))) * cos(m_1)
else
tmp = cos(m_1) * t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp(-l);
double t_1 = (m + n) * 0.5;
double tmp;
if (l <= -1.9e+236) {
tmp = t_0 * Math.cos(((0.5 * (K * n)) - M));
} else if (l <= 200.0) {
tmp = Math.exp(((n - m) + ((t_1 - M) * (M - t_1)))) * Math.cos(M);
} else {
tmp = Math.cos(M) * t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-l) t_1 = (m + n) * 0.5 tmp = 0 if l <= -1.9e+236: tmp = t_0 * math.cos(((0.5 * (K * n)) - M)) elif l <= 200.0: tmp = math.exp(((n - m) + ((t_1 - M) * (M - t_1)))) * math.cos(M) else: tmp = math.cos(M) * t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-l)) t_1 = Float64(Float64(m + n) * 0.5) tmp = 0.0 if (l <= -1.9e+236) tmp = Float64(t_0 * cos(Float64(Float64(0.5 * Float64(K * n)) - M))); elseif (l <= 200.0) tmp = Float64(exp(Float64(Float64(n - m) + Float64(Float64(t_1 - M) * Float64(M - t_1)))) * cos(M)); else tmp = Float64(cos(M) * t_0); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-l); t_1 = (m + n) * 0.5; tmp = 0.0; if (l <= -1.9e+236) tmp = t_0 * cos(((0.5 * (K * n)) - M)); elseif (l <= 200.0) tmp = exp(((n - m) + ((t_1 - M) * (M - t_1)))) * cos(M); else tmp = cos(M) * t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, Block[{t$95$1 = N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[l, -1.9e+236], N[(t$95$0 * N[Cos[N[(N[(0.5 * N[(K * n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 200.0], N[(N[Exp[N[(N[(n - m), $MachinePrecision] + N[(N[(t$95$1 - M), $MachinePrecision] * N[(M - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
t_1 := \left(m + n\right) \cdot 0.5\\
\mathbf{if}\;\ell \leq -1.9 \cdot 10^{+236}:\\
\;\;\;\;t\_0 \cdot \cos \left(0.5 \cdot \left(K \cdot n\right) - M\right)\\
\mathbf{elif}\;\ell \leq 200:\\
\;\;\;\;e^{\left(n - m\right) + \left(t\_1 - M\right) \cdot \left(M - t\_1\right)} \cdot \cos M\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot t\_0\\
\end{array}
\end{array}
if l < -1.89999999999999993e236Initial program 60.0%
Taylor expanded in l around inf 40.3%
mul-1-neg40.3%
Simplified40.3%
Taylor expanded in m around 0 50.3%
*-commutative50.3%
*-commutative50.3%
Simplified50.3%
if -1.89999999999999993e236 < l < 200Initial program 76.4%
Taylor expanded in K around 0 94.5%
*-commutative94.5%
associate--r+94.5%
sub-neg94.5%
mul-1-neg94.5%
mul-1-neg94.5%
sub-neg94.5%
fabs-sub94.5%
cos-neg94.5%
Simplified94.5%
Taylor expanded in l around 0 88.3%
rem-square-sqrt46.6%
fabs-sqr46.6%
rem-square-sqrt88.3%
Simplified88.3%
unpow288.3%
+-commutative88.3%
+-commutative88.3%
Applied egg-rr88.3%
if 200 < l Initial program 85.2%
Taylor expanded in l around inf 85.2%
mul-1-neg85.2%
Simplified85.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
*-commutative100.0%
Simplified100.0%
Final simplification89.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- l))) (t_1 (* (+ m n) 0.5)))
(if (<= l -2.3e+236)
(* t_0 (cos (- (* 0.5 (* K n)) M)))
(if (<= l 740.0)
(exp (+ (- n m) (* (- t_1 M) (- M t_1))))
(* (cos M) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-l);
double t_1 = (m + n) * 0.5;
double tmp;
if (l <= -2.3e+236) {
tmp = t_0 * cos(((0.5 * (K * n)) - M));
} else if (l <= 740.0) {
tmp = exp(((n - m) + ((t_1 - M) * (M - t_1))));
} else {
tmp = cos(M) * t_0;
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = exp(-l)
t_1 = (m + n) * 0.5d0
if (l <= (-2.3d+236)) then
tmp = t_0 * cos(((0.5d0 * (k * n)) - m_1))
else if (l <= 740.0d0) then
tmp = exp(((n - m) + ((t_1 - m_1) * (m_1 - t_1))))
else
tmp = cos(m_1) * t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp(-l);
double t_1 = (m + n) * 0.5;
double tmp;
if (l <= -2.3e+236) {
tmp = t_0 * Math.cos(((0.5 * (K * n)) - M));
} else if (l <= 740.0) {
tmp = Math.exp(((n - m) + ((t_1 - M) * (M - t_1))));
} else {
tmp = Math.cos(M) * t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-l) t_1 = (m + n) * 0.5 tmp = 0 if l <= -2.3e+236: tmp = t_0 * math.cos(((0.5 * (K * n)) - M)) elif l <= 740.0: tmp = math.exp(((n - m) + ((t_1 - M) * (M - t_1)))) else: tmp = math.cos(M) * t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-l)) t_1 = Float64(Float64(m + n) * 0.5) tmp = 0.0 if (l <= -2.3e+236) tmp = Float64(t_0 * cos(Float64(Float64(0.5 * Float64(K * n)) - M))); elseif (l <= 740.0) tmp = exp(Float64(Float64(n - m) + Float64(Float64(t_1 - M) * Float64(M - t_1)))); else tmp = Float64(cos(M) * t_0); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-l); t_1 = (m + n) * 0.5; tmp = 0.0; if (l <= -2.3e+236) tmp = t_0 * cos(((0.5 * (K * n)) - M)); elseif (l <= 740.0) tmp = exp(((n - m) + ((t_1 - M) * (M - t_1)))); else tmp = cos(M) * t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, Block[{t$95$1 = N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[l, -2.3e+236], N[(t$95$0 * N[Cos[N[(N[(0.5 * N[(K * n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 740.0], N[Exp[N[(N[(n - m), $MachinePrecision] + N[(N[(t$95$1 - M), $MachinePrecision] * N[(M - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
t_1 := \left(m + n\right) \cdot 0.5\\
\mathbf{if}\;\ell \leq -2.3 \cdot 10^{+236}:\\
\;\;\;\;t\_0 \cdot \cos \left(0.5 \cdot \left(K \cdot n\right) - M\right)\\
\mathbf{elif}\;\ell \leq 740:\\
\;\;\;\;e^{\left(n - m\right) + \left(t\_1 - M\right) \cdot \left(M - t\_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot t\_0\\
\end{array}
\end{array}
if l < -2.3e236Initial program 60.0%
Taylor expanded in l around inf 40.3%
mul-1-neg40.3%
Simplified40.3%
Taylor expanded in m around 0 50.3%
*-commutative50.3%
*-commutative50.3%
Simplified50.3%
if -2.3e236 < l < 740Initial program 76.4%
Taylor expanded in K around 0 94.5%
*-commutative94.5%
associate--r+94.5%
sub-neg94.5%
mul-1-neg94.5%
mul-1-neg94.5%
sub-neg94.5%
fabs-sub94.5%
cos-neg94.5%
Simplified94.5%
Taylor expanded in l around 0 88.3%
rem-square-sqrt46.6%
fabs-sqr46.6%
rem-square-sqrt88.3%
Simplified88.3%
unpow288.3%
+-commutative88.3%
+-commutative88.3%
Applied egg-rr88.3%
Taylor expanded in M around 0 88.0%
if 740 < l Initial program 85.2%
Taylor expanded in l around inf 85.2%
mul-1-neg85.2%
Simplified85.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
*-commutative100.0%
Simplified100.0%
Final simplification89.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (+ m n) 0.5)))
(if (<= l 200.0)
(exp (+ (- n m) (* (- t_0 M) (- M t_0))))
(* (cos M) (exp (- l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m + n) * 0.5;
double tmp;
if (l <= 200.0) {
tmp = exp(((n - m) + ((t_0 - M) * (M - t_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) :: t_0
real(8) :: tmp
t_0 = (m + n) * 0.5d0
if (l <= 200.0d0) then
tmp = exp(((n - m) + ((t_0 - m_1) * (m_1 - t_0))))
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 t_0 = (m + n) * 0.5;
double tmp;
if (l <= 200.0) {
tmp = Math.exp(((n - m) + ((t_0 - M) * (M - t_0))));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (m + n) * 0.5 tmp = 0 if l <= 200.0: tmp = math.exp(((n - m) + ((t_0 - M) * (M - t_0)))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(m + n) * 0.5) tmp = 0.0 if (l <= 200.0) tmp = exp(Float64(Float64(n - m) + Float64(Float64(t_0 - M) * Float64(M - t_0)))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (m + n) * 0.5; tmp = 0.0; if (l <= 200.0) tmp = exp(((n - m) + ((t_0 - M) * (M - t_0)))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[l, 200.0], N[Exp[N[(N[(n - m), $MachinePrecision] + N[(N[(t$95$0 - M), $MachinePrecision] * N[(M - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(m + n\right) \cdot 0.5\\
\mathbf{if}\;\ell \leq 200:\\
\;\;\;\;e^{\left(n - m\right) + \left(t\_0 - M\right) \cdot \left(M - t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 200Initial program 75.6%
Taylor expanded in K around 0 93.8%
*-commutative93.8%
associate--r+93.8%
sub-neg93.8%
mul-1-neg93.8%
mul-1-neg93.8%
sub-neg93.8%
fabs-sub93.8%
cos-neg93.8%
Simplified93.8%
Taylor expanded in l around 0 84.8%
rem-square-sqrt44.8%
fabs-sqr44.8%
rem-square-sqrt84.8%
Simplified84.8%
unpow284.8%
+-commutative84.8%
+-commutative84.8%
Applied egg-rr84.8%
Taylor expanded in M around 0 84.6%
if 200 < l Initial program 85.2%
Taylor expanded in l around inf 85.2%
mul-1-neg85.2%
Simplified85.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
*-commutative100.0%
Simplified100.0%
Final simplification88.2%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (* (+ m n) 0.5))) (exp (+ (- n m) (* (- t_0 M) (- M t_0))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m + n) * 0.5;
return exp(((n - m) + ((t_0 - M) * (M - t_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
real(8) :: t_0
t_0 = (m + n) * 0.5d0
code = exp(((n - m) + ((t_0 - m_1) * (m_1 - t_0))))
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (m + n) * 0.5;
return Math.exp(((n - m) + ((t_0 - M) * (M - t_0))));
}
def code(K, m, n, M, l): t_0 = (m + n) * 0.5 return math.exp(((n - m) + ((t_0 - M) * (M - t_0))))
function code(K, m, n, M, l) t_0 = Float64(Float64(m + n) * 0.5) return exp(Float64(Float64(n - m) + Float64(Float64(t_0 - M) * Float64(M - t_0)))) end
function tmp = code(K, m, n, M, l) t_0 = (m + n) * 0.5; tmp = exp(((n - m) + ((t_0 - M) * (M - t_0)))); end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision]}, N[Exp[N[(N[(n - m), $MachinePrecision] + N[(N[(t$95$0 - M), $MachinePrecision] * N[(M - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(m + n\right) \cdot 0.5\\
e^{\left(n - m\right) + \left(t\_0 - M\right) \cdot \left(M - t\_0\right)}
\end{array}
\end{array}
Initial program 77.9%
Taylor expanded in K around 0 95.3%
*-commutative95.3%
associate--r+95.3%
sub-neg95.3%
mul-1-neg95.3%
mul-1-neg95.3%
sub-neg95.3%
fabs-sub95.3%
cos-neg95.3%
Simplified95.3%
Taylor expanded in l around 0 86.2%
rem-square-sqrt44.3%
fabs-sqr44.3%
rem-square-sqrt86.2%
Simplified86.2%
unpow286.2%
+-commutative86.2%
+-commutative86.2%
Applied egg-rr86.2%
Taylor expanded in M around 0 86.0%
Final simplification86.0%
(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 77.9%
Taylor expanded in l around inf 33.0%
mul-1-neg33.0%
Simplified33.0%
Taylor expanded in l around 0 7.1%
*-commutative7.1%
*-commutative7.1%
+-commutative7.1%
associate-*l*7.1%
+-commutative7.1%
*-commutative7.1%
Simplified7.1%
Taylor expanded in K around 0 7.6%
cos-neg7.6%
Simplified7.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 77.9%
Taylor expanded in l around inf 33.0%
mul-1-neg33.0%
Simplified33.0%
Taylor expanded in l around 0 7.1%
*-commutative7.1%
*-commutative7.1%
+-commutative7.1%
associate-*l*7.1%
+-commutative7.1%
*-commutative7.1%
Simplified7.1%
Taylor expanded in K around 0 7.6%
cos-neg7.6%
Simplified7.6%
Taylor expanded in M around 0 7.6%
herbie shell --seed 2024132
(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)))))))