
(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 7 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 (pow (- (/ (+ m n) 2.0) M) 2.0))
(t_1 (exp (- (- (fabs (- m n)) l) t_0))))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_1) 0.5)
(*
(log (pow (cbrt (exp (cos (fma K (* (+ m n) 0.5) M)))) 3.0))
(exp (- (- l) t_0)))
(* t_1 (cos M)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = pow((((m + n) / 2.0) - M), 2.0);
double t_1 = exp(((fabs((m - n)) - l) - t_0));
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_1) <= 0.5) {
tmp = log(pow(cbrt(exp(cos(fma(K, ((m + n) * 0.5), M)))), 3.0)) * exp((-l - t_0));
} else {
tmp = t_1 * cos(M);
}
return tmp;
}
function code(K, m, n, M, l) t_0 = Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0 t_1 = exp(Float64(Float64(abs(Float64(m - n)) - l) - t_0)) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_1) <= 0.5) tmp = Float64(log((cbrt(exp(cos(fma(K, Float64(Float64(m + n) * 0.5), M)))) ^ 3.0)) * exp(Float64(Float64(-l) - t_0))); else tmp = Float64(t_1 * cos(M)); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], 0.5], N[(N[Log[N[Power[N[Power[N[Exp[N[Cos[N[(K * N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] + M), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-l) - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[M], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{m + n}{2} - M\right)}^{2}\\
t_1 := e^{\left(\left|m - n\right| - \ell\right) - t\_0}\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t\_1 \leq 0.5:\\
\;\;\;\;\log \left({\left(\sqrt[3]{e^{\cos \left(\mathsf{fma}\left(K, \left(m + n\right) \cdot 0.5, M\right)\right)}}\right)}^{3}\right) \cdot e^{\left(-\ell\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \cos M\\
\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)))))) < 0.5Initial program 96.7%
add-log-exp96.7%
associate-/l*96.7%
fma-neg96.7%
div-inv96.7%
metadata-eval96.7%
Applied egg-rr96.7%
Taylor expanded in l around inf 96.7%
add-cube-cbrt96.7%
pow396.7%
add-sqr-sqrt55.9%
sqrt-unprod69.8%
sqr-neg69.8%
sqrt-unprod40.8%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
if 0.5 < (*.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 29.7%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Final simplification97.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (pow (- (/ (+ m n) 2.0) M) 2.0))
(t_1 (exp (- (- (fabs (- m n)) l) t_0))))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_1) 0.5)
(* (exp (- (- l) t_0)) (log (exp (cos (fma K (* (+ m n) 0.5) (- M))))))
(* t_1 (cos M)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = pow((((m + n) / 2.0) - M), 2.0);
double t_1 = exp(((fabs((m - n)) - l) - t_0));
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_1) <= 0.5) {
tmp = exp((-l - t_0)) * log(exp(cos(fma(K, ((m + n) * 0.5), -M))));
} else {
tmp = t_1 * cos(M);
}
return tmp;
}
function code(K, m, n, M, l) t_0 = Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0 t_1 = exp(Float64(Float64(abs(Float64(m - n)) - l) - t_0)) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_1) <= 0.5) tmp = Float64(exp(Float64(Float64(-l) - t_0)) * log(exp(cos(fma(K, Float64(Float64(m + n) * 0.5), Float64(-M)))))); else tmp = Float64(t_1 * cos(M)); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], 0.5], N[(N[Exp[N[((-l) - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Log[N[Exp[N[Cos[N[(K * N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] + (-M)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[M], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{m + n}{2} - M\right)}^{2}\\
t_1 := e^{\left(\left|m - n\right| - \ell\right) - t\_0}\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t\_1 \leq 0.5:\\
\;\;\;\;e^{\left(-\ell\right) - t\_0} \cdot \log \left(e^{\cos \left(\mathsf{fma}\left(K, \left(m + n\right) \cdot 0.5, -M\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \cos M\\
\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)))))) < 0.5Initial program 96.7%
add-log-exp96.7%
associate-/l*96.7%
fma-neg96.7%
div-inv96.7%
metadata-eval96.7%
Applied egg-rr96.7%
Taylor expanded in l around inf 96.7%
if 0.5 < (*.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 29.7%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Final simplification97.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (cos (- (/ (* K (+ m n)) 2.0) M)))
(t_1 (pow (- (/ (+ m n) 2.0) M) 2.0))
(t_2 (exp (- (- (fabs (- m n)) l) t_1))))
(if (<= (* t_0 t_2) 0.5) (* t_0 (exp (- (- l) t_1))) (* t_2 (cos M)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos((((K * (m + n)) / 2.0) - M));
double t_1 = pow((((m + n) / 2.0) - M), 2.0);
double t_2 = exp(((fabs((m - n)) - l) - t_1));
double tmp;
if ((t_0 * t_2) <= 0.5) {
tmp = t_0 * exp((-l - t_1));
} else {
tmp = t_2 * cos(M);
}
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 = cos((((k * (m + n)) / 2.0d0) - m_1))
t_1 = (((m + n) / 2.0d0) - m_1) ** 2.0d0
t_2 = exp(((abs((m - n)) - l) - t_1))
if ((t_0 * t_2) <= 0.5d0) then
tmp = t_0 * exp((-l - t_1))
else
tmp = t_2 * cos(m_1)
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((((K * (m + n)) / 2.0) - M));
double t_1 = Math.pow((((m + n) / 2.0) - M), 2.0);
double t_2 = Math.exp(((Math.abs((m - n)) - l) - t_1));
double tmp;
if ((t_0 * t_2) <= 0.5) {
tmp = t_0 * Math.exp((-l - t_1));
} else {
tmp = t_2 * Math.cos(M);
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos((((K * (m + n)) / 2.0) - M)) t_1 = math.pow((((m + n) / 2.0) - M), 2.0) t_2 = math.exp(((math.fabs((m - n)) - l) - t_1)) tmp = 0 if (t_0 * t_2) <= 0.5: tmp = t_0 * math.exp((-l - t_1)) else: tmp = t_2 * math.cos(M) return tmp
function code(K, m, n, M, l) t_0 = cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) t_1 = Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0 t_2 = exp(Float64(Float64(abs(Float64(m - n)) - l) - t_1)) tmp = 0.0 if (Float64(t_0 * t_2) <= 0.5) tmp = Float64(t_0 * exp(Float64(Float64(-l) - t_1))); else tmp = Float64(t_2 * cos(M)); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos((((K * (m + n)) / 2.0) - M)); t_1 = (((m + n) / 2.0) - M) ^ 2.0; t_2 = exp(((abs((m - n)) - l) - t_1)); tmp = 0.0; if ((t_0 * t_2) <= 0.5) tmp = t_0 * exp((-l - t_1)); else tmp = t_2 * cos(M); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$0 * t$95$2), $MachinePrecision], 0.5], N[(t$95$0 * N[Exp[N[((-l) - t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[Cos[M], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\
t_1 := {\left(\frac{m + n}{2} - M\right)}^{2}\\
t_2 := e^{\left(\left|m - n\right| - \ell\right) - t\_1}\\
\mathbf{if}\;t\_0 \cdot t\_2 \leq 0.5:\\
\;\;\;\;t\_0 \cdot e^{\left(-\ell\right) - t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2 \cdot \cos M\\
\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)))))) < 0.5Initial program 96.7%
Taylor expanded in l around inf 96.7%
if 0.5 < (*.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 29.7%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Final simplification97.3%
(FPCore (K m n M l) :precision binary64 (* (exp (- (- l) (pow (- (/ (+ m n) 2.0) M) 2.0))) (cos M)))
double code(double K, double m, double n, double M, double l) {
return exp((-l - pow((((m + n) / 2.0) - 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((-l - ((((m + n) / 2.0d0) - 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((-l - Math.pow((((m + n) / 2.0) - M), 2.0))) * Math.cos(M);
}
def code(K, m, n, M, l): return math.exp((-l - math.pow((((m + n) / 2.0) - M), 2.0))) * math.cos(M)
function code(K, m, n, M, l) return Float64(exp(Float64(Float64(-l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) * cos(M)) end
function tmp = code(K, m, n, M, l) tmp = exp((-l - ((((m + n) / 2.0) - M) ^ 2.0))) * cos(M); end
code[K_, m_, n_, M_, l_] := N[(N[Exp[N[((-l) - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{\left(-\ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot \cos M
\end{array}
Initial program 77.3%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in l around inf 95.4%
Final simplification95.4%
(FPCore (K m n M l) :precision binary64 (if (<= m -2e+112) (exp (- (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) l)) (* (cos M) (exp (- (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2e+112) {
tmp = exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - 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 (m <= (-2d+112)) then
tmp = exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) - l))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) - 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 <= -2e+112) {
tmp = Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -2e+112: tmp = math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -2e+112) tmp = exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) - l)); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -2e+112) tmp = exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)); else tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -2e+112], N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2 \cdot 10^{+112}:\\
\;\;\;\;e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) - \ell}\\
\end{array}
\end{array}
if m < -1.9999999999999999e112Initial program 70.0%
Taylor expanded in l around inf 70.0%
Taylor expanded in n around 0 47.6%
+-commutative47.6%
unpow247.6%
distribute-rgt-out57.7%
*-commutative57.7%
*-commutative57.7%
Simplified57.7%
Taylor expanded in m around inf 57.7%
associate-*r*57.7%
Simplified57.7%
Taylor expanded in K around 0 87.7%
if -1.9999999999999999e112 < m Initial program 78.7%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in l around inf 94.5%
Taylor expanded in m around 0 80.3%
+-commutative80.3%
unpow280.3%
distribute-rgt-out85.4%
*-commutative85.4%
*-commutative85.4%
Simplified85.4%
Final simplification85.8%
(FPCore (K m n M l) :precision binary64 (if (<= n 1.45e+105) (* (cos M) (exp (- (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) l))) (* (cos M) (exp (- (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1.45e+105) {
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - 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 <= 1.45d+105) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) - l))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) - 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 <= 1.45e+105) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 1.45e+105: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 1.45e+105) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) - l))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 1.45e+105) tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)); else tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1.45e+105], 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] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.45 \cdot 10^{+105}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) - \ell}\\
\end{array}
\end{array}
if n < 1.45000000000000005e105Initial program 79.4%
Taylor expanded in l around inf 79.2%
Taylor expanded in n around 0 66.4%
+-commutative66.4%
unpow266.4%
distribute-rgt-out73.1%
*-commutative73.1%
*-commutative73.1%
Simplified73.1%
Taylor expanded in K around 0 84.9%
Simplified84.9%
if 1.45000000000000005e105 < n Initial program 68.1%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around inf 100.0%
Taylor expanded in m around 0 78.8%
+-commutative78.8%
unpow278.8%
distribute-rgt-out95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Final simplification86.9%
(FPCore (K m n M l) :precision binary64 (exp (- (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) l)))
double code(double K, double m, double n, double M, double l) {
return exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - 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(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) - l))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
}
def code(K, m, n, M, l): return math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l))
function code(K, m, n, M, l) return exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) - l)) end
function tmp = code(K, m, n, M, l) tmp = exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) - \ell}
\end{array}
Initial program 77.3%
Taylor expanded in l around inf 77.2%
Taylor expanded in n around 0 59.7%
+-commutative59.7%
unpow259.7%
distribute-rgt-out67.2%
*-commutative67.2%
*-commutative67.2%
Simplified67.2%
Taylor expanded in m around inf 68.9%
associate-*r*68.9%
Simplified68.9%
Taylor expanded in K around 0 80.2%
Final simplification80.2%
herbie shell --seed 2024072
(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)))))))