
(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 (- 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 76.9%
associate-/l*76.9%
+-commutative76.9%
fabs-sub76.9%
+-commutative76.9%
Simplified76.9%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (K m n M l)
:precision binary64
(if (<= n 3.05e+35)
(*
(cos (- (/ K (/ 2.0 n)) M))
(exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) (- (fabs (- n m)) l))))
(* (cos M) (exp (* -0.25 (pow n 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 3.05e+35) {
tmp = cos(((K / (2.0 / n)) - M)) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (fabs((n - m)) - l)));
} else {
tmp = cos(M) * 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 <= 3.05d+35) then
tmp = cos(((k / (2.0d0 / n)) - m_1)) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + (abs((n - m)) - l)))
else
tmp = cos(m_1) * 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 <= 3.05e+35) {
tmp = Math.cos(((K / (2.0 / n)) - M)) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (Math.abs((n - m)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 3.05e+35: tmp = math.cos(((K / (2.0 / n)) - M)) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (math.fabs((n - m)) - l))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 3.05e+35) tmp = Float64(cos(Float64(Float64(K / Float64(2.0 / n)) - M)) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + Float64(abs(Float64(n - m)) - l)))); else tmp = Float64(cos(M) * 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 <= 3.05e+35) tmp = cos(((K / (2.0 / n)) - M)) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (abs((n - m)) - l))); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 3.05e+35], N[(N[Cos[N[(N[(K / N[(2.0 / n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 3.05 \cdot 10^{+35}:\\
\;\;\;\;\cos \left(\frac{K}{\frac{2}{n}} - M\right) \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + \left(\left|n - m\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 3.04999999999999989e35Initial program 79.4%
associate-/l*79.5%
+-commutative79.5%
fabs-sub79.5%
+-commutative79.5%
Simplified79.5%
Taylor expanded in n around 0 65.9%
+-commutative65.9%
unpow265.9%
distribute-rgt-out68.7%
*-commutative68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in m around 0 79.4%
if 3.04999999999999989e35 < n Initial program 65.2%
associate-/l*65.2%
+-commutative65.2%
fabs-sub65.2%
+-commutative65.2%
Simplified65.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
Final simplification83.1%
(FPCore (K m n M l)
:precision binary64
(if (<= m -5.5e+65)
(exp (* -0.25 (pow m 2.0)))
(*
(cos M)
(exp (+ (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) (- (fabs (- n m)) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -5.5e+65) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (fabs((n - m)) - 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 <= (-5.5d+65)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) + (abs((n - m)) - 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 <= -5.5e+65) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (Math.abs((n - m)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -5.5e+65: tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (math.fabs((n - m)) - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -5.5e+65) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) + Float64(abs(Float64(n - m)) - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -5.5e+65) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (abs((n - m)) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -5.5e+65], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -5.5 \cdot 10^{+65}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) + \left(\left|n - m\right| - \ell\right)}\\
\end{array}
\end{array}
if m < -5.4999999999999996e65Initial program 57.1%
associate-/l*57.1%
+-commutative57.1%
fabs-sub57.1%
+-commutative57.1%
Simplified57.1%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 98.0%
Taylor expanded in M around 0 98.0%
if -5.4999999999999996e65 < m Initial program 81.5%
associate-/l*81.6%
+-commutative81.6%
fabs-sub81.6%
+-commutative81.6%
Simplified81.6%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in m around 0 81.2%
+-commutative81.2%
unpow281.2%
distribute-rgt-out84.6%
*-commutative84.6%
*-commutative84.6%
Simplified84.6%
Final simplification87.2%
(FPCore (K m n M l) :precision binary64 (if (<= m -3.2e+83) (exp (* -0.25 (pow m 2.0))) (* (cos M) (exp (- (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -3.2e+83) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - 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 <= (-3.2d+83)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) - 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 <= -3.2e+83) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -3.2e+83: tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -3.2e+83) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -3.2e+83) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -3.2e+83], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.2 \cdot 10^{+83}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) - \ell}\\
\end{array}
\end{array}
if m < -3.1999999999999999e83Initial program 55.3%
associate-/l*55.3%
+-commutative55.3%
fabs-sub55.3%
+-commutative55.3%
Simplified55.3%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 97.9%
Taylor expanded in M around 0 97.9%
if -3.1999999999999999e83 < m Initial program 81.7%
associate-/l*81.8%
+-commutative81.8%
fabs-sub81.8%
+-commutative81.8%
Simplified81.8%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in m around 0 81.4%
+-commutative81.4%
unpow281.4%
distribute-rgt-out84.7%
*-commutative84.7%
*-commutative84.7%
Simplified84.7%
Taylor expanded in l around inf 85.5%
Final simplification87.8%
(FPCore (K m n M l)
:precision binary64
(if (<= m -0.1)
(exp (* -0.25 (pow m 2.0)))
(if (<= m 2.9e-303)
(* (cos M) (exp (- l)))
(* (cos M) (exp (* m (- M (* n 0.5))))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.1) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 2.9e-303) {
tmp = cos(M) * exp(-l);
} else {
tmp = cos(M) * exp((m * (M - (n * 0.5))));
}
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 <= (-0.1d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 2.9d-303) then
tmp = cos(m_1) * exp(-l)
else
tmp = cos(m_1) * exp((m * (m_1 - (n * 0.5d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.1) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 2.9e-303) {
tmp = Math.cos(M) * Math.exp(-l);
} else {
tmp = Math.cos(M) * Math.exp((m * (M - (n * 0.5))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -0.1: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 2.9e-303: tmp = math.cos(M) * math.exp(-l) else: tmp = math.cos(M) * math.exp((m * (M - (n * 0.5)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -0.1) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 2.9e-303) tmp = Float64(cos(M) * exp(Float64(-l))); else tmp = Float64(cos(M) * exp(Float64(m * Float64(M - Float64(n * 0.5))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -0.1) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= 2.9e-303) tmp = cos(M) * exp(-l); else tmp = cos(M) * exp((m * (M - (n * 0.5)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.1], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 2.9e-303], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.1:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 2.9 \cdot 10^{-303}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(M - n \cdot 0.5\right)}\\
\end{array}
\end{array}
if m < -0.10000000000000001Initial program 61.3%
associate-/l*61.3%
+-commutative61.3%
fabs-sub61.3%
+-commutative61.3%
Simplified61.3%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in m around inf 95.2%
Taylor expanded in M around 0 95.2%
if -0.10000000000000001 < m < 2.90000000000000014e-303Initial program 88.8%
associate-/l*88.8%
+-commutative88.8%
fabs-sub88.8%
+-commutative88.8%
Simplified88.8%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in l around inf 37.1%
mul-1-neg37.1%
Simplified37.1%
if 2.90000000000000014e-303 < m Initial program 77.2%
associate-/l*77.3%
+-commutative77.3%
fabs-sub77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
Simplified97.9%
Taylor expanded in m around 0 72.4%
+-commutative72.4%
unpow272.4%
distribute-rgt-out76.7%
*-commutative76.7%
*-commutative76.7%
Simplified76.7%
Taylor expanded in m around inf 39.0%
Final simplification52.0%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -0.1) (not (<= m 5.5e-78))) (exp (* -0.25 (pow m 2.0))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -0.1) || !(m <= 5.5e-78)) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(M) * exp(-l);
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if ((m <= (-0.1d0)) .or. (.not. (m <= 5.5d-78))) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(m_1) * exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -0.1) || !(m <= 5.5e-78)) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -0.1) or not (m <= 5.5e-78): tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -0.1) || !(m <= 5.5e-78)) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -0.1) || ~((m <= 5.5e-78))) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -0.1], N[Not[LessEqual[m, 5.5e-78]], $MachinePrecision]], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.1 \lor \neg \left(m \leq 5.5 \cdot 10^{-78}\right):\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -0.10000000000000001 or 5.50000000000000017e-78 < m Initial program 69.0%
associate-/l*69.2%
+-commutative69.2%
fabs-sub69.2%
+-commutative69.2%
Simplified69.2%
Taylor expanded in K around 0 98.0%
cos-neg98.0%
Simplified98.0%
Taylor expanded in m around inf 88.6%
Taylor expanded in M around 0 88.6%
if -0.10000000000000001 < m < 5.50000000000000017e-78Initial program 85.5%
associate-/l*85.5%
+-commutative85.5%
fabs-sub85.5%
+-commutative85.5%
Simplified85.5%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in l around inf 40.1%
mul-1-neg40.1%
Simplified40.1%
Final simplification65.5%
(FPCore (K m n M l) :precision binary64 (exp (* -0.25 (pow m 2.0))))
double code(double K, double m, double n, double M, double l) {
return exp((-0.25 * pow(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 = exp(((-0.25d0) * (m ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((-0.25 * Math.pow(m, 2.0)));
}
def code(K, m, n, M, l): return math.exp((-0.25 * math.pow(m, 2.0)))
function code(K, m, n, M, l) return exp(Float64(-0.25 * (m ^ 2.0))) end
function tmp = code(K, m, n, M, l) tmp = exp((-0.25 * (m ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{-0.25 \cdot {m}^{2}}
\end{array}
Initial program 76.9%
associate-/l*76.9%
+-commutative76.9%
fabs-sub76.9%
+-commutative76.9%
Simplified76.9%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in m around inf 50.5%
Taylor expanded in M around 0 50.5%
Final simplification50.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%
associate-/l*76.9%
+-commutative76.9%
fabs-sub76.9%
+-commutative76.9%
Simplified76.9%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in m around inf 50.5%
Taylor expanded in m around 0 6.2%
Final simplification6.2%
herbie shell --seed 2023318
(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)))))))