
(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 8 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 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(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]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 77.1%
*-commutative77.1%
associate-*r/77.1%
associate--r-77.1%
+-commutative77.1%
associate-+r-77.1%
unsub-neg77.1%
associate--r+77.1%
+-commutative77.1%
associate--r+77.1%
Simplified77.1%
Taylor expanded in K around 0 98.0%
cos-neg98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (K m n M l)
:precision binary64
(if (<= n -6.5e-275)
(* (cos M) (exp (* (* m m) -0.25)))
(if (<= n 54.0)
(* (cos M) (exp (- (- (fabs (- m n)) l) (* M M))))
(* (cos M) (exp (* -0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -6.5e-275) {
tmp = cos(M) * exp(((m * m) * -0.25));
} else if (n <= 54.0) {
tmp = cos(M) * exp(((fabs((m - n)) - l) - (M * M)));
} else {
tmp = cos(M) * exp((-0.25 * (n * 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 (n <= (-6.5d-275)) then
tmp = cos(m_1) * exp(((m * m) * (-0.25d0)))
else if (n <= 54.0d0) then
tmp = cos(m_1) * exp(((abs((m - n)) - l) - (m_1 * m_1)))
else
tmp = cos(m_1) * exp(((-0.25d0) * (n * n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -6.5e-275) {
tmp = Math.cos(M) * Math.exp(((m * m) * -0.25));
} else if (n <= 54.0) {
tmp = Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - (M * M)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= -6.5e-275: tmp = math.cos(M) * math.exp(((m * m) * -0.25)) elif n <= 54.0: tmp = math.cos(M) * math.exp(((math.fabs((m - n)) - l) - (M * M))) else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= -6.5e-275) tmp = Float64(cos(M) * exp(Float64(Float64(m * m) * -0.25))); elseif (n <= 54.0) tmp = Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(M * M)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(n * n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= -6.5e-275) tmp = cos(M) * exp(((m * m) * -0.25)); elseif (n <= 54.0) tmp = cos(M) * exp(((abs((m - n)) - l) - (M * M))); else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, -6.5e-275], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -6.5 \cdot 10^{-275}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < -6.500000000000001e-275Initial program 73.4%
*-commutative73.4%
associate-*r/73.4%
associate--r-73.4%
+-commutative73.4%
associate-+r-73.4%
unsub-neg73.4%
associate--r+73.4%
+-commutative73.4%
associate--r+73.4%
Simplified73.4%
Taylor expanded in K around 0 99.1%
cos-neg99.1%
Simplified99.1%
Taylor expanded in m around inf 56.7%
*-commutative56.7%
unpow256.7%
Simplified56.7%
if -6.500000000000001e-275 < n < 54Initial program 85.8%
*-commutative85.8%
associate-*r/85.8%
associate--r-85.8%
+-commutative85.8%
associate-+r-85.8%
unsub-neg85.8%
associate--r+85.8%
+-commutative85.8%
associate--r+85.8%
Simplified85.8%
Taylor expanded in K around 0 94.5%
cos-neg94.5%
Simplified94.5%
Taylor expanded in M around inf 76.4%
unpow276.4%
Simplified76.4%
if 54 < n Initial program 73.5%
*-commutative73.5%
associate-*r/73.5%
associate--r-73.5%
+-commutative73.5%
associate-+r-73.5%
unsub-neg73.5%
associate--r+73.5%
+-commutative73.5%
associate--r+73.5%
Simplified73.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Final simplification74.1%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -7000000.0) (not (<= M 28500000000.0))) (* (cos M) (exp (* M (- M)))) (* (cos M) (exp (* (* m m) -0.25)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -7000000.0) || !(M <= 28500000000.0)) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = cos(M) * exp(((m * m) * -0.25));
}
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 <= (-7000000.0d0)) .or. (.not. (m_1 <= 28500000000.0d0))) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = cos(m_1) * exp(((m * m) * (-0.25d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -7000000.0) || !(M <= 28500000000.0)) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp(((m * m) * -0.25));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -7000000.0) or not (M <= 28500000000.0): tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp(((m * m) * -0.25)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -7000000.0) || !(M <= 28500000000.0)) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) * exp(Float64(Float64(m * m) * -0.25))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -7000000.0) || ~((M <= 28500000000.0))) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp(((m * m) * -0.25)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -7000000.0], N[Not[LessEqual[M, 28500000000.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -7000000 \lor \neg \left(M \leq 28500000000\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\
\end{array}
\end{array}
if M < -7e6 or 2.85e10 < M Initial program 80.2%
*-commutative80.2%
associate-*r/80.2%
associate--r-80.2%
+-commutative80.2%
associate-+r-80.2%
unsub-neg80.2%
associate--r+80.2%
+-commutative80.2%
associate--r+80.2%
Simplified80.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 97.7%
mul-1-neg97.7%
unpow297.7%
distribute-rgt-neg-in97.7%
Simplified97.7%
if -7e6 < M < 2.85e10Initial program 73.9%
*-commutative73.9%
associate-*r/73.9%
associate--r-73.9%
+-commutative73.9%
associate-+r-73.9%
unsub-neg73.9%
associate--r+73.9%
+-commutative73.9%
associate--r+73.9%
Simplified73.9%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in m around inf 61.3%
*-commutative61.3%
unpow261.3%
Simplified61.3%
Final simplification80.0%
(FPCore (K m n M l)
:precision binary64
(if (<= m -54.0)
(* (cos M) (exp (* (* m m) -0.25)))
(if (<= m 1.6e-167)
(* (cos M) (exp (* M (- M))))
(* (cos M) (exp (* -0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = cos(M) * exp(((m * m) * -0.25));
} else if (m <= 1.6e-167) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = cos(M) * exp((-0.25 * (n * 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 <= (-54.0d0)) then
tmp = cos(m_1) * exp(((m * m) * (-0.25d0)))
else if (m <= 1.6d-167) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = cos(m_1) * exp(((-0.25d0) * (n * 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 <= -54.0) {
tmp = Math.cos(M) * Math.exp(((m * m) * -0.25));
} else if (m <= 1.6e-167) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -54.0: tmp = math.cos(M) * math.exp(((m * m) * -0.25)) elif m <= 1.6e-167: tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -54.0) tmp = Float64(cos(M) * exp(Float64(Float64(m * m) * -0.25))); elseif (m <= 1.6e-167) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(n * n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -54.0) tmp = cos(M) * exp(((m * m) * -0.25)); elseif (m <= 1.6e-167) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -54.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.6e-167], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -54:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;m \leq 1.6 \cdot 10^{-167}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -54Initial program 66.0%
*-commutative66.0%
associate-*r/66.0%
associate--r-66.0%
+-commutative66.0%
associate-+r-66.0%
unsub-neg66.0%
associate--r+66.0%
+-commutative66.0%
associate--r+66.0%
Simplified66.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 98.1%
*-commutative98.1%
unpow298.1%
Simplified98.1%
if -54 < m < 1.6000000000000001e-167Initial program 86.3%
*-commutative86.3%
associate-*r/86.3%
associate--r-86.3%
+-commutative86.3%
associate-+r-86.3%
unsub-neg86.3%
associate--r+86.3%
+-commutative86.3%
associate--r+86.3%
Simplified86.3%
Taylor expanded in K around 0 97.3%
cos-neg97.3%
Simplified97.3%
Taylor expanded in M around inf 58.3%
mul-1-neg58.3%
unpow258.3%
distribute-rgt-neg-in58.3%
Simplified58.3%
if 1.6000000000000001e-167 < m Initial program 75.4%
*-commutative75.4%
associate-*r/75.4%
associate--r-75.4%
+-commutative75.4%
associate-+r-75.4%
unsub-neg75.4%
associate--r+75.4%
+-commutative75.4%
associate--r+75.4%
Simplified75.4%
Taylor expanded in K around 0 97.6%
cos-neg97.6%
Simplified97.6%
Taylor expanded in n around inf 52.1%
*-commutative52.1%
unpow252.1%
Simplified52.1%
Final simplification63.7%
(FPCore (K m n M l) :precision binary64 (if (<= l -0.00045) (* (cos M) (exp l)) (if (<= l 6.2e-10) (* (cos M) (exp (* M (- M)))) (/ (cos M) (exp l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -0.00045) {
tmp = cos(M) * exp(l);
} else if (l <= 6.2e-10) {
tmp = cos(M) * exp((M * -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) :: tmp
if (l <= (-0.00045d0)) then
tmp = cos(m_1) * exp(l)
else if (l <= 6.2d-10) then
tmp = cos(m_1) * exp((m_1 * -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 tmp;
if (l <= -0.00045) {
tmp = Math.cos(M) * Math.exp(l);
} else if (l <= 6.2e-10) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -0.00045: tmp = math.cos(M) * math.exp(l) elif l <= 6.2e-10: tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -0.00045) tmp = Float64(cos(M) * exp(l)); elseif (l <= 6.2e-10) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -0.00045) tmp = cos(M) * exp(l); elseif (l <= 6.2e-10) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -0.00045], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.2e-10], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.00045:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{elif}\;\ell \leq 6.2 \cdot 10^{-10}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if l < -4.4999999999999999e-4Initial program 72.2%
*-commutative72.2%
associate-*r/72.2%
associate--r-72.2%
+-commutative72.2%
associate-+r-72.2%
unsub-neg72.2%
associate--r+72.2%
+-commutative72.2%
associate--r+72.2%
Simplified72.2%
Taylor expanded in l around inf 17.6%
neg-mul-117.6%
Simplified17.6%
clear-num17.6%
un-div-inv19.0%
Applied egg-rr19.0%
expm1-log1p-u15.7%
expm1-udef15.7%
Applied egg-rr53.2%
expm1-def53.2%
expm1-log1p53.2%
fma-neg53.2%
*-commutative53.2%
fma-neg53.2%
+-commutative53.2%
Simplified53.2%
Taylor expanded in K around 0 75.4%
*-commutative75.4%
cos-neg75.4%
Simplified75.4%
if -4.4999999999999999e-4 < l < 6.2000000000000003e-10Initial program 80.7%
*-commutative80.7%
associate-*r/80.7%
associate--r-80.7%
+-commutative80.7%
associate-+r-80.7%
unsub-neg80.7%
associate--r+80.7%
+-commutative80.7%
associate--r+80.7%
Simplified80.7%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
Simplified97.9%
Taylor expanded in M around inf 60.1%
mul-1-neg60.1%
unpow260.1%
distribute-rgt-neg-in60.1%
Simplified60.1%
if 6.2000000000000003e-10 < l Initial program 76.3%
*-commutative76.3%
associate-*r/76.3%
associate--r-76.3%
+-commutative76.3%
associate-+r-76.3%
unsub-neg76.3%
associate--r+76.3%
+-commutative76.3%
associate--r+76.3%
Simplified76.3%
Taylor expanded in l around inf 76.3%
neg-mul-176.3%
Simplified76.3%
clear-num76.3%
un-div-inv76.3%
Applied egg-rr76.3%
Taylor expanded in K around 0 97.5%
*-commutative97.5%
exp-neg97.5%
associate-*r/97.5%
*-rgt-identity97.5%
cos-neg97.5%
Simplified97.5%
Final simplification74.8%
(FPCore (K m n M l) :precision binary64 (if (<= l -4e-16) (* (cos M) (exp l)) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -4e-16) {
tmp = cos(M) * exp(l);
} 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 (l <= (-4d-16)) then
tmp = cos(m_1) * exp(l)
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 (l <= -4e-16) {
tmp = Math.cos(M) * Math.exp(l);
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -4e-16: tmp = math.cos(M) * math.exp(l) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -4e-16) tmp = Float64(cos(M) * exp(l)); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -4e-16) tmp = cos(M) * exp(l); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -4e-16], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4 \cdot 10^{-16}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if l < -3.9999999999999999e-16Initial program 73.3%
*-commutative73.3%
associate-*r/73.3%
associate--r-73.3%
+-commutative73.3%
associate-+r-73.3%
unsub-neg73.3%
associate--r+73.3%
+-commutative73.3%
associate--r+73.3%
Simplified73.3%
Taylor expanded in l around inf 17.0%
neg-mul-117.0%
Simplified17.0%
clear-num17.0%
un-div-inv18.3%
Applied egg-rr18.3%
expm1-log1p-u15.2%
expm1-udef15.2%
Applied egg-rr51.2%
expm1-def51.2%
expm1-log1p51.2%
fma-neg51.2%
*-commutative51.2%
fma-neg51.2%
+-commutative51.2%
Simplified51.2%
Taylor expanded in K around 0 72.5%
*-commutative72.5%
cos-neg72.5%
Simplified72.5%
if -3.9999999999999999e-16 < l Initial program 78.7%
*-commutative78.7%
associate-*r/78.7%
associate--r-78.7%
+-commutative78.7%
associate-+r-78.7%
unsub-neg78.7%
associate--r+78.7%
+-commutative78.7%
associate--r+78.7%
Simplified78.7%
Taylor expanded in l around inf 35.0%
neg-mul-135.0%
Simplified35.0%
clear-num35.0%
un-div-inv35.1%
Applied egg-rr35.1%
Taylor expanded in K around 0 43.6%
*-commutative43.6%
exp-neg43.6%
associate-*r/43.6%
*-rgt-identity43.6%
cos-neg43.6%
Simplified43.6%
Final simplification52.1%
(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(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 77.1%
*-commutative77.1%
associate-*r/77.1%
associate--r-77.1%
+-commutative77.1%
associate-+r-77.1%
unsub-neg77.1%
associate--r+77.1%
+-commutative77.1%
associate--r+77.1%
Simplified77.1%
Taylor expanded in l around inf 29.8%
neg-mul-129.8%
Simplified29.8%
clear-num29.8%
un-div-inv30.2%
Applied egg-rr30.2%
expm1-log1p-u29.3%
expm1-udef29.3%
Applied egg-rr19.1%
expm1-def19.1%
expm1-log1p19.2%
fma-neg19.2%
*-commutative19.2%
fma-neg19.2%
+-commutative19.2%
Simplified19.2%
Taylor expanded in K around 0 25.8%
*-commutative25.8%
cos-neg25.8%
Simplified25.8%
Final simplification25.8%
(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(Float64(-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 \left(-M\right)
\end{array}
Initial program 77.1%
*-commutative77.1%
associate-*r/77.1%
associate--r-77.1%
+-commutative77.1%
associate-+r-77.1%
unsub-neg77.1%
associate--r+77.1%
+-commutative77.1%
associate--r+77.1%
Simplified77.1%
Taylor expanded in l around inf 29.8%
neg-mul-129.8%
Simplified29.8%
Taylor expanded in l around 0 5.2%
Taylor expanded in K around 0 5.8%
neg-mul-15.8%
Simplified5.8%
Final simplification5.8%
herbie shell --seed 2023256
(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)))))))