
(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 (* (cos M) (exp (- (- (fabs (- n m)) 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((n - m)) - 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((n - m)) - 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((n - m)) - 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((n - m)) - 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(n - m)) - 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((n - m)) - 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[(n - m), $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|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 78.0%
associate-/l*77.9%
+-commutative77.9%
fabs-sub77.9%
+-commutative77.9%
Simplified77.9%
Taylor expanded in K around 0 96.2%
cos-neg96.2%
Simplified96.2%
Final simplification96.2%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -1400000.0) (not (<= M 2.1e+16))) (* (cos M) (exp (- (pow M 2.0)))) (exp (- (fabs (- n m)) (+ l (* 0.25 (pow (+ m n) 2.0)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -1400000.0) || !(M <= 2.1e+16)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = exp((fabs((n - m)) - (l + (0.25 * pow((m + 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 ((m_1 <= (-1400000.0d0)) .or. (.not. (m_1 <= 2.1d+16))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = exp((abs((n - m)) - (l + (0.25d0 * ((m + 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 ((M <= -1400000.0) || !(M <= 2.1e+16)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp((Math.abs((n - m)) - (l + (0.25 * Math.pow((m + n), 2.0)))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -1400000.0) or not (M <= 2.1e+16): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.exp((math.fabs((n - m)) - (l + (0.25 * math.pow((m + n), 2.0))))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -1400000.0) || !(M <= 2.1e+16)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = exp(Float64(abs(Float64(n - m)) - Float64(l + Float64(0.25 * (Float64(m + n) ^ 2.0))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -1400000.0) || ~((M <= 2.1e+16))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = exp((abs((n - m)) - (l + (0.25 * ((m + n) ^ 2.0))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -1400000.0], N[Not[LessEqual[M, 2.1e+16]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -1400000 \lor \neg \left(M \leq 2.1 \cdot 10^{+16}\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left|n - m\right| - \left(\ell + 0.25 \cdot {\left(m + n\right)}^{2}\right)}\\
\end{array}
\end{array}
if M < -1.4e6 or 2.1e16 < M Initial program 76.6%
associate-/l*76.6%
+-commutative76.6%
fabs-sub76.6%
+-commutative76.6%
Simplified76.6%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in M around inf 96.9%
mul-1-neg96.9%
Simplified96.9%
if -1.4e6 < M < 2.1e16Initial program 79.5%
associate-/l*79.2%
+-commutative79.2%
fabs-sub79.2%
+-commutative79.2%
Simplified79.2%
Taylor expanded in K around 0 88.6%
cos-neg88.6%
associate-*r*88.6%
sin-neg88.6%
Simplified88.6%
Taylor expanded in M around 0 94.1%
Final simplification95.5%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -1000000.0) (not (<= M 27.0))) (* (cos M) (exp (- (pow M 2.0)))) (exp (+ (- n (- m l)) (* (pow (+ m n) 2.0) -0.25)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -1000000.0) || !(M <= 27.0)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = exp(((n - (m - l)) + (pow((m + n), 2.0) * -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 <= (-1000000.0d0)) .or. (.not. (m_1 <= 27.0d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = exp(((n - (m - l)) + (((m + n) ** 2.0d0) * (-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 <= -1000000.0) || !(M <= 27.0)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp(((n - (m - l)) + (Math.pow((m + n), 2.0) * -0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -1000000.0) or not (M <= 27.0): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.exp(((n - (m - l)) + (math.pow((m + n), 2.0) * -0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -1000000.0) || !(M <= 27.0)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = exp(Float64(Float64(n - Float64(m - l)) + Float64((Float64(m + n) ^ 2.0) * -0.25))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -1000000.0) || ~((M <= 27.0))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = exp(((n - (m - l)) + (((m + n) ^ 2.0) * -0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -1000000.0], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(n - N[(m - l), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -1000000 \lor \neg \left(M \leq 27\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(n - \left(m - \ell\right)\right) + {\left(m + n\right)}^{2} \cdot -0.25}\\
\end{array}
\end{array}
if M < -1e6 or 27 < M Initial program 76.7%
associate-/l*76.7%
+-commutative76.7%
fabs-sub76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in K around 0 98.5%
cos-neg98.5%
Simplified98.5%
Taylor expanded in M around inf 96.3%
mul-1-neg96.3%
Simplified96.3%
if -1e6 < M < 27Initial program 79.5%
associate-/l*79.2%
+-commutative79.2%
fabs-sub79.2%
+-commutative79.2%
Simplified79.2%
Taylor expanded in K around 0 88.9%
cos-neg88.9%
associate-*r*88.9%
sin-neg88.9%
Simplified88.9%
Taylor expanded in M around 0 93.8%
associate--r+93.8%
sub-neg93.8%
sub-neg93.8%
add-sqr-sqrt48.8%
fabs-sqr48.8%
add-sqr-sqrt93.8%
add-sqr-sqrt48.9%
sqrt-unprod70.4%
sqr-neg70.4%
sqrt-unprod36.9%
add-sqr-sqrt82.3%
+-commutative82.3%
Applied egg-rr82.3%
associate-+l-82.3%
distribute-lft-neg-in82.3%
metadata-eval82.3%
Simplified82.3%
Final simplification89.6%
(FPCore (K m n M l) :precision binary64 (if (<= l 740.0) (exp (+ (- n (- m l)) (* (pow (+ m n) 2.0) -0.25))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 740.0) {
tmp = exp(((n - (m - l)) + (pow((m + n), 2.0) * -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 (l <= 740.0d0) then
tmp = exp(((n - (m - l)) + (((m + n) ** 2.0d0) * (-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 (l <= 740.0) {
tmp = Math.exp(((n - (m - l)) + (Math.pow((m + n), 2.0) * -0.25)));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 740.0: tmp = math.exp(((n - (m - l)) + (math.pow((m + n), 2.0) * -0.25))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 740.0) tmp = exp(Float64(Float64(n - Float64(m - l)) + Float64((Float64(m + n) ^ 2.0) * -0.25))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 740.0) tmp = exp(((n - (m - l)) + (((m + n) ^ 2.0) * -0.25))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 740.0], N[Exp[N[(N[(n - N[(m - l), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 740:\\
\;\;\;\;e^{\left(n - \left(m - \ell\right)\right) + {\left(m + n\right)}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < 740Initial program 77.1%
associate-/l*76.9%
+-commutative76.9%
fabs-sub76.9%
+-commutative76.9%
Simplified76.9%
Taylor expanded in K around 0 82.6%
cos-neg82.6%
associate-*r*82.6%
sin-neg82.6%
Simplified82.6%
Taylor expanded in M around 0 81.9%
associate--r+81.9%
sub-neg81.9%
sub-neg81.9%
add-sqr-sqrt37.0%
fabs-sqr37.0%
add-sqr-sqrt81.9%
add-sqr-sqrt55.8%
sqrt-unprod71.5%
sqr-neg71.5%
sqrt-unprod26.1%
add-sqr-sqrt83.3%
+-commutative83.3%
Applied egg-rr83.3%
associate-+l-83.3%
distribute-lft-neg-in83.3%
metadata-eval83.3%
Simplified83.3%
if 740 < l Initial program 81.0%
associate-/l*81.0%
+-commutative81.0%
fabs-sub81.0%
+-commutative81.0%
Simplified81.0%
Taylor expanded in K around 0 84.1%
cos-neg84.1%
associate-*r*84.1%
sin-neg84.1%
Simplified84.1%
Taylor expanded in M around 0 100.0%
Taylor expanded in l around inf 100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification87.4%
(FPCore (K m n M l) :precision binary64 (if (<= l -3.5e-9) (exp l) (if (<= l 0.0072) (exp (* -0.25 (pow n 2.0))) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -3.5e-9) {
tmp = exp(l);
} else if (l <= 0.0072) {
tmp = exp((-0.25 * pow(n, 2.0)));
} 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 (l <= (-3.5d-9)) then
tmp = exp(l)
else if (l <= 0.0072d0) then
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
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 (l <= -3.5e-9) {
tmp = Math.exp(l);
} else if (l <= 0.0072) {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -3.5e-9: tmp = math.exp(l) elif l <= 0.0072: tmp = math.exp((-0.25 * math.pow(n, 2.0))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -3.5e-9) tmp = exp(l); elseif (l <= 0.0072) tmp = exp(Float64(-0.25 * (n ^ 2.0))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -3.5e-9) tmp = exp(l); elseif (l <= 0.0072) tmp = exp((-0.25 * (n ^ 2.0))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -3.5e-9], N[Exp[l], $MachinePrecision], If[LessEqual[l, 0.0072], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -3.5 \cdot 10^{-9}:\\
\;\;\;\;e^{\ell}\\
\mathbf{elif}\;\ell \leq 0.0072:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < -3.4999999999999999e-9Initial program 63.5%
associate-/l*63.5%
+-commutative63.5%
fabs-sub63.5%
+-commutative63.5%
Simplified63.5%
Taylor expanded in K around 0 71.4%
cos-neg71.4%
associate-*r*71.4%
sin-neg71.4%
Simplified71.4%
Taylor expanded in M around 0 73.3%
associate--r+73.3%
sub-neg73.3%
sub-neg73.3%
add-sqr-sqrt33.4%
fabs-sqr33.4%
add-sqr-sqrt73.3%
add-sqr-sqrt73.3%
sqrt-unprod41.6%
sqr-neg41.6%
sqrt-unprod0.0%
add-sqr-sqrt78.2%
+-commutative78.2%
Applied egg-rr78.2%
associate-+l-78.2%
distribute-lft-neg-in78.2%
metadata-eval78.2%
Simplified78.2%
Taylor expanded in l around inf 72.0%
if -3.4999999999999999e-9 < l < 0.0071999999999999998Initial program 84.0%
associate-/l*83.8%
+-commutative83.8%
fabs-sub83.8%
+-commutative83.8%
Simplified83.8%
Taylor expanded in K around 0 88.5%
cos-neg88.5%
associate-*r*88.5%
sin-neg88.5%
Simplified88.5%
Taylor expanded in M around 0 86.4%
Taylor expanded in n around inf 61.2%
if 0.0071999999999999998 < l Initial program 80.3%
associate-/l*80.3%
+-commutative80.3%
fabs-sub80.3%
+-commutative80.3%
Simplified80.3%
Taylor expanded in K around 0 83.3%
cos-neg83.3%
associate-*r*83.3%
sin-neg83.3%
Simplified83.3%
Taylor expanded in M around 0 98.7%
Taylor expanded in l around inf 97.2%
neg-mul-197.2%
Simplified97.2%
Final simplification73.0%
(FPCore (K m n M l) :precision binary64 (if (<= n 55.0) (exp (* -0.25 (pow 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 <= 55.0) {
tmp = exp((-0.25 * pow(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 <= 55.0d0) then
tmp = exp(((-0.25d0) * (m ** 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 <= 55.0) {
tmp = Math.exp((-0.25 * Math.pow(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 <= 55.0: tmp = math.exp((-0.25 * math.pow(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 <= 55.0) tmp = exp(Float64(-0.25 * (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 <= 55.0) tmp = exp((-0.25 * (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, 55.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $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 55:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 55Initial program 79.7%
associate-/l*79.5%
+-commutative79.5%
fabs-sub79.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in K around 0 84.5%
cos-neg84.5%
associate-*r*84.5%
sin-neg84.5%
Simplified84.5%
Taylor expanded in M around 0 83.8%
Taylor expanded in m around inf 55.8%
*-commutative55.8%
Simplified55.8%
if 55 < n Initial program 72.4%
associate-/l*72.4%
+-commutative72.4%
fabs-sub72.4%
+-commutative72.4%
Simplified72.4%
Taylor expanded in K around 0 77.6%
cos-neg77.6%
associate-*r*77.6%
sin-neg77.6%
Simplified77.6%
Taylor expanded in M around 0 94.9%
Taylor expanded in n around inf 94.9%
Final simplification64.7%
(FPCore (K m n M l) :precision binary64 (if (<= l -1.16e-9) (exp l) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -1.16e-9) {
tmp = exp(l);
} 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 (l <= (-1.16d-9)) then
tmp = exp(l)
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 (l <= -1.16e-9) {
tmp = Math.exp(l);
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -1.16e-9: tmp = math.exp(l) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -1.16e-9) tmp = exp(l); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -1.16e-9) tmp = exp(l); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -1.16e-9], N[Exp[l], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.16 \cdot 10^{-9}:\\
\;\;\;\;e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < -1.15999999999999992e-9Initial program 64.1%
associate-/l*64.1%
+-commutative64.1%
fabs-sub64.1%
+-commutative64.1%
Simplified64.1%
Taylor expanded in K around 0 71.9%
cos-neg71.9%
associate-*r*71.9%
sin-neg71.9%
Simplified71.9%
Taylor expanded in M around 0 73.7%
associate--r+73.7%
sub-neg73.7%
sub-neg73.7%
add-sqr-sqrt32.9%
fabs-sqr32.9%
add-sqr-sqrt73.7%
add-sqr-sqrt73.7%
sqrt-unprod42.5%
sqr-neg42.5%
sqrt-unprod0.0%
add-sqr-sqrt78.5%
+-commutative78.5%
Applied egg-rr78.5%
associate-+l-78.5%
distribute-lft-neg-in78.5%
metadata-eval78.5%
Simplified78.5%
Taylor expanded in l around inf 70.9%
if -1.15999999999999992e-9 < l Initial program 82.7%
associate-/l*82.5%
+-commutative82.5%
fabs-sub82.5%
+-commutative82.5%
Simplified82.5%
Taylor expanded in K around 0 86.7%
cos-neg86.7%
associate-*r*86.7%
sin-neg86.7%
Simplified86.7%
Taylor expanded in M around 0 90.5%
Taylor expanded in l around inf 39.6%
neg-mul-139.6%
Simplified39.6%
Final simplification47.4%
(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 78.0%
associate-/l*77.9%
+-commutative77.9%
fabs-sub77.9%
+-commutative77.9%
Simplified77.9%
Taylor expanded in K around 0 96.2%
cos-neg96.2%
Simplified96.2%
Taylor expanded in m around inf 54.1%
*-commutative54.1%
Simplified54.1%
Taylor expanded in m around 0 5.9%
+-commutative5.9%
*-commutative5.9%
Simplified5.9%
Taylor expanded in m around 0 6.4%
Final simplification6.4%
(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(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 78.0%
associate-/l*77.9%
+-commutative77.9%
fabs-sub77.9%
+-commutative77.9%
Simplified77.9%
Taylor expanded in K around 0 83.0%
cos-neg83.0%
associate-*r*83.0%
sin-neg83.0%
Simplified83.0%
Taylor expanded in M around 0 86.3%
associate--r+86.3%
sub-neg86.3%
sub-neg86.3%
add-sqr-sqrt39.6%
fabs-sqr39.6%
add-sqr-sqrt86.3%
add-sqr-sqrt42.1%
sqrt-unprod60.4%
sqr-neg60.4%
sqrt-unprod35.8%
add-sqr-sqrt78.9%
+-commutative78.9%
Applied egg-rr78.9%
associate-+l-78.9%
distribute-lft-neg-in78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in l around inf 23.0%
Final simplification23.0%
herbie shell --seed 2024024
(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)))))))