
(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 10 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 76.9%
*-commutative76.9%
associate-*r/76.9%
associate--r-76.9%
+-commutative76.9%
associate-+r-76.9%
unsub-neg76.9%
associate--r+76.9%
+-commutative76.9%
associate--r+76.9%
Simplified76.9%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Final simplification96.3%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- 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(((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(((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(((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(((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(m - Float64(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(((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[(m - N[(n + l), $MachinePrecision]), $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(m - \left(n + \ell\right)\right) - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}
\end{array}
Initial program 76.9%
*-commutative76.9%
associate-*r/76.9%
associate--r-76.9%
+-commutative76.9%
associate-+r-76.9%
unsub-neg76.9%
associate--r+76.9%
+-commutative76.9%
associate--r+76.9%
Simplified76.9%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
expm1-log1p-u96.3%
expm1-udef96.0%
add-sqr-sqrt52.1%
fabs-sqr52.1%
add-sqr-sqrt96.0%
div-inv96.0%
fma-neg96.0%
metadata-eval96.0%
Applied egg-rr96.0%
expm1-def96.3%
expm1-log1p96.3%
associate--l-96.3%
fma-neg96.3%
*-commutative96.3%
+-commutative96.3%
Simplified96.3%
Final simplification96.3%
(FPCore (K m n M l)
:precision binary64
(if (<= n 7.9e-171)
(* (cos M) (exp m))
(if (<= n 35.0)
(* (cos M) (exp (* M (- M))))
(* (cos M) (exp (* n (* n -0.25)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 7.9e-171) {
tmp = cos(M) * exp(m);
} else if (n <= 35.0) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = cos(M) * exp((n * (n * -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 (n <= 7.9d-171) then
tmp = cos(m_1) * exp(m)
else if (n <= 35.0d0) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = cos(m_1) * exp((n * (n * (-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 (n <= 7.9e-171) {
tmp = Math.cos(M) * Math.exp(m);
} else if (n <= 35.0) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp((n * (n * -0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 7.9e-171: tmp = math.cos(M) * math.exp(m) elif n <= 35.0: tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp((n * (n * -0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 7.9e-171) tmp = Float64(cos(M) * exp(m)); elseif (n <= 35.0) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(n * -0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 7.9e-171) tmp = cos(M) * exp(m); elseif (n <= 35.0) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp((n * (n * -0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 7.9e-171], N[(N[Cos[M], $MachinePrecision] * N[Exp[m], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 35.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 7.9 \cdot 10^{-171}:\\
\;\;\;\;\cos M \cdot e^{m}\\
\mathbf{elif}\;n \leq 35:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if n < 7.8999999999999998e-171Initial program 78.2%
*-commutative78.2%
associate-*r/78.2%
associate--r-78.2%
+-commutative78.2%
associate-+r-78.2%
unsub-neg78.2%
associate--r+78.2%
+-commutative78.2%
associate--r+78.2%
Simplified78.2%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
expm1-log1p-u95.6%
expm1-udef95.6%
add-sqr-sqrt65.5%
fabs-sqr65.5%
add-sqr-sqrt95.6%
div-inv95.6%
fma-neg95.6%
metadata-eval95.6%
Applied egg-rr95.6%
expm1-def95.6%
expm1-log1p95.6%
associate--l-95.6%
fma-neg95.6%
*-commutative95.6%
+-commutative95.6%
Simplified95.6%
Taylor expanded in M around inf 64.1%
unpow264.1%
Simplified64.1%
Taylor expanded in m around inf 30.7%
if 7.8999999999999998e-171 < n < 35Initial program 79.8%
*-commutative79.8%
associate-*r/79.8%
associate--r-79.8%
+-commutative79.8%
associate-+r-79.8%
unsub-neg79.8%
associate--r+79.8%
+-commutative79.8%
associate--r+79.8%
Simplified79.8%
Taylor expanded in K around 0 92.3%
cos-neg92.3%
Simplified92.3%
Taylor expanded in M around inf 60.8%
unpow260.8%
neg-mul-160.8%
distribute-rgt-neg-in60.8%
Simplified60.8%
if 35 < n Initial program 72.3%
*-commutative72.3%
associate-*r/72.3%
associate--r-72.3%
+-commutative72.3%
associate-+r-72.3%
unsub-neg72.3%
associate--r+72.3%
+-commutative72.3%
associate--r+72.3%
Simplified72.3%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 98.5%
*-commutative98.5%
unpow298.5%
associate-*l*98.5%
Simplified98.5%
Final simplification52.1%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- m (+ n l)) (* M M)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((m - (n + l)) - (M * 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) * exp(((m - (n + l)) - (m_1 * m_1)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(((m - (n + l)) - (M * M)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((m - (n + l)) - (M * M)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(m - Float64(n + l)) - Float64(M * M)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((m - (n + l)) - (M * M))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(m - \left(n + \ell\right)\right) - M \cdot M}
\end{array}
Initial program 76.9%
*-commutative76.9%
associate-*r/76.9%
associate--r-76.9%
+-commutative76.9%
associate-+r-76.9%
unsub-neg76.9%
associate--r+76.9%
+-commutative76.9%
associate--r+76.9%
Simplified76.9%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
expm1-log1p-u96.3%
expm1-udef96.0%
add-sqr-sqrt52.1%
fabs-sqr52.1%
add-sqr-sqrt96.0%
div-inv96.0%
fma-neg96.0%
metadata-eval96.0%
Applied egg-rr96.0%
expm1-def96.3%
expm1-log1p96.3%
associate--l-96.3%
fma-neg96.3%
*-commutative96.3%
+-commutative96.3%
Simplified96.3%
Taylor expanded in M around inf 70.6%
unpow270.6%
Simplified70.6%
Final simplification70.6%
(FPCore (K m n M l) :precision binary64 (if (<= n 9.6e-175) (* (cos M) (exp m)) (if (<= n 35.0) (* (cos M) (exp (* M (- M)))) (* (cos M) (exp (- n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 9.6e-175) {
tmp = cos(M) * exp(m);
} else if (n <= 35.0) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = cos(M) * exp(-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 <= 9.6d-175) then
tmp = cos(m_1) * exp(m)
else if (n <= 35.0d0) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = cos(m_1) * exp(-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 <= 9.6e-175) {
tmp = Math.cos(M) * Math.exp(m);
} else if (n <= 35.0) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp(-n);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 9.6e-175: tmp = math.cos(M) * math.exp(m) elif n <= 35.0: tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp(-n) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 9.6e-175) tmp = Float64(cos(M) * exp(m)); elseif (n <= 35.0) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) * exp(Float64(-n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 9.6e-175) tmp = cos(M) * exp(m); elseif (n <= 35.0) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp(-n); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 9.6e-175], N[(N[Cos[M], $MachinePrecision] * N[Exp[m], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 35.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-n)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 9.6 \cdot 10^{-175}:\\
\;\;\;\;\cos M \cdot e^{m}\\
\mathbf{elif}\;n \leq 35:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-n}\\
\end{array}
\end{array}
if n < 9.6e-175Initial program 78.1%
*-commutative78.1%
associate-*r/78.1%
associate--r-78.1%
+-commutative78.1%
associate-+r-78.1%
unsub-neg78.1%
associate--r+78.1%
+-commutative78.1%
associate--r+78.1%
Simplified78.1%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
expm1-log1p-u95.6%
expm1-udef95.6%
add-sqr-sqrt65.3%
fabs-sqr65.3%
add-sqr-sqrt95.6%
div-inv95.6%
fma-neg95.6%
metadata-eval95.6%
Applied egg-rr95.6%
expm1-def95.6%
expm1-log1p95.6%
associate--l-95.6%
fma-neg95.6%
*-commutative95.6%
+-commutative95.6%
Simplified95.6%
Taylor expanded in M around inf 63.9%
unpow263.9%
Simplified63.9%
Taylor expanded in m around inf 30.9%
if 9.6e-175 < n < 35Initial program 80.4%
*-commutative80.4%
associate-*r/80.4%
associate--r-80.4%
+-commutative80.4%
associate-+r-80.4%
unsub-neg80.4%
associate--r+80.4%
+-commutative80.4%
associate--r+80.4%
Simplified80.4%
Taylor expanded in K around 0 92.5%
cos-neg92.5%
Simplified92.5%
Taylor expanded in M around inf 61.9%
unpow261.9%
neg-mul-161.9%
distribute-rgt-neg-in61.9%
Simplified61.9%
if 35 < n Initial program 72.3%
*-commutative72.3%
associate-*r/72.3%
associate--r-72.3%
+-commutative72.3%
associate-+r-72.3%
unsub-neg72.3%
associate--r+72.3%
+-commutative72.3%
associate--r+72.3%
Simplified72.3%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
add-sqr-sqrt21.5%
fabs-sqr21.5%
add-sqr-sqrt100.0%
div-inv100.0%
fma-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
associate--l-100.0%
fma-neg100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in M around inf 83.3%
unpow283.3%
Simplified83.3%
Taylor expanded in n around inf 97.0%
mul-1-neg97.0%
Simplified97.0%
Final simplification52.1%
(FPCore (K m n M l) :precision binary64 (if (<= m -7e-9) (* (cos M) (exp m)) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -7e-9) {
tmp = cos(M) * exp(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 (m <= (-7d-9)) then
tmp = cos(m_1) * exp(m)
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 (m <= -7e-9) {
tmp = Math.cos(M) * Math.exp(m);
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -7e-9: tmp = math.cos(M) * math.exp(m) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -7e-9) tmp = Float64(cos(M) * exp(m)); 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 (m <= -7e-9) tmp = cos(M) * exp(m); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -7e-9], N[(N[Cos[M], $MachinePrecision] * N[Exp[m], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -7 \cdot 10^{-9}:\\
\;\;\;\;\cos M \cdot e^{m}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -6.9999999999999998e-9Initial program 70.9%
*-commutative70.9%
associate-*r/70.9%
associate--r-70.9%
+-commutative70.9%
associate-+r-70.9%
unsub-neg70.9%
associate--r+70.9%
+-commutative70.9%
associate--r+70.9%
Simplified70.9%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt100.0%
div-inv100.0%
fma-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
associate--l-100.0%
fma-neg100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in M around inf 91.1%
unpow291.1%
Simplified91.1%
Taylor expanded in m around inf 98.2%
if -6.9999999999999998e-9 < m Initial program 78.6%
*-commutative78.6%
associate-*r/78.6%
associate--r-78.6%
+-commutative78.6%
associate-+r-78.6%
unsub-neg78.6%
associate--r+78.6%
+-commutative78.6%
associate--r+78.6%
Simplified78.6%
Taylor expanded in K around 0 95.3%
cos-neg95.3%
Simplified95.3%
Taylor expanded in l around inf 32.9%
mul-1-neg32.9%
Simplified32.9%
Final simplification47.0%
(FPCore (K m n M l) :precision binary64 (if (<= n 35.0) (* (cos M) (exp m)) (* (cos M) (exp (- n)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 35.0) {
tmp = cos(M) * exp(m);
} else {
tmp = cos(M) * exp(-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 <= 35.0d0) then
tmp = cos(m_1) * exp(m)
else
tmp = cos(m_1) * exp(-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 <= 35.0) {
tmp = Math.cos(M) * Math.exp(m);
} else {
tmp = Math.cos(M) * Math.exp(-n);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 35.0: tmp = math.cos(M) * math.exp(m) else: tmp = math.cos(M) * math.exp(-n) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 35.0) tmp = Float64(cos(M) * exp(m)); else tmp = Float64(cos(M) * exp(Float64(-n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 35.0) tmp = cos(M) * exp(m); else tmp = cos(M) * exp(-n); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 35.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[m], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-n)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 35:\\
\;\;\;\;\cos M \cdot e^{m}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-n}\\
\end{array}
\end{array}
if n < 35Initial program 78.5%
*-commutative78.5%
associate-*r/78.5%
associate--r-78.5%
+-commutative78.5%
associate-+r-78.5%
unsub-neg78.5%
associate--r+78.5%
+-commutative78.5%
associate--r+78.5%
Simplified78.5%
Taylor expanded in K around 0 95.0%
cos-neg95.0%
Simplified95.0%
expm1-log1p-u95.0%
expm1-udef94.6%
add-sqr-sqrt62.4%
fabs-sqr62.4%
add-sqr-sqrt94.6%
div-inv94.6%
fma-neg94.6%
metadata-eval94.6%
Applied egg-rr94.6%
expm1-def95.0%
expm1-log1p95.0%
associate--l-95.0%
fma-neg95.0%
*-commutative95.0%
+-commutative95.0%
Simplified95.0%
Taylor expanded in M around inf 66.2%
unpow266.2%
Simplified66.2%
Taylor expanded in m around inf 29.1%
if 35 < n Initial program 72.3%
*-commutative72.3%
associate-*r/72.3%
associate--r-72.3%
+-commutative72.3%
associate-+r-72.3%
unsub-neg72.3%
associate--r+72.3%
+-commutative72.3%
associate--r+72.3%
Simplified72.3%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
add-sqr-sqrt21.5%
fabs-sqr21.5%
add-sqr-sqrt100.0%
div-inv100.0%
fma-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
associate--l-100.0%
fma-neg100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in M around inf 83.3%
unpow283.3%
Simplified83.3%
Taylor expanded in n around inf 97.0%
mul-1-neg97.0%
Simplified97.0%
Final simplification46.3%
(FPCore (K m n M l) :precision binary64 (if (<= m -1.85e-37) (* (cos M) (exp m)) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1.85e-37) {
tmp = cos(M) * exp(m);
} 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 (m <= (-1.85d-37)) then
tmp = cos(m_1) * exp(m)
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 (m <= -1.85e-37) {
tmp = Math.cos(M) * Math.exp(m);
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1.85e-37: tmp = math.cos(M) * math.exp(m) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1.85e-37) tmp = Float64(cos(M) * exp(m)); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1.85e-37) tmp = cos(M) * exp(m); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1.85e-37], N[(N[Cos[M], $MachinePrecision] * N[Exp[m], $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.85 \cdot 10^{-37}:\\
\;\;\;\;\cos M \cdot e^{m}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if m < -1.85e-37Initial program 71.7%
*-commutative71.7%
associate-*r/71.7%
associate--r-71.7%
+-commutative71.7%
associate-+r-71.7%
unsub-neg71.7%
associate--r+71.7%
+-commutative71.7%
associate--r+71.7%
Simplified71.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
add-sqr-sqrt20.0%
fabs-sqr20.0%
add-sqr-sqrt100.0%
div-inv100.0%
fma-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
associate--l-100.0%
fma-neg100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in M around inf 85.2%
unpow285.2%
Simplified85.2%
Taylor expanded in m around inf 90.3%
if -1.85e-37 < m Initial program 78.6%
*-commutative78.6%
associate-*r/78.6%
associate--r-78.6%
+-commutative78.6%
associate-+r-78.6%
unsub-neg78.6%
associate--r+78.6%
+-commutative78.6%
associate--r+78.6%
Simplified78.6%
Taylor expanded in K around 0 95.2%
cos-neg95.2%
Simplified95.2%
Taylor expanded in l around inf 33.2%
mul-1-neg33.2%
Simplified33.2%
Taylor expanded in M around 0 33.2%
Final simplification46.6%
(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 76.9%
*-commutative76.9%
associate-*r/76.9%
associate--r-76.9%
+-commutative76.9%
associate-+r-76.9%
unsub-neg76.9%
associate--r+76.9%
+-commutative76.9%
associate--r+76.9%
Simplified76.9%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in l around inf 32.5%
mul-1-neg32.5%
Simplified32.5%
Taylor expanded in M around 0 32.5%
Final simplification32.5%
(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 76.9%
*-commutative76.9%
associate-*r/76.9%
associate--r-76.9%
+-commutative76.9%
associate-+r-76.9%
unsub-neg76.9%
associate--r+76.9%
+-commutative76.9%
associate--r+76.9%
Simplified76.9%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in l around inf 32.5%
mul-1-neg32.5%
Simplified32.5%
Taylor expanded in l around 0 6.1%
Final simplification6.1%
herbie shell --seed 2023230
(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)))))))