
(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 (- (* 0.5 (+ n m)) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((n - m)) - l) - pow(((0.5 * (n + m)) - 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) - (((0.5d0 * (n + m)) - 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(((0.5 * (n + m)) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((n - m)) - l) - math.pow(((0.5 * (n + m)) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(0.5 * Float64(n + m)) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((n - m)) - l) - (((0.5 * (n + m)) - 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[(0.5 * N[(n + m), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(0.5 \cdot \left(n + m\right) - M\right)}^{2}}
\end{array}
Initial program 74.4%
*-commutative74.4%
associate-*r/74.4%
associate--r-74.4%
+-commutative74.4%
associate-+r-74.4%
unsub-neg74.4%
associate--r+74.4%
+-commutative74.4%
associate--r+74.4%
Simplified74.4%
Taylor expanded in K around 0 97.2%
Simplified97.2%
Final simplification97.2%
(FPCore (K m n M l)
:precision binary64
(if (<= n -3.6e-106)
(* (cos M) (exp (* -0.25 (* m m))))
(if (<= n 54.0)
(* (cos M) (exp (- (- (fabs (- n m)) 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 <= -3.6e-106) {
tmp = cos(M) * exp((-0.25 * (m * m)));
} else if (n <= 54.0) {
tmp = cos(M) * exp(((fabs((n - m)) - 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 <= (-3.6d-106)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m * m)))
else if (n <= 54.0d0) then
tmp = cos(m_1) * exp(((abs((n - m)) - 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 <= -3.6e-106) {
tmp = Math.cos(M) * Math.exp((-0.25 * (m * m)));
} else if (n <= 54.0) {
tmp = Math.cos(M) * Math.exp(((Math.abs((n - m)) - 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 <= -3.6e-106: tmp = math.cos(M) * math.exp((-0.25 * (m * m))) elif n <= 54.0: tmp = math.cos(M) * math.exp(((math.fabs((n - m)) - 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 <= -3.6e-106) tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(m * m)))); elseif (n <= 54.0) tmp = Float64(cos(M) * exp(Float64(Float64(abs(Float64(n - m)) - 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 <= -3.6e-106) tmp = cos(M) * exp((-0.25 * (m * m))); elseif (n <= 54.0) tmp = cos(M) * exp(((abs((n - m)) - 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, -3.6e-106], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(n - m), $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 -3.6 \cdot 10^{-106}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;\cos M \cdot e^{\left(\left|n - m\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 < -3.60000000000000013e-106Initial program 69.4%
*-commutative69.4%
associate-*r/69.4%
associate--r-69.4%
+-commutative69.4%
associate-+r-69.4%
unsub-neg69.4%
associate--r+69.4%
+-commutative69.4%
associate--r+69.4%
Simplified69.4%
Taylor expanded in K around 0 98.2%
Simplified98.2%
Taylor expanded in m around inf 55.6%
unpow255.6%
Simplified55.6%
if -3.60000000000000013e-106 < n < 54Initial program 81.4%
*-commutative81.4%
associate-*r/81.4%
associate--r-81.4%
+-commutative81.4%
associate-+r-81.4%
unsub-neg81.4%
associate--r+81.4%
+-commutative81.4%
associate--r+81.4%
Simplified81.4%
Taylor expanded in M around inf 61.8%
unpow261.8%
Simplified61.8%
Taylor expanded in K around 0 69.4%
*-commutative69.4%
Simplified69.4%
if 54 < n Initial program 73.8%
*-commutative73.8%
associate-*r/73.8%
associate--r-73.8%
+-commutative73.8%
associate-+r-73.8%
unsub-neg73.8%
associate--r+73.8%
+-commutative73.8%
associate--r+73.8%
Simplified73.8%
Taylor expanded in K around 0 100.0%
Simplified100.0%
Taylor expanded in n around inf 95.5%
*-commutative95.5%
unpow295.5%
Simplified95.5%
Final simplification70.2%
(FPCore (K m n M l) :precision binary64 (if (<= m -54.0) (* (cos M) (exp (* -0.25 (* m m)))) (* (cos M) (exp (- (- (fabs (- n m)) l) (* (* n n) 0.25))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = cos(M) * exp((-0.25 * (m * m)));
} else {
tmp = cos(M) * exp(((fabs((n - m)) - l) - ((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 (m <= (-54.0d0)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m * m)))
else
tmp = cos(m_1) * exp(((abs((n - m)) - l) - ((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 (m <= -54.0) {
tmp = Math.cos(M) * Math.exp((-0.25 * (m * m)));
} else {
tmp = Math.cos(M) * Math.exp(((Math.abs((n - m)) - l) - ((n * n) * 0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -54.0: tmp = math.cos(M) * math.exp((-0.25 * (m * m))) else: tmp = math.cos(M) * math.exp(((math.fabs((n - m)) - l) - ((n * n) * 0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -54.0) tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(m * m)))); else tmp = Float64(cos(M) * exp(Float64(Float64(abs(Float64(n - m)) - l) - Float64(Float64(n * n) * 0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -54.0) tmp = cos(M) * exp((-0.25 * (m * m))); else tmp = cos(M) * exp(((abs((n - m)) - l) - ((n * n) * 0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -54.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(N[(n * n), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -54:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - \left(n \cdot n\right) \cdot 0.25}\\
\end{array}
\end{array}
if m < -54Initial program 65.1%
*-commutative65.1%
associate-*r/65.1%
associate--r-65.1%
+-commutative65.1%
associate-+r-65.1%
unsub-neg65.1%
associate--r+65.1%
+-commutative65.1%
associate--r+65.1%
Simplified65.1%
Taylor expanded in K around 0 100.0%
Simplified100.0%
Taylor expanded in m around inf 96.9%
unpow296.9%
Simplified96.9%
if -54 < m Initial program 77.5%
*-commutative77.5%
associate-*r/77.5%
associate--r-77.5%
+-commutative77.5%
associate-+r-77.5%
unsub-neg77.5%
associate--r+77.5%
+-commutative77.5%
associate--r+77.5%
Simplified77.5%
Taylor expanded in K around 0 96.2%
Simplified96.2%
Taylor expanded in n around inf 70.5%
*-commutative70.5%
unpow270.5%
Simplified70.5%
Final simplification77.0%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -18.0) (not (<= M 26.5))) (* (cos M) (exp (* M (- M)))) (* (cos M) (exp (* -0.25 (* m m))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -18.0) || !(M <= 26.5)) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = cos(M) * exp((-0.25 * (m * m)));
}
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 <= (-18.0d0)) .or. (.not. (m_1 <= 26.5d0))) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = cos(m_1) * exp(((-0.25d0) * (m * m)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -18.0) || !(M <= 26.5)) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (m * m)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -18.0) or not (M <= 26.5): tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp((-0.25 * (m * m))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -18.0) || !(M <= 26.5)) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(m * m)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -18.0) || ~((M <= 26.5))) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp((-0.25 * (m * m))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -18.0], N[Not[LessEqual[M, 26.5]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -18 \lor \neg \left(M \leq 26.5\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\end{array}
\end{array}
if M < -18 or 26.5 < M 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 99.9%
Simplified99.9%
Taylor expanded in M around inf 96.0%
mul-1-neg96.0%
unpow296.0%
distribute-rgt-neg-in96.0%
Simplified96.0%
if -18 < M < 26.5Initial program 75.3%
*-commutative75.3%
associate-*r/75.3%
associate--r-75.3%
+-commutative75.3%
associate-+r-75.3%
unsub-neg75.3%
associate--r+75.3%
+-commutative75.3%
associate--r+75.3%
Simplified75.3%
Taylor expanded in K around 0 94.5%
Simplified94.5%
Taylor expanded in m around inf 57.7%
unpow257.7%
Simplified57.7%
Final simplification76.4%
(FPCore (K m n M l)
:precision binary64
(if (<= n -3.1e-88)
(* (cos M) (exp (* -0.25 (* m m))))
(if (<= n 54.0)
(* (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 (n <= -3.1e-88) {
tmp = cos(M) * exp((-0.25 * (m * m)));
} else if (n <= 54.0) {
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 (n <= (-3.1d-88)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m * m)))
else if (n <= 54.0d0) 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 (n <= -3.1e-88) {
tmp = Math.cos(M) * Math.exp((-0.25 * (m * m)));
} else if (n <= 54.0) {
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 n <= -3.1e-88: tmp = math.cos(M) * math.exp((-0.25 * (m * m))) elif n <= 54.0: 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 (n <= -3.1e-88) tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(m * m)))); elseif (n <= 54.0) 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 (n <= -3.1e-88) tmp = cos(M) * exp((-0.25 * (m * m))); elseif (n <= 54.0) 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[n, -3.1e-88], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], 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}\;n \leq -3.1 \cdot 10^{-88}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;\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 n < -3.0999999999999998e-88Initial program 70.7%
*-commutative70.7%
associate-*r/70.7%
associate--r-70.7%
+-commutative70.7%
associate-+r-70.7%
unsub-neg70.7%
associate--r+70.7%
+-commutative70.7%
associate--r+70.7%
Simplified70.7%
Taylor expanded in K around 0 99.1%
Simplified99.1%
Taylor expanded in m around inf 56.6%
unpow256.6%
Simplified56.6%
if -3.0999999999999998e-88 < n < 54Initial program 79.5%
*-commutative79.5%
associate-*r/79.5%
associate--r-79.5%
+-commutative79.5%
associate-+r-79.5%
unsub-neg79.5%
associate--r+79.5%
+-commutative79.5%
associate--r+79.5%
Simplified79.5%
Taylor expanded in K around 0 92.7%
Simplified92.7%
Taylor expanded in M around inf 55.7%
mul-1-neg55.7%
unpow255.7%
distribute-rgt-neg-in55.7%
Simplified55.7%
if 54 < n Initial program 73.8%
*-commutative73.8%
associate-*r/73.8%
associate--r-73.8%
+-commutative73.8%
associate-+r-73.8%
unsub-neg73.8%
associate--r+73.8%
+-commutative73.8%
associate--r+73.8%
Simplified73.8%
Taylor expanded in K around 0 100.0%
Simplified100.0%
Taylor expanded in n around inf 95.5%
*-commutative95.5%
unpow295.5%
Simplified95.5%
Final simplification66.2%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -0.012) (not (<= M 2800000000000.0))) (* (cos M) (exp (* M (- M)))) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -0.012) || !(M <= 2800000000000.0)) {
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 ((m_1 <= (-0.012d0)) .or. (.not. (m_1 <= 2800000000000.0d0))) 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 ((M <= -0.012) || !(M <= 2800000000000.0)) {
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 (M <= -0.012) or not (M <= 2800000000000.0): 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 ((M <= -0.012) || !(M <= 2800000000000.0)) 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 ((M <= -0.012) || ~((M <= 2800000000000.0))) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -0.012], N[Not[LessEqual[M, 2800000000000.0]], $MachinePrecision]], 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}\;M \leq -0.012 \lor \neg \left(M \leq 2800000000000\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if M < -0.012 or 2.8e12 < M Initial program 72.5%
*-commutative72.5%
associate-*r/72.5%
associate--r-72.5%
+-commutative72.5%
associate-+r-72.5%
unsub-neg72.5%
associate--r+72.5%
+-commutative72.5%
associate--r+72.5%
Simplified72.5%
Taylor expanded in K around 0 99.9%
Simplified99.9%
Taylor expanded in M around inf 96.0%
mul-1-neg96.0%
unpow296.0%
distribute-rgt-neg-in96.0%
Simplified96.0%
if -0.012 < M < 2.8e12Initial program 76.3%
Simplified76.3%
Taylor expanded in m around inf 53.1%
*-commutative53.1%
unpow253.1%
Simplified53.1%
Taylor expanded in l around inf 36.6%
Taylor expanded in K around 0 46.0%
cos-neg46.0%
Simplified46.0%
Final simplification70.2%
(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}
\\
\frac{\cos M}{e^{\ell}}
\end{array}
Initial program 74.4%
Simplified74.4%
Taylor expanded in m around inf 45.0%
*-commutative45.0%
unpow245.0%
Simplified45.0%
Taylor expanded in l around inf 27.7%
Taylor expanded in K around 0 35.6%
cos-neg35.6%
Simplified35.6%
Final simplification35.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 74.4%
Simplified74.4%
Taylor expanded in m around inf 45.0%
*-commutative45.0%
unpow245.0%
Simplified45.0%
Taylor expanded in l around inf 27.7%
Taylor expanded in K around 0 35.6%
cos-neg35.6%
Simplified35.6%
Taylor expanded in M around 0 34.4%
rec-exp34.4%
Simplified34.4%
Final simplification34.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 74.4%
Simplified74.4%
Taylor expanded in m around inf 45.0%
*-commutative45.0%
unpow245.0%
Simplified45.0%
Taylor expanded in l around inf 27.7%
Taylor expanded in K around 0 35.6%
cos-neg35.6%
Simplified35.6%
Taylor expanded in l around 0 6.1%
Final simplification6.1%
herbie shell --seed 2023207
(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)))))))