
(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 (- n m)) (+ (pow (- (/ (+ m n) 2.0) M) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((n - m)) - (pow((((m + n) / 2.0) - M), 2.0) + 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((abs((n - m)) - (((((m + n) / 2.0d0) - m_1) ** 2.0d0) + l)))
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)) - (Math.pow((((m + n) / 2.0) - M), 2.0) + l)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((n - m)) - (math.pow((((m + n) / 2.0) - M), 2.0) + l)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64((Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0) + l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((n - m)) - (((((m + n) / 2.0) - M) ^ 2.0) + l))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 77.4%
+-commutative77.4%
+-commutative77.4%
fabs-sub77.4%
associate-/l*77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Final simplification97.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= m -1.95e+21)
(* (cos M) (exp (* -0.25 (* m m))))
(if (<= m -1.85e-206)
(* (cos M) (exp (- t_0 (+ l (* M M)))))
(* (cos M) (exp (- t_0 (+ l (* (* n n) 0.25)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (m <= -1.95e+21) {
tmp = cos(M) * exp((-0.25 * (m * m)));
} else if (m <= -1.85e-206) {
tmp = cos(M) * exp((t_0 - (l + (M * M))));
} else {
tmp = cos(M) * exp((t_0 - (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) :: t_0
real(8) :: tmp
t_0 = abs((n - m))
if (m <= (-1.95d+21)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m * m)))
else if (m <= (-1.85d-206)) then
tmp = cos(m_1) * exp((t_0 - (l + (m_1 * m_1))))
else
tmp = cos(m_1) * exp((t_0 - (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 t_0 = Math.abs((n - m));
double tmp;
if (m <= -1.95e+21) {
tmp = Math.cos(M) * Math.exp((-0.25 * (m * m)));
} else if (m <= -1.85e-206) {
tmp = Math.cos(M) * Math.exp((t_0 - (l + (M * M))));
} else {
tmp = Math.cos(M) * Math.exp((t_0 - (l + ((n * n) * 0.25))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if m <= -1.95e+21: tmp = math.cos(M) * math.exp((-0.25 * (m * m))) elif m <= -1.85e-206: tmp = math.cos(M) * math.exp((t_0 - (l + (M * M)))) else: tmp = math.cos(M) * math.exp((t_0 - (l + ((n * n) * 0.25)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (m <= -1.95e+21) tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(m * m)))); elseif (m <= -1.85e-206) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(l + Float64(M * M))))); else tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(l + Float64(Float64(n * n) * 0.25))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (m <= -1.95e+21) tmp = cos(M) * exp((-0.25 * (m * m))); elseif (m <= -1.85e-206) tmp = cos(M) * exp((t_0 - (l + (M * M)))); else tmp = cos(M) * exp((t_0 - (l + ((n * n) * 0.25)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -1.95e+21], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -1.85e-206], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(l + N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(l + N[(N[(n * n), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;m \leq -1.95 \cdot 10^{+21}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;m \leq -1.85 \cdot 10^{-206}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(\ell + M \cdot M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(\ell + \left(n \cdot n\right) \cdot 0.25\right)}\\
\end{array}
\end{array}
if m < -1.95e21Initial program 74.1%
Taylor expanded in m around inf 65.7%
*-commutative65.7%
unpow265.7%
Simplified65.7%
Taylor expanded in K around 0 86.4%
cos-neg86.4%
fabs-sub86.4%
*-commutative86.4%
unpow286.4%
Simplified86.4%
Taylor expanded in m around inf 98.3%
unpow298.3%
Simplified98.3%
if -1.95e21 < m < -1.84999999999999999e-206Initial program 82.5%
+-commutative82.5%
+-commutative82.5%
fabs-sub82.5%
associate-/l*85.0%
+-commutative85.0%
Simplified85.0%
Taylor expanded in K around 0 95.0%
cos-neg95.0%
Simplified95.0%
Taylor expanded in M around inf 80.3%
unpow280.3%
Simplified80.3%
if -1.84999999999999999e-206 < m Initial program 77.3%
+-commutative77.3%
+-commutative77.3%
fabs-sub77.3%
associate-/l*76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in n around inf 64.1%
*-commutative64.1%
unpow264.1%
Simplified64.1%
Final simplification74.3%
(FPCore (K m n M l)
:precision binary64
(if (<= n -5.6e-82)
(* (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 <= -5.6e-82) {
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 <= (-5.6d-82)) 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 <= -5.6e-82) {
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 <= -5.6e-82: 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 <= -5.6e-82) tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(m * m)))); elseif (n <= 54.0) tmp = Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64(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 <= -5.6e-82) 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, -5.6e-82], 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[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(M * M), $MachinePrecision]), $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 -5.6 \cdot 10^{-82}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;\cos M \cdot e^{\left|n - m\right| - \left(\ell + M \cdot M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < -5.60000000000000049e-82Initial program 74.7%
Taylor expanded in m around inf 37.5%
*-commutative37.5%
unpow237.5%
Simplified37.5%
Taylor expanded in K around 0 50.3%
cos-neg50.3%
fabs-sub50.3%
*-commutative50.3%
unpow250.3%
Simplified50.3%
Taylor expanded in m around inf 53.2%
unpow253.2%
Simplified53.2%
if -5.60000000000000049e-82 < n < 54Initial program 83.1%
+-commutative83.1%
+-commutative83.1%
fabs-sub83.1%
associate-/l*83.1%
+-commutative83.1%
Simplified83.1%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in M around inf 72.0%
unpow272.0%
Simplified72.0%
if 54 < n Initial program 71.9%
+-commutative71.9%
+-commutative71.9%
fabs-sub71.9%
associate-/l*71.9%
+-commutative71.9%
Simplified71.9%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in n around inf 90.7%
*-commutative90.7%
unpow290.7%
Simplified90.7%
Taylor expanded in n around inf 96.9%
*-commutative96.9%
unpow296.9%
Simplified96.9%
Final simplification71.9%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 8.5e-197)
(* (cos M) (exp (- t_0 (+ l (* (* m m) 0.25)))))
(if (<= n 54.0)
(* (cos M) (exp (- t_0 (+ l (* M M)))))
(* (cos M) (exp (* -0.25 (* n n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= 8.5e-197) {
tmp = cos(M) * exp((t_0 - (l + ((m * m) * 0.25))));
} else if (n <= 54.0) {
tmp = cos(M) * exp((t_0 - (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) :: t_0
real(8) :: tmp
t_0 = abs((n - m))
if (n <= 8.5d-197) then
tmp = cos(m_1) * exp((t_0 - (l + ((m * m) * 0.25d0))))
else if (n <= 54.0d0) then
tmp = cos(m_1) * exp((t_0 - (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 t_0 = Math.abs((n - m));
double tmp;
if (n <= 8.5e-197) {
tmp = Math.cos(M) * Math.exp((t_0 - (l + ((m * m) * 0.25))));
} else if (n <= 54.0) {
tmp = Math.cos(M) * Math.exp((t_0 - (l + (M * M))));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if n <= 8.5e-197: tmp = math.cos(M) * math.exp((t_0 - (l + ((m * m) * 0.25)))) elif n <= 54.0: tmp = math.cos(M) * math.exp((t_0 - (l + (M * M)))) else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= 8.5e-197) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(l + Float64(Float64(m * m) * 0.25))))); elseif (n <= 54.0) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(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) t_0 = abs((n - m)); tmp = 0.0; if (n <= 8.5e-197) tmp = cos(M) * exp((t_0 - (l + ((m * m) * 0.25)))); elseif (n <= 54.0) tmp = cos(M) * exp((t_0 - (l + (M * M)))); else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 8.5e-197], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(l + N[(N[(m * m), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(l + N[(M * M), $MachinePrecision]), $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}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 8.5 \cdot 10^{-197}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(\ell + \left(m \cdot m\right) \cdot 0.25\right)}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(\ell + M \cdot M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 8.5e-197Initial program 80.8%
Taylor expanded in m around inf 52.7%
*-commutative52.7%
unpow252.7%
Simplified52.7%
Taylor expanded in K around 0 64.0%
cos-neg64.0%
fabs-sub64.0%
*-commutative64.0%
unpow264.0%
Simplified64.0%
if 8.5e-197 < n < 54Initial program 73.9%
+-commutative73.9%
+-commutative73.9%
fabs-sub73.9%
associate-/l*73.9%
+-commutative73.9%
Simplified73.9%
Taylor expanded in K around 0 91.0%
cos-neg91.0%
Simplified91.0%
Taylor expanded in M around inf 72.3%
unpow272.3%
Simplified72.3%
if 54 < n Initial program 71.9%
+-commutative71.9%
+-commutative71.9%
fabs-sub71.9%
associate-/l*71.9%
+-commutative71.9%
Simplified71.9%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in n around inf 90.7%
*-commutative90.7%
unpow290.7%
Simplified90.7%
Taylor expanded in n around inf 96.9%
*-commutative96.9%
unpow296.9%
Simplified96.9%
Final simplification73.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -1.75e-9) (not (<= M 27.0))) (* (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 <= -1.75e-9) || !(M <= 27.0)) {
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 <= (-1.75d-9)) .or. (.not. (m_1 <= 27.0d0))) 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 <= -1.75e-9) || !(M <= 27.0)) {
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 <= -1.75e-9) or not (M <= 27.0): 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 <= -1.75e-9) || !(M <= 27.0)) 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 <= -1.75e-9) || ~((M <= 27.0))) 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, -1.75e-9], N[Not[LessEqual[M, 27.0]], $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 -1.75 \cdot 10^{-9} \lor \neg \left(M \leq 27\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 < -1.75e-9 or 27 < M Initial program 79.0%
+-commutative79.0%
+-commutative79.0%
fabs-sub79.0%
associate-/l*79.0%
+-commutative79.0%
Simplified79.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 84.1%
unpow284.1%
Simplified84.1%
Taylor expanded in M around inf 98.4%
mul-1-neg98.4%
unpow298.4%
distribute-rgt-neg-out98.4%
Simplified98.4%
if -1.75e-9 < M < 27Initial program 75.9%
Taylor expanded in m around inf 54.3%
*-commutative54.3%
unpow254.3%
Simplified54.3%
Taylor expanded in K around 0 66.5%
cos-neg66.5%
fabs-sub66.5%
*-commutative66.5%
unpow266.5%
Simplified66.5%
Taylor expanded in m around inf 59.9%
unpow259.9%
Simplified59.9%
Final simplification78.6%
(FPCore (K m n M l)
:precision binary64
(if (<= n 3.5e-172)
(* (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.5e-172) {
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.5d-172) 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.5e-172) {
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.5e-172: 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.5e-172) 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.5e-172) 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.5e-172], 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.5 \cdot 10^{-172}:\\
\;\;\;\;\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.50000000000000029e-172Initial program 81.5%
Taylor expanded in m around inf 53.9%
*-commutative53.9%
unpow253.9%
Simplified53.9%
Taylor expanded in K around 0 64.8%
cos-neg64.8%
fabs-sub64.8%
*-commutative64.8%
unpow264.8%
Simplified64.8%
Taylor expanded in m around inf 59.8%
unpow259.8%
Simplified59.8%
if 3.50000000000000029e-172 < n < 54Initial program 69.6%
+-commutative69.6%
+-commutative69.6%
fabs-sub69.6%
associate-/l*72.4%
+-commutative72.4%
Simplified72.4%
Taylor expanded in K around 0 89.5%
cos-neg89.5%
Simplified89.5%
Taylor expanded in M around inf 70.4%
unpow270.4%
Simplified70.4%
Taylor expanded in M around inf 60.0%
mul-1-neg60.0%
unpow260.0%
distribute-rgt-neg-out60.0%
Simplified60.0%
if 54 < n Initial program 71.9%
+-commutative71.9%
+-commutative71.9%
fabs-sub71.9%
associate-/l*71.9%
+-commutative71.9%
Simplified71.9%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in n around inf 90.7%
*-commutative90.7%
unpow290.7%
Simplified90.7%
Taylor expanded in n around inf 96.9%
*-commutative96.9%
unpow296.9%
Simplified96.9%
Final simplification69.1%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -27.0) (not (<= M 2.5e-5))) (* (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 <= -27.0) || !(M <= 2.5e-5)) {
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 <= (-27.0d0)) .or. (.not. (m_1 <= 2.5d-5))) 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 <= -27.0) || !(M <= 2.5e-5)) {
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 <= -27.0) or not (M <= 2.5e-5): 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 <= -27.0) || !(M <= 2.5e-5)) tmp = Float64(cos(M) * exp(Float64(M * Float64(-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 <= -27.0) || ~((M <= 2.5e-5))) 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, -27.0], N[Not[LessEqual[M, 2.5e-5]], $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 -27 \lor \neg \left(M \leq 2.5 \cdot 10^{-5}\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if M < -27 or 2.50000000000000012e-5 < M Initial program 80.6%
+-commutative80.6%
+-commutative80.6%
fabs-sub80.6%
associate-/l*80.6%
+-commutative80.6%
Simplified80.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 84.1%
unpow284.1%
Simplified84.1%
Taylor expanded in M around inf 98.4%
mul-1-neg98.4%
unpow298.4%
distribute-rgt-neg-out98.4%
Simplified98.4%
if -27 < M < 2.50000000000000012e-5Initial program 74.4%
+-commutative74.4%
+-commutative74.4%
fabs-sub74.4%
associate-/l*74.4%
+-commutative74.4%
Simplified74.4%
Taylor expanded in K around 0 94.9%
cos-neg94.9%
Simplified94.9%
Taylor expanded in M around inf 32.2%
unpow232.2%
Simplified32.2%
Taylor expanded in l around inf 41.8%
mul-1-neg41.8%
Simplified41.8%
Final simplification69.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(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{-\ell}
\end{array}
Initial program 77.4%
+-commutative77.4%
+-commutative77.4%
fabs-sub77.4%
associate-/l*77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in M around inf 57.4%
unpow257.4%
Simplified57.4%
Taylor expanded in l around inf 33.5%
mul-1-neg33.5%
Simplified33.5%
Final simplification33.5%
(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 77.4%
+-commutative77.4%
+-commutative77.4%
fabs-sub77.4%
associate-/l*77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in M around inf 57.4%
unpow257.4%
Simplified57.4%
Taylor expanded in l around inf 33.5%
mul-1-neg33.5%
Simplified33.5%
Taylor expanded in M around 0 33.5%
Final simplification33.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 77.4%
+-commutative77.4%
+-commutative77.4%
fabs-sub77.4%
associate-/l*77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in M around inf 57.4%
unpow257.4%
Simplified57.4%
Taylor expanded in l around inf 33.5%
mul-1-neg33.5%
Simplified33.5%
Taylor expanded in l around 0 6.7%
Final simplification6.7%
herbie shell --seed 2023263
(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)))))))