
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (fabs (- m n)) l))
(t_1
(*
(cos (- (/ (* K (+ m n)) 2.0) M))
(exp (- t_0 (pow (- (/ (+ m n) 2.0) M) 2.0))))))
(if (<= t_1 INFINITY)
t_1
(* (cos M) (exp (- t_0 (pow (- (* (+ m n) 0.5) M) 2.0)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n)) - l;
double t_1 = cos((((K * (m + n)) / 2.0) - M)) * exp((t_0 - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = cos(M) * exp((t_0 - pow((((m + n) * 0.5) - M), 2.0)));
}
return tmp;
}
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.abs((m - n)) - l;
double t_1 = Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((t_0 - Math.pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = Math.cos(M) * Math.exp((t_0 - Math.pow((((m + n) * 0.5) - M), 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) - l t_1 = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((t_0 - math.pow((((m + n) / 2.0) - M), 2.0))) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = math.cos(M) * math.exp((t_0 - math.pow((((m + n) * 0.5) - M), 2.0))) return tmp
function code(K, m, n, M, l) t_0 = Float64(abs(Float64(m - n)) - l) t_1 = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(t_0 - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(cos(M) * exp(Float64(t_0 - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)) - l; t_1 = cos((((K * (m + n)) / 2.0) - M)) * exp((t_0 - ((((m + n) / 2.0) - M) ^ 2.0))); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = cos(M) * exp((t_0 - ((((m + n) * 0.5) - M) ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(t$95$0 - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right| - \ell\\
t_1 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{t\_0 - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t\_0 - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}\\
\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 96.7%
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%
add-cube-cbrt0.0%
pow30.0%
Applied egg-rr0.0%
Taylor expanded in K around 0 98.0%
Simplified98.0%
Final simplification96.9%
(FPCore (K m n M l) :precision binary64 (if (<= n 10000000000000.0) (* (cos M) (exp (- (fabs (- m n)) (+ l (pow (- (* m 0.5) M) 2.0))))) (exp (* -0.25 (pow n 2.0)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 10000000000000.0) {
tmp = cos(M) * exp((fabs((m - n)) - (l + pow(((m * 0.5) - M), 2.0))));
} else {
tmp = 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) :: tmp
if (n <= 10000000000000.0d0) then
tmp = cos(m_1) * exp((abs((m - n)) - (l + (((m * 0.5d0) - m_1) ** 2.0d0))))
else
tmp = 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 tmp;
if (n <= 10000000000000.0) {
tmp = Math.cos(M) * Math.exp((Math.abs((m - n)) - (l + Math.pow(((m * 0.5) - M), 2.0))));
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 10000000000000.0: tmp = math.cos(M) * math.exp((math.fabs((m - n)) - (l + math.pow(((m * 0.5) - M), 2.0)))) else: tmp = math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 10000000000000.0) tmp = Float64(cos(M) * exp(Float64(abs(Float64(m - n)) - Float64(l + (Float64(Float64(m * 0.5) - M) ^ 2.0))))); else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 10000000000000.0) tmp = cos(M) * exp((abs((m - n)) - (l + (((m * 0.5) - M) ^ 2.0)))); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 10000000000000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[Power[N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 10000000000000:\\
\;\;\;\;\cos M \cdot e^{\left|m - n\right| - \left(\ell + {\left(m \cdot 0.5 - M\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 1e13Initial program 79.0%
add-cube-cbrt78.7%
pow378.2%
Applied egg-rr78.2%
Taylor expanded in m around 0 90.1%
Taylor expanded in n around 0 82.5%
cos-neg82.5%
fabs-sub82.5%
*-commutative82.5%
Simplified82.5%
if 1e13 < n Initial program 75.4%
Taylor expanded in n around inf 73.8%
Taylor expanded in M around 0 73.8%
*-commutative73.8%
associate-*r*73.8%
Simplified73.8%
Taylor expanded in K around 0 98.4%
Final simplification86.3%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (- (* (+ m n) 0.5) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((m - n)) - l) - pow((((m + n) * 0.5) - 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((m - n)) - l) - ((((m + n) * 0.5d0) - 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((m - n)) - l) - Math.pow((((m + n) * 0.5) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) * 0.5) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) * 0.5) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * 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]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}
\end{array}
Initial program 78.2%
add-cube-cbrt77.6%
pow377.2%
Applied egg-rr77.2%
Taylor expanded in K around 0 95.1%
Simplified95.1%
Final simplification95.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (cos (- (/ (* K (+ m n)) 2.0) M)))
(t_1 (exp (* -0.25 (pow n 2.0)))))
(if (<= n -54.0)
t_1
(if (<= n 1.2e-206)
(* t_0 (exp (* -0.25 (pow m 2.0))))
(if (<= n 5.8e-12)
(* t_0 (exp (- (pow M 2.0))))
(if (<= n 250000000.0) (* (cos M) (exp (- l))) t_1))))))
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 = exp((-0.25 * pow(n, 2.0)));
double tmp;
if (n <= -54.0) {
tmp = t_1;
} else if (n <= 1.2e-206) {
tmp = t_0 * exp((-0.25 * pow(m, 2.0)));
} else if (n <= 5.8e-12) {
tmp = t_0 * exp(-pow(M, 2.0));
} else if (n <= 250000000.0) {
tmp = cos(M) * exp(-l);
} else {
tmp = t_1;
}
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 = cos((((k * (m + n)) / 2.0d0) - m_1))
t_1 = exp(((-0.25d0) * (n ** 2.0d0)))
if (n <= (-54.0d0)) then
tmp = t_1
else if (n <= 1.2d-206) then
tmp = t_0 * exp(((-0.25d0) * (m ** 2.0d0)))
else if (n <= 5.8d-12) then
tmp = t_0 * exp(-(m_1 ** 2.0d0))
else if (n <= 250000000.0d0) then
tmp = cos(m_1) * exp(-l)
else
tmp = t_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.exp((-0.25 * Math.pow(n, 2.0)));
double tmp;
if (n <= -54.0) {
tmp = t_1;
} else if (n <= 1.2e-206) {
tmp = t_0 * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (n <= 5.8e-12) {
tmp = t_0 * Math.exp(-Math.pow(M, 2.0));
} else if (n <= 250000000.0) {
tmp = Math.cos(M) * Math.exp(-l);
} else {
tmp = t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos((((K * (m + n)) / 2.0) - M)) t_1 = math.exp((-0.25 * math.pow(n, 2.0))) tmp = 0 if n <= -54.0: tmp = t_1 elif n <= 1.2e-206: tmp = t_0 * math.exp((-0.25 * math.pow(m, 2.0))) elif n <= 5.8e-12: tmp = t_0 * math.exp(-math.pow(M, 2.0)) elif n <= 250000000.0: tmp = math.cos(M) * math.exp(-l) else: tmp = t_1 return tmp
function code(K, m, n, M, l) t_0 = cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) t_1 = exp(Float64(-0.25 * (n ^ 2.0))) tmp = 0.0 if (n <= -54.0) tmp = t_1; elseif (n <= 1.2e-206) tmp = Float64(t_0 * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (n <= 5.8e-12) tmp = Float64(t_0 * exp(Float64(-(M ^ 2.0)))); elseif (n <= 250000000.0) tmp = Float64(cos(M) * exp(Float64(-l))); else tmp = t_1; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos((((K * (m + n)) / 2.0) - M)); t_1 = exp((-0.25 * (n ^ 2.0))); tmp = 0.0; if (n <= -54.0) tmp = t_1; elseif (n <= 1.2e-206) tmp = t_0 * exp((-0.25 * (m ^ 2.0))); elseif (n <= 5.8e-12) tmp = t_0 * exp(-(M ^ 2.0)); elseif (n <= 250000000.0) tmp = cos(M) * exp(-l); else tmp = t_1; 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[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -54.0], t$95$1, If[LessEqual[n, 1.2e-206], N[(t$95$0 * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 5.8e-12], N[(t$95$0 * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 250000000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\
t_1 := e^{-0.25 \cdot {n}^{2}}\\
\mathbf{if}\;n \leq -54:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;n \leq 1.2 \cdot 10^{-206}:\\
\;\;\;\;t\_0 \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;n \leq 5.8 \cdot 10^{-12}:\\
\;\;\;\;t\_0 \cdot e^{-{M}^{2}}\\
\mathbf{elif}\;n \leq 250000000:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if n < -54 or 2.5e8 < n Initial program 77.5%
Taylor expanded in n around inf 74.5%
Taylor expanded in M around 0 74.5%
*-commutative74.5%
associate-*r*74.5%
Simplified74.5%
Taylor expanded in K around 0 96.2%
if -54 < n < 1.2e-206Initial program 77.1%
Taylor expanded in m around inf 46.6%
if 1.2e-206 < n < 5.8000000000000003e-12Initial program 80.9%
Taylor expanded in M around inf 45.5%
mul-1-neg45.5%
Simplified45.5%
if 5.8000000000000003e-12 < n < 2.5e8Initial program 85.7%
Taylor expanded in l around inf 71.9%
mul-1-neg71.9%
Simplified71.9%
Taylor expanded in K around 0 86.2%
cos-neg100.0%
Simplified86.2%
Final simplification72.5%
(FPCore (K m n M l)
:precision binary64
(if (<= m -1.45e+206)
(* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (* -0.25 (pow m 2.0))))
(*
(cos M)
(exp (+ (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) (- (fabs (- m n)) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1.45e+206) {
tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (fabs((m - n)) - l)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-1.45d+206)) then
tmp = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) + (abs((m - n)) - l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1.45e+206) {
tmp = Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (Math.abs((m - n)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1.45e+206: tmp = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (math.fabs((m - n)) - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1.45e+206) tmp = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(-0.25 * (m ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) + Float64(abs(Float64(m - n)) - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1.45e+206) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (abs((m - n)) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1.45e+206], N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $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] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.45 \cdot 10^{+206}:\\
\;\;\;\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) + \left(\left|m - n\right| - \ell\right)}\\
\end{array}
\end{array}
if m < -1.45e206Initial program 57.1%
Taylor expanded in m around inf 57.1%
if -1.45e206 < m Initial program 80.0%
Taylor expanded in m around 0 65.5%
+-commutative65.5%
unpow265.5%
distribute-rgt-out70.2%
*-commutative70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in K around 0 80.7%
cos-neg80.7%
Simplified80.7%
Final simplification78.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* -0.25 (pow n 2.0)))))
(if (<= n -54.0)
t_0
(if (<= n 8e-12)
(* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (pow M 2.0))))
(if (<= n 250000000.0) (* (cos M) (exp (- l))) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-0.25 * pow(n, 2.0)));
double tmp;
if (n <= -54.0) {
tmp = t_0;
} else if (n <= 8e-12) {
tmp = cos((((K * (m + n)) / 2.0) - M)) * exp(-pow(M, 2.0));
} else if (n <= 250000000.0) {
tmp = cos(M) * exp(-l);
} else {
tmp = 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) :: tmp
t_0 = exp(((-0.25d0) * (n ** 2.0d0)))
if (n <= (-54.0d0)) then
tmp = t_0
else if (n <= 8d-12) then
tmp = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp(-(m_1 ** 2.0d0))
else if (n <= 250000000.0d0) then
tmp = cos(m_1) * exp(-l)
else
tmp = 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((-0.25 * Math.pow(n, 2.0)));
double tmp;
if (n <= -54.0) {
tmp = t_0;
} else if (n <= 8e-12) {
tmp = Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp(-Math.pow(M, 2.0));
} else if (n <= 250000000.0) {
tmp = Math.cos(M) * Math.exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-0.25 * math.pow(n, 2.0))) tmp = 0 if n <= -54.0: tmp = t_0 elif n <= 8e-12: tmp = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp(-math.pow(M, 2.0)) elif n <= 250000000.0: tmp = math.cos(M) * math.exp(-l) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-0.25 * (n ^ 2.0))) tmp = 0.0 if (n <= -54.0) tmp = t_0; elseif (n <= 8e-12) tmp = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(-(M ^ 2.0)))); elseif (n <= 250000000.0) tmp = Float64(cos(M) * exp(Float64(-l))); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-0.25 * (n ^ 2.0))); tmp = 0.0; if (n <= -54.0) tmp = t_0; elseif (n <= 8e-12) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp(-(M ^ 2.0)); elseif (n <= 250000000.0) tmp = cos(M) * exp(-l); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -54.0], t$95$0, If[LessEqual[n, 8e-12], N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 250000000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot {n}^{2}}\\
\mathbf{if}\;n \leq -54:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 8 \cdot 10^{-12}:\\
\;\;\;\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{-{M}^{2}}\\
\mathbf{elif}\;n \leq 250000000:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -54 or 2.5e8 < n Initial program 77.5%
Taylor expanded in n around inf 74.5%
Taylor expanded in M around 0 74.5%
*-commutative74.5%
associate-*r*74.5%
Simplified74.5%
Taylor expanded in K around 0 96.2%
if -54 < n < 7.99999999999999984e-12Initial program 78.4%
Taylor expanded in M around inf 42.2%
mul-1-neg42.2%
Simplified42.2%
if 7.99999999999999984e-12 < n < 2.5e8Initial program 85.7%
Taylor expanded in l around inf 71.9%
mul-1-neg71.9%
Simplified71.9%
Taylor expanded in K around 0 86.2%
cos-neg100.0%
Simplified86.2%
Final simplification70.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -53.0) (not (<= n 55.0))) (exp (* -0.25 (pow n 2.0))) (* (exp (- l)) (cos (- (* K (* n 0.5)) M)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -53.0) || !(n <= 55.0)) {
tmp = exp((-0.25 * pow(n, 2.0)));
} else {
tmp = exp(-l) * cos(((K * (n * 0.5)) - 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) :: tmp
if ((n <= (-53.0d0)) .or. (.not. (n <= 55.0d0))) then
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
else
tmp = exp(-l) * cos(((k * (n * 0.5d0)) - m_1))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -53.0) || !(n <= 55.0)) {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
} else {
tmp = Math.exp(-l) * Math.cos(((K * (n * 0.5)) - M));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -53.0) or not (n <= 55.0): tmp = math.exp((-0.25 * math.pow(n, 2.0))) else: tmp = math.exp(-l) * math.cos(((K * (n * 0.5)) - M)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -53.0) || !(n <= 55.0)) tmp = exp(Float64(-0.25 * (n ^ 2.0))); else tmp = Float64(exp(Float64(-l)) * cos(Float64(Float64(K * Float64(n * 0.5)) - M))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((n <= -53.0) || ~((n <= 55.0))) tmp = exp((-0.25 * (n ^ 2.0))); else tmp = exp(-l) * cos(((K * (n * 0.5)) - M)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -53.0], N[Not[LessEqual[n, 55.0]], $MachinePrecision]], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Exp[(-l)], $MachinePrecision] * N[Cos[N[(N[(K * N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -53 \lor \neg \left(n \leq 55\right):\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell} \cdot \cos \left(K \cdot \left(n \cdot 0.5\right) - M\right)\\
\end{array}
\end{array}
if n < -53 or 55 < n Initial program 76.9%
Taylor expanded in n around inf 73.9%
Taylor expanded in M around 0 73.9%
*-commutative73.9%
associate-*r*73.9%
Simplified73.9%
Taylor expanded in K around 0 95.5%
if -53 < n < 55Initial program 79.4%
Taylor expanded in l around inf 38.0%
mul-1-neg38.0%
Simplified38.0%
Taylor expanded in m around 0 41.2%
*-commutative41.2%
associate-*l*41.2%
Simplified41.2%
Final simplification68.7%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -54.0) (not (<= n 250000000.0))) (exp (* -0.25 (pow n 2.0))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -54.0) || !(n <= 250000000.0)) {
tmp = exp((-0.25 * pow(n, 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 ((n <= (-54.0d0)) .or. (.not. (n <= 250000000.0d0))) then
tmp = exp(((-0.25d0) * (n ** 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 ((n <= -54.0) || !(n <= 250000000.0)) {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -54.0) or not (n <= 250000000.0): tmp = math.exp((-0.25 * math.pow(n, 2.0))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -54.0) || !(n <= 250000000.0)) tmp = exp(Float64(-0.25 * (n ^ 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 ((n <= -54.0) || ~((n <= 250000000.0))) tmp = exp((-0.25 * (n ^ 2.0))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -54.0], N[Not[LessEqual[n, 250000000.0]], $MachinePrecision]], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -54 \lor \neg \left(n \leq 250000000\right):\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if n < -54 or 2.5e8 < n Initial program 77.5%
Taylor expanded in n around inf 74.5%
Taylor expanded in M around 0 74.5%
*-commutative74.5%
associate-*r*74.5%
Simplified74.5%
Taylor expanded in K around 0 96.2%
if -54 < n < 2.5e8Initial program 78.8%
Taylor expanded in l around inf 37.7%
mul-1-neg37.7%
Simplified37.7%
Taylor expanded in K around 0 42.2%
cos-neg71.2%
Simplified42.2%
Final simplification69.4%
(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(Float64(-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}
\\
\cos M \cdot e^{-\ell}
\end{array}
Initial program 78.2%
Taylor expanded in l around inf 29.6%
mul-1-neg29.6%
Simplified29.6%
Taylor expanded in K around 0 34.8%
cos-neg77.6%
Simplified34.8%
herbie shell --seed 2024111
(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)))))))