
(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 (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0))))
(t_1 (- (* 0.5 (* K m)) M)))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_0) INFINITY)
(* t_0 (+ (cos t_1) (* -0.5 (* K (* n (sin t_1))))))
(exp (- (- l) (* 0.25 (* (+ m n) (+ m n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
double t_1 = (0.5 * (K * m)) - M;
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_0) <= ((double) INFINITY)) {
tmp = t_0 * (cos(t_1) + (-0.5 * (K * (n * sin(t_1)))));
} else {
tmp = exp((-l - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
double t_1 = (0.5 * (K * m)) - M;
double tmp;
if ((Math.cos((((K * (m + n)) / 2.0) - M)) * t_0) <= Double.POSITIVE_INFINITY) {
tmp = t_0 * (Math.cos(t_1) + (-0.5 * (K * (n * Math.sin(t_1)))));
} else {
tmp = Math.exp((-l - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0))) t_1 = (0.5 * (K * m)) - M tmp = 0 if (math.cos((((K * (m + n)) / 2.0) - M)) * t_0) <= math.inf: tmp = t_0 * (math.cos(t_1) + (-0.5 * (K * (n * math.sin(t_1))))) else: tmp = math.exp((-l - (0.25 * ((m + n) * (m + n))))) return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) t_1 = Float64(Float64(0.5 * Float64(K * m)) - M) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_0) <= Inf) tmp = Float64(t_0 * Float64(cos(t_1) + Float64(-0.5 * Float64(K * Float64(n * sin(t_1)))))); else tmp = exp(Float64(Float64(-l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); t_1 = (0.5 * (K * m)) - M; tmp = 0.0; if ((cos((((K * (m + n)) / 2.0) - M)) * t_0) <= Inf) tmp = t_0 * (cos(t_1) + (-0.5 * (K * (n * sin(t_1))))); else tmp = exp((-l - (0.25 * ((m + n) * (m + n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(N[(0.5 * N[(K * m), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], Infinity], N[(t$95$0 * N[(N[Cos[t$95$1], $MachinePrecision] + N[(-0.5 * N[(K * N[(n * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[((-l) - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
t_1 := 0.5 \cdot \left(K \cdot m\right) - M\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t\_0 \leq \infty:\\
\;\;\;\;t\_0 \cdot \left(\cos t\_1 + -0.5 \cdot \left(K \cdot \left(n \cdot \sin t\_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\left(-\ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\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 98.1%
Taylor expanded in n around 0 98.3%
*-commutative98.3%
*-commutative98.3%
Simplified98.3%
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 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in M around 0 100.0%
associate--r+100.0%
fabs-sub100.0%
Simplified100.0%
Taylor expanded in l around inf 100.0%
neg-mul-1100.0%
Simplified100.0%
unpow2100.0%
+-commutative100.0%
+-commutative100.0%
Applied egg-rr100.0%
Final simplification98.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0
(*
(cos (- (/ (* K (+ m n)) 2.0) M))
(exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0))))))
(if (<= t_0 1.0) t_0 (exp (- (- l) (* 0.25 (* (+ m n) (+ m n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos((((K * (m + n)) / 2.0) - M)) * exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if (t_0 <= 1.0) {
tmp = t_0;
} else {
tmp = exp((-l - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
if (t_0 <= 1.0d0) then
tmp = t_0
else
tmp = exp((-l - (0.25d0 * ((m + n) * (m + n)))))
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)) * Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if (t_0 <= 1.0) {
tmp = t_0;
} else {
tmp = Math.exp((-l - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0))) tmp = 0 if t_0 <= 1.0: tmp = t_0 else: tmp = math.exp((-l - (0.25 * ((m + n) * (m + n))))) return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) tmp = 0.0 if (t_0 <= 1.0) tmp = t_0; else tmp = exp(Float64(Float64(-l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos((((K * (m + n)) / 2.0) - M)) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); tmp = 0.0; if (t_0 <= 1.0) tmp = t_0; else tmp = exp((-l - (0.25 * ((m + n) * (m + n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * 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]), $MachinePrecision]}, If[LessEqual[t$95$0, 1.0], t$95$0, N[Exp[N[((-l) - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;t\_0 \leq 1:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{\left(-\ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\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)))))) < 1Initial program 99.0%
if 1 < (*.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 23.6%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
Simplified97.2%
Taylor expanded in M around 0 97.2%
associate--r+97.2%
fabs-sub97.2%
Simplified97.2%
Taylor expanded in l around inf 97.2%
neg-mul-197.2%
Simplified97.2%
unpow297.2%
+-commutative97.2%
+-commutative97.2%
Applied egg-rr97.2%
Final simplification98.5%
(FPCore (K m n M l) :precision binary64 (* (exp (- (- (fabs (- m n)) 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(((fabs((m - n)) - 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(((abs((m - n)) - 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(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - 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) / 2.0) - 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) / 2.0) - M) ^ 2.0))) * cos(M)) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - 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] / 2.0), $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(\frac{m + n}{2} - M\right)}^{2}} \cdot \cos M
\end{array}
Initial program 77.8%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
Simplified96.7%
Final simplification96.7%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -4000000000000.0) (not (<= M 2.4e+25))) (* (cos M) (exp (- (pow M 2.0)))) (exp (- (- l) (* 0.25 (* (+ m n) (+ m n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -4000000000000.0) || !(M <= 2.4e+25)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = exp((-l - (0.25 * ((m + n) * (m + n)))));
}
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 <= (-4000000000000.0d0)) .or. (.not. (m_1 <= 2.4d+25))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = exp((-l - (0.25d0 * ((m + n) * (m + n)))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -4000000000000.0) || !(M <= 2.4e+25)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp((-l - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -4000000000000.0) or not (M <= 2.4e+25): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.exp((-l - (0.25 * ((m + n) * (m + n))))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -4000000000000.0) || !(M <= 2.4e+25)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = exp(Float64(Float64(-l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -4000000000000.0) || ~((M <= 2.4e+25))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = exp((-l - (0.25 * ((m + n) * (m + n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -4000000000000.0], N[Not[LessEqual[M, 2.4e+25]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[((-l) - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -4000000000000 \lor \neg \left(M \leq 2.4 \cdot 10^{+25}\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(-\ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\end{array}
\end{array}
if M < -4e12 or 2.39999999999999996e25 < M Initial program 80.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 97.6%
mul-1-neg97.6%
Simplified97.6%
if -4e12 < M < 2.39999999999999996e25Initial program 75.6%
Taylor expanded in K around 0 93.7%
cos-neg93.7%
Simplified93.7%
Taylor expanded in M around 0 93.8%
associate--r+93.8%
fabs-sub93.8%
Simplified93.8%
Taylor expanded in l around inf 93.8%
neg-mul-193.8%
Simplified93.8%
unpow293.8%
+-commutative93.8%
+-commutative93.8%
Applied egg-rr93.8%
Final simplification95.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -53.0) (not (<= n 2.2e-5))) (exp (* (* n n) -0.25)) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -53.0) || !(n <= 2.2e-5)) {
tmp = exp(((n * n) * -0.25));
} else {
tmp = 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 <= (-53.0d0)) .or. (.not. (n <= 2.2d-5))) then
tmp = exp(((n * n) * (-0.25d0)))
else
tmp = 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 <= -53.0) || !(n <= 2.2e-5)) {
tmp = Math.exp(((n * n) * -0.25));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -53.0) or not (n <= 2.2e-5): tmp = math.exp(((n * n) * -0.25)) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -53.0) || !(n <= 2.2e-5)) tmp = exp(Float64(Float64(n * n) * -0.25)); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((n <= -53.0) || ~((n <= 2.2e-5))) tmp = exp(((n * n) * -0.25)); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -53.0], N[Not[LessEqual[n, 2.2e-5]], $MachinePrecision]], N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -53 \lor \neg \left(n \leq 2.2 \cdot 10^{-5}\right):\\
\;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if n < -53 or 2.1999999999999999e-5 < n Initial program 68.6%
Taylor expanded in K around 0 98.3%
cos-neg98.3%
Simplified98.3%
Taylor expanded in M around 0 97.5%
associate--r+97.5%
fabs-sub97.5%
Simplified97.5%
Taylor expanded in n around inf 95.1%
*-commutative95.1%
Simplified95.1%
unpow295.1%
Applied egg-rr95.1%
if -53 < n < 2.1999999999999999e-5Initial program 86.0%
Taylor expanded in K around 0 95.2%
cos-neg95.2%
Simplified95.2%
Taylor expanded in M around 0 82.9%
associate--r+82.9%
fabs-sub82.9%
Simplified82.9%
Taylor expanded in l around inf 82.9%
neg-mul-182.9%
Simplified82.9%
Taylor expanded in l around inf 48.3%
neg-mul-148.3%
Simplified48.3%
Final simplification70.5%
(FPCore (K m n M l) :precision binary64 (exp (- (- l) (* 0.25 (* (+ m n) (+ m n))))))
double code(double K, double m, double n, double M, double l) {
return exp((-l - (0.25 * ((m + n) * (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 = exp((-l - (0.25d0 * ((m + n) * (m + n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((-l - (0.25 * ((m + n) * (m + n)))));
}
def code(K, m, n, M, l): return math.exp((-l - (0.25 * ((m + n) * (m + n)))))
function code(K, m, n, M, l) return exp(Float64(Float64(-l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))) end
function tmp = code(K, m, n, M, l) tmp = exp((-l - (0.25 * ((m + n) * (m + n))))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[((-l) - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(-\ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}
\end{array}
Initial program 77.8%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
Simplified96.7%
Taylor expanded in M around 0 89.8%
associate--r+89.8%
fabs-sub89.8%
Simplified89.8%
Taylor expanded in l around inf 89.8%
neg-mul-189.8%
Simplified89.8%
unpow289.8%
+-commutative89.8%
+-commutative89.8%
Applied egg-rr89.8%
Final simplification89.8%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return 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 = exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 77.8%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
Simplified96.7%
Taylor expanded in M around 0 89.8%
associate--r+89.8%
fabs-sub89.8%
Simplified89.8%
Taylor expanded in l around inf 89.8%
neg-mul-189.8%
Simplified89.8%
Taylor expanded in l around inf 38.1%
neg-mul-138.1%
Simplified38.1%
(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.8%
Taylor expanded in l around inf 32.9%
mul-1-neg32.9%
Simplified32.9%
Taylor expanded in l around 0 6.1%
*-commutative6.1%
Simplified6.1%
Taylor expanded in m around inf 5.9%
distribute-lft-out5.9%
associate-/l*5.8%
Simplified5.8%
Taylor expanded in K around 0 6.5%
cos-neg6.5%
Simplified6.5%
(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.8%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
Simplified96.7%
Taylor expanded in M around 0 89.8%
associate--r+89.8%
fabs-sub89.8%
Simplified89.8%
Taylor expanded in n around inf 50.0%
*-commutative50.0%
Simplified50.0%
Taylor expanded in n around 0 6.5%
herbie shell --seed 2024165
(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)))))))