
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (fabs (- m n)) (+ (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((m - n)) - (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((m - n)) - (((((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((m - n)) - (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((m - n)) - (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(m - n)) - 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((m - n)) - (((((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[(m - n), $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|m - n\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 79.2%
associate-/l*78.8%
associate--r-78.8%
Simplified78.8%
Taylor expanded in K around 0 96.0%
cos-neg96.0%
Simplified96.0%
Final simplification96.0%
(FPCore (K m n M l) :precision binary64 (/ (cos M) (exp (+ (pow (- (* 0.5 (+ m n)) M) 2.0) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos(M) / exp((pow(((0.5 * (m + n)) - 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(m_1) / exp(((((0.5d0 * (m + n)) - 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(M) / Math.exp((Math.pow(((0.5 * (m + n)) - M), 2.0) + (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos(M) / math.exp((math.pow(((0.5 * (m + n)) - M), 2.0) + (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(M) / exp(Float64((Float64(Float64(0.5 * Float64(m + n)) - M) ^ 2.0) + Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) / exp(((((0.5 * (m + n)) - M) ^ 2.0) + (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(N[Power[N[(N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos M}{e^{{\left(0.5 \cdot \left(m + n\right) - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}
\end{array}
Initial program 79.2%
Simplified79.2%
Taylor expanded in K around 0 96.0%
Simplified96.0%
Final simplification96.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (or (<= M -6.5e+124) (not (<= M 1.15e+87)))
(/ (cos M) (exp (+ (- l t_0) (* M M))))
(exp (- t_0 (+ l (* 0.25 (pow (+ m n) 2.0))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if ((M <= -6.5e+124) || !(M <= 1.15e+87)) {
tmp = cos(M) / exp(((l - t_0) + (M * M)));
} else {
tmp = exp((t_0 - (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) :: t_0
real(8) :: tmp
t_0 = abs((m - n))
if ((m_1 <= (-6.5d+124)) .or. (.not. (m_1 <= 1.15d+87))) then
tmp = cos(m_1) / exp(((l - t_0) + (m_1 * m_1)))
else
tmp = exp((t_0 - (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 t_0 = Math.abs((m - n));
double tmp;
if ((M <= -6.5e+124) || !(M <= 1.15e+87)) {
tmp = Math.cos(M) / Math.exp(((l - t_0) + (M * M)));
} else {
tmp = Math.exp((t_0 - (l + (0.25 * Math.pow((m + n), 2.0)))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if (M <= -6.5e+124) or not (M <= 1.15e+87): tmp = math.cos(M) / math.exp(((l - t_0) + (M * M))) else: tmp = math.exp((t_0 - (l + (0.25 * math.pow((m + n), 2.0))))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if ((M <= -6.5e+124) || !(M <= 1.15e+87)) tmp = Float64(cos(M) / exp(Float64(Float64(l - t_0) + Float64(M * M)))); else tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * (Float64(m + n) ^ 2.0))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if ((M <= -6.5e+124) || ~((M <= 1.15e+87))) tmp = cos(M) / exp(((l - t_0) + (M * M))); else tmp = exp((t_0 - (l + (0.25 * ((m + n) ^ 2.0))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[M, -6.5e+124], N[Not[LessEqual[M, 1.15e+87]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(N[(l - t$95$0), $MachinePrecision] + N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;M \leq -6.5 \cdot 10^{+124} \lor \neg \left(M \leq 1.15 \cdot 10^{+87}\right):\\
\;\;\;\;\frac{\cos M}{e^{\left(\ell - t_0\right) + M \cdot M}}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot {\left(m + n\right)}^{2}\right)}\\
\end{array}
\end{array}
if M < -6.50000000000000008e124 or 1.1500000000000001e87 < M Initial program 83.5%
Simplified83.5%
Taylor expanded in M around inf 83.5%
unpow283.5%
Simplified83.5%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
if -6.50000000000000008e124 < M < 1.1500000000000001e87Initial program 77.3%
associate-/l*76.6%
associate--r-76.6%
Simplified76.6%
Taylor expanded in K around 0 94.2%
cos-neg94.2%
Simplified94.2%
Taylor expanded in M around 0 88.4%
Final simplification91.2%
(FPCore (K m n M l)
:precision binary64
(if (<= n -3.3e-256)
(exp (* m (* m -0.25)))
(if (<= n 2.7e+17)
(/ (cos M) (exp (+ (- l (fabs (- m n))) (* M M))))
(exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -3.3e-256) {
tmp = exp((m * (m * -0.25)));
} else if (n <= 2.7e+17) {
tmp = cos(M) / exp(((l - fabs((m - n))) + (M * M)));
} else {
tmp = 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.3d-256)) then
tmp = exp((m * (m * (-0.25d0))))
else if (n <= 2.7d+17) then
tmp = cos(m_1) / exp(((l - abs((m - n))) + (m_1 * m_1)))
else
tmp = 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.3e-256) {
tmp = Math.exp((m * (m * -0.25)));
} else if (n <= 2.7e+17) {
tmp = Math.cos(M) / Math.exp(((l - Math.abs((m - n))) + (M * M)));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= -3.3e-256: tmp = math.exp((m * (m * -0.25))) elif n <= 2.7e+17: tmp = math.cos(M) / math.exp(((l - math.fabs((m - n))) + (M * M))) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= -3.3e-256) tmp = exp(Float64(m * Float64(m * -0.25))); elseif (n <= 2.7e+17) tmp = Float64(cos(M) / exp(Float64(Float64(l - abs(Float64(m - n))) + Float64(M * M)))); else tmp = 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.3e-256) tmp = exp((m * (m * -0.25))); elseif (n <= 2.7e+17) tmp = cos(M) / exp(((l - abs((m - n))) + (M * M))); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, -3.3e-256], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 2.7e+17], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.3 \cdot 10^{-256}:\\
\;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;n \leq 2.7 \cdot 10^{+17}:\\
\;\;\;\;\frac{\cos M}{e^{\left(\ell - \left|m - n\right|\right) + M \cdot M}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < -3.3e-256Initial program 80.7%
associate-/l*80.7%
associate--r-80.7%
Simplified80.7%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in M around 0 83.2%
Taylor expanded in m around inf 45.1%
*-commutative45.1%
unpow245.1%
associate-*l*45.1%
Simplified45.1%
if -3.3e-256 < n < 2.7e17Initial program 83.1%
Simplified83.1%
Taylor expanded in M around inf 67.1%
unpow267.1%
Simplified67.1%
Taylor expanded in K around 0 68.2%
cos-neg68.2%
Simplified68.2%
if 2.7e17 < n Initial program 71.2%
associate-/l*71.2%
associate--r-71.2%
Simplified71.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 98.3%
Taylor expanded in n around inf 95.0%
*-commutative95.0%
unpow295.0%
Simplified95.0%
Final simplification63.8%
(FPCore (K m n M l)
:precision binary64
(if (<= m -116000.0)
(exp (* m (* m -0.25)))
(if (<= m 1.15e-178)
(/ (cos (- (* 0.5 (* m K)) M)) (exp (* M M)))
(exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -116000.0) {
tmp = exp((m * (m * -0.25)));
} else if (m <= 1.15e-178) {
tmp = cos(((0.5 * (m * K)) - M)) / exp((M * M));
} else {
tmp = 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 (m <= (-116000.0d0)) then
tmp = exp((m * (m * (-0.25d0))))
else if (m <= 1.15d-178) then
tmp = cos(((0.5d0 * (m * k)) - m_1)) / exp((m_1 * m_1))
else
tmp = 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 (m <= -116000.0) {
tmp = Math.exp((m * (m * -0.25)));
} else if (m <= 1.15e-178) {
tmp = Math.cos(((0.5 * (m * K)) - M)) / Math.exp((M * M));
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -116000.0: tmp = math.exp((m * (m * -0.25))) elif m <= 1.15e-178: tmp = math.cos(((0.5 * (m * K)) - M)) / math.exp((M * M)) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -116000.0) tmp = exp(Float64(m * Float64(m * -0.25))); elseif (m <= 1.15e-178) tmp = Float64(cos(Float64(Float64(0.5 * Float64(m * K)) - M)) / exp(Float64(M * M))); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -116000.0) tmp = exp((m * (m * -0.25))); elseif (m <= 1.15e-178) tmp = cos(((0.5 * (m * K)) - M)) / exp((M * M)); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -116000.0], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 1.15e-178], N[(N[Cos[N[(N[(0.5 * N[(m * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(M * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -116000:\\
\;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 1.15 \cdot 10^{-178}:\\
\;\;\;\;\frac{\cos \left(0.5 \cdot \left(m \cdot K\right) - M\right)}{e^{M \cdot M}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -116000Initial program 71.4%
associate-/l*71.4%
associate--r-71.4%
Simplified71.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Taylor expanded in m around inf 96.9%
*-commutative96.9%
unpow296.9%
associate-*l*96.9%
Simplified96.9%
if -116000 < m < 1.14999999999999997e-178Initial program 83.3%
Simplified83.3%
Taylor expanded in M around inf 67.1%
unpow267.1%
Simplified67.1%
Taylor expanded in n around 0 69.8%
Taylor expanded in M around inf 57.3%
unpow257.3%
Simplified57.3%
if 1.14999999999999997e-178 < m Initial program 80.4%
associate-/l*79.4%
associate--r-79.4%
Simplified79.4%
Taylor expanded in K around 0 95.1%
cos-neg95.1%
Simplified95.1%
Taylor expanded in M around 0 87.5%
Taylor expanded in n around inf 48.6%
*-commutative48.6%
unpow248.6%
Simplified48.6%
Final simplification63.6%
(FPCore (K m n M l)
:precision binary64
(if (<= m -1.28e+20)
(exp (* m (* m -0.25)))
(if (<= m 2.05e-227)
(/ (cos (- (* K (* n 0.5)) M)) (exp l))
(exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1.28e+20) {
tmp = exp((m * (m * -0.25)));
} else if (m <= 2.05e-227) {
tmp = cos(((K * (n * 0.5)) - M)) / exp(l);
} else {
tmp = 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 (m <= (-1.28d+20)) then
tmp = exp((m * (m * (-0.25d0))))
else if (m <= 2.05d-227) then
tmp = cos(((k * (n * 0.5d0)) - m_1)) / exp(l)
else
tmp = 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 (m <= -1.28e+20) {
tmp = Math.exp((m * (m * -0.25)));
} else if (m <= 2.05e-227) {
tmp = Math.cos(((K * (n * 0.5)) - M)) / Math.exp(l);
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1.28e+20: tmp = math.exp((m * (m * -0.25))) elif m <= 2.05e-227: tmp = math.cos(((K * (n * 0.5)) - M)) / math.exp(l) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1.28e+20) tmp = exp(Float64(m * Float64(m * -0.25))); elseif (m <= 2.05e-227) tmp = Float64(cos(Float64(Float64(K * Float64(n * 0.5)) - M)) / exp(l)); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1.28e+20) tmp = exp((m * (m * -0.25))); elseif (m <= 2.05e-227) tmp = cos(((K * (n * 0.5)) - M)) / exp(l); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1.28e+20], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 2.05e-227], N[(N[Cos[N[(N[(K * N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.28 \cdot 10^{+20}:\\
\;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 2.05 \cdot 10^{-227}:\\
\;\;\;\;\frac{\cos \left(K \cdot \left(n \cdot 0.5\right) - M\right)}{e^{\ell}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -1.28e20Initial program 71.0%
associate-/l*71.0%
associate--r-71.0%
Simplified71.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Taylor expanded in m around inf 98.4%
*-commutative98.4%
unpow298.4%
associate-*l*98.4%
Simplified98.4%
if -1.28e20 < m < 2.05000000000000005e-227Initial program 83.1%
Simplified83.1%
Taylor expanded in M around inf 66.7%
unpow266.7%
Simplified66.7%
Taylor expanded in l around inf 44.2%
Taylor expanded in m around 0 43.9%
associate-*r*43.9%
*-commutative43.9%
Simplified43.9%
if 2.05000000000000005e-227 < m Initial program 80.9%
associate-/l*80.0%
associate--r-80.0%
Simplified80.0%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in M around 0 84.8%
Taylor expanded in n around inf 48.8%
*-commutative48.8%
unpow248.8%
Simplified48.8%
Final simplification59.2%
(FPCore (K m n M l) :precision binary64 (if (<= m -1.28e+20) (exp (* m (* m -0.25))) (if (<= m 7.6e-227) (/ (cos M) (exp l)) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1.28e+20) {
tmp = exp((m * (m * -0.25)));
} else if (m <= 7.6e-227) {
tmp = cos(M) / exp(l);
} else {
tmp = 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 (m <= (-1.28d+20)) then
tmp = exp((m * (m * (-0.25d0))))
else if (m <= 7.6d-227) then
tmp = cos(m_1) / exp(l)
else
tmp = 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 (m <= -1.28e+20) {
tmp = Math.exp((m * (m * -0.25)));
} else if (m <= 7.6e-227) {
tmp = Math.cos(M) / Math.exp(l);
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1.28e+20: tmp = math.exp((m * (m * -0.25))) elif m <= 7.6e-227: tmp = math.cos(M) / math.exp(l) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1.28e+20) tmp = exp(Float64(m * Float64(m * -0.25))); elseif (m <= 7.6e-227) tmp = Float64(cos(M) / exp(l)); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1.28e+20) tmp = exp((m * (m * -0.25))); elseif (m <= 7.6e-227) tmp = cos(M) / exp(l); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1.28e+20], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 7.6e-227], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.28 \cdot 10^{+20}:\\
\;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 7.6 \cdot 10^{-227}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -1.28e20Initial program 71.0%
associate-/l*71.0%
associate--r-71.0%
Simplified71.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Taylor expanded in m around inf 98.4%
*-commutative98.4%
unpow298.4%
associate-*l*98.4%
Simplified98.4%
if -1.28e20 < m < 7.60000000000000019e-227Initial program 83.1%
Simplified83.1%
Taylor expanded in M around inf 66.7%
unpow266.7%
Simplified66.7%
Taylor expanded in l around inf 44.2%
Taylor expanded in K around 0 47.9%
cos-neg47.9%
Simplified47.9%
if 7.60000000000000019e-227 < m Initial program 80.9%
associate-/l*80.0%
associate--r-80.0%
Simplified80.0%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in M around 0 84.8%
Taylor expanded in n around inf 48.8%
*-commutative48.8%
unpow248.8%
Simplified48.8%
Final simplification60.5%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -1.28e+20) (not (<= m 3.2e-48))) (exp (* m (* m -0.25))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -1.28e+20) || !(m <= 3.2e-48)) {
tmp = exp((m * (m * -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 ((m <= (-1.28d+20)) .or. (.not. (m <= 3.2d-48))) then
tmp = exp((m * (m * (-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 ((m <= -1.28e+20) || !(m <= 3.2e-48)) {
tmp = Math.exp((m * (m * -0.25)));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -1.28e+20) or not (m <= 3.2e-48): tmp = math.exp((m * (m * -0.25))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -1.28e+20) || !(m <= 3.2e-48)) tmp = exp(Float64(m * Float64(m * -0.25))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -1.28e+20) || ~((m <= 3.2e-48))) tmp = exp((m * (m * -0.25))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -1.28e+20], N[Not[LessEqual[m, 3.2e-48]], $MachinePrecision]], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.28 \cdot 10^{+20} \lor \neg \left(m \leq 3.2 \cdot 10^{-48}\right):\\
\;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if m < -1.28e20 or 3.1999999999999998e-48 < m Initial program 74.4%
associate-/l*73.6%
associate--r-73.6%
Simplified73.6%
Taylor expanded in K around 0 97.6%
cos-neg97.6%
Simplified97.6%
Taylor expanded in M around 0 96.8%
Taylor expanded in m around inf 88.3%
*-commutative88.3%
unpow288.3%
associate-*l*88.3%
Simplified88.3%
if -1.28e20 < m < 3.1999999999999998e-48Initial program 83.8%
associate-/l*83.7%
associate--r-83.7%
Simplified83.7%
Taylor expanded in K around 0 94.5%
cos-neg94.5%
Simplified94.5%
Taylor expanded in M around 0 72.5%
Taylor expanded in l around inf 46.5%
neg-mul-146.5%
Simplified46.5%
Final simplification66.9%
(FPCore (K m n M l) :precision binary64 (if (<= m -1.28e+20) (exp (* m (* m -0.25))) (if (<= m 8.4e-237) (exp (- l)) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1.28e+20) {
tmp = exp((m * (m * -0.25)));
} else if (m <= 8.4e-237) {
tmp = exp(-l);
} else {
tmp = 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 (m <= (-1.28d+20)) then
tmp = exp((m * (m * (-0.25d0))))
else if (m <= 8.4d-237) then
tmp = exp(-l)
else
tmp = 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 (m <= -1.28e+20) {
tmp = Math.exp((m * (m * -0.25)));
} else if (m <= 8.4e-237) {
tmp = Math.exp(-l);
} else {
tmp = Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1.28e+20: tmp = math.exp((m * (m * -0.25))) elif m <= 8.4e-237: tmp = math.exp(-l) else: tmp = math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1.28e+20) tmp = exp(Float64(m * Float64(m * -0.25))); elseif (m <= 8.4e-237) tmp = exp(Float64(-l)); else tmp = exp(Float64(-0.25 * Float64(n * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1.28e+20) tmp = exp((m * (m * -0.25))); elseif (m <= 8.4e-237) tmp = exp(-l); else tmp = exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1.28e+20], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 8.4e-237], N[Exp[(-l)], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.28 \cdot 10^{+20}:\\
\;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 8.4 \cdot 10^{-237}:\\
\;\;\;\;e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -1.28e20Initial program 71.0%
associate-/l*71.0%
associate--r-71.0%
Simplified71.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Taylor expanded in m around inf 98.4%
*-commutative98.4%
unpow298.4%
associate-*l*98.4%
Simplified98.4%
if -1.28e20 < m < 8.4000000000000005e-237Initial program 82.9%
associate-/l*82.6%
associate--r-82.6%
Simplified82.6%
Taylor expanded in K around 0 93.2%
cos-neg93.2%
Simplified93.2%
Taylor expanded in M around 0 70.9%
Taylor expanded in l around inf 45.6%
neg-mul-145.6%
Simplified45.6%
if 8.4000000000000005e-237 < m Initial program 81.2%
associate-/l*80.4%
associate--r-80.4%
Simplified80.4%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Taylor expanded in M around 0 84.9%
Taylor expanded in n around inf 49.4%
*-commutative49.4%
unpow249.4%
Simplified49.4%
Final simplification60.1%
(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 79.2%
associate-/l*78.8%
associate--r-78.8%
Simplified78.8%
Taylor expanded in K around 0 96.0%
cos-neg96.0%
Simplified96.0%
Taylor expanded in M around 0 84.4%
Taylor expanded in l around inf 39.5%
neg-mul-139.5%
Simplified39.5%
Final simplification39.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 79.2%
Simplified79.2%
Taylor expanded in M around inf 54.6%
unpow254.6%
Simplified54.6%
Taylor expanded in l around inf 35.7%
Taylor expanded in l around 0 7.9%
Taylor expanded in K around 0 8.4%
cos-neg8.4%
Simplified8.4%
Final simplification8.4%
herbie shell --seed 2023213
(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)))))))