
(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 (- 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 74.8%
associate-/l*74.8%
associate--r-74.8%
Simplified74.8%
Taylor expanded in K around 0 97.7%
cos-neg97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (K m n M l)
:precision binary64
(if (<= m -60000.0)
(* (cos M) (exp (* m (* m -0.25))))
(if (<= m 5.5e-238)
(* (cos M) (exp (- (fabs (- m n)) (+ l (* M M)))))
(* (cos M) (exp (* n (* n -0.25)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -60000.0) {
tmp = cos(M) * exp((m * (m * -0.25)));
} else if (m <= 5.5e-238) {
tmp = cos(M) * exp((fabs((m - n)) - (l + (M * M))));
} else {
tmp = cos(M) * exp((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 <= (-60000.0d0)) then
tmp = cos(m_1) * exp((m * (m * (-0.25d0))))
else if (m <= 5.5d-238) then
tmp = cos(m_1) * exp((abs((m - n)) - (l + (m_1 * m_1))))
else
tmp = cos(m_1) * exp((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 <= -60000.0) {
tmp = Math.cos(M) * Math.exp((m * (m * -0.25)));
} else if (m <= 5.5e-238) {
tmp = Math.cos(M) * Math.exp((Math.abs((m - n)) - (l + (M * M))));
} else {
tmp = Math.cos(M) * Math.exp((n * (n * -0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -60000.0: tmp = math.cos(M) * math.exp((m * (m * -0.25))) elif m <= 5.5e-238: tmp = math.cos(M) * math.exp((math.fabs((m - n)) - (l + (M * M)))) else: tmp = math.cos(M) * math.exp((n * (n * -0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -60000.0) tmp = Float64(cos(M) * exp(Float64(m * Float64(m * -0.25)))); elseif (m <= 5.5e-238) tmp = Float64(cos(M) * exp(Float64(abs(Float64(m - n)) - Float64(l + Float64(M * M))))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(n * -0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -60000.0) tmp = cos(M) * exp((m * (m * -0.25))); elseif (m <= 5.5e-238) tmp = cos(M) * exp((abs((m - n)) - (l + (M * M)))); else tmp = cos(M) * exp((n * (n * -0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -60000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 5.5e-238], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -60000:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 5.5 \cdot 10^{-238}:\\
\;\;\;\;\cos M \cdot e^{\left|m - n\right| - \left(\ell + M \cdot M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if m < -6e4Initial program 74.6%
associate-/l*74.6%
associate--r-74.6%
Simplified74.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 98.6%
*-commutative98.6%
unpow298.6%
associate-*l*98.6%
Simplified98.6%
if -6e4 < m < 5.49999999999999995e-238Initial program 86.7%
associate-/l*88.0%
associate--r-88.0%
Simplified88.0%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in M around inf 81.4%
unpow281.4%
Simplified81.4%
if 5.49999999999999995e-238 < m Initial program 66.8%
associate-/l*65.9%
associate--r-65.9%
Simplified65.9%
Taylor expanded in K around 0 96.5%
cos-neg96.5%
Simplified96.5%
Taylor expanded in n around inf 56.7%
*-commutative56.7%
unpow256.7%
associate-*l*56.7%
Simplified56.7%
Final simplification75.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (/ (cos M) (exp l))) (t_1 (pow (exp n) (* n -0.25))))
(if (<= n -1.26e-24)
t_1
(if (<= n -1.55e-213)
t_0
(if (<= n 9.2e-232)
(/ (cos (- (* (/ (+ m n) 2.0) K) M)) (+ 1.0 (* m (* m 0.25))))
(if (<= n 510000.0) t_0 t_1))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) / exp(l);
double t_1 = pow(exp(n), (n * -0.25));
double tmp;
if (n <= -1.26e-24) {
tmp = t_1;
} else if (n <= -1.55e-213) {
tmp = t_0;
} else if (n <= 9.2e-232) {
tmp = cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25)));
} else if (n <= 510000.0) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = cos(m_1) / exp(l)
t_1 = exp(n) ** (n * (-0.25d0))
if (n <= (-1.26d-24)) then
tmp = t_1
else if (n <= (-1.55d-213)) then
tmp = t_0
else if (n <= 9.2d-232) then
tmp = cos(((((m + n) / 2.0d0) * k) - m_1)) / (1.0d0 + (m * (m * 0.25d0)))
else if (n <= 510000.0d0) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.cos(M) / Math.exp(l);
double t_1 = Math.pow(Math.exp(n), (n * -0.25));
double tmp;
if (n <= -1.26e-24) {
tmp = t_1;
} else if (n <= -1.55e-213) {
tmp = t_0;
} else if (n <= 9.2e-232) {
tmp = Math.cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25)));
} else if (n <= 510000.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(M) / math.exp(l) t_1 = math.pow(math.exp(n), (n * -0.25)) tmp = 0 if n <= -1.26e-24: tmp = t_1 elif n <= -1.55e-213: tmp = t_0 elif n <= 9.2e-232: tmp = math.cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25))) elif n <= 510000.0: tmp = t_0 else: tmp = t_1 return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(M) / exp(l)) t_1 = exp(n) ^ Float64(n * -0.25) tmp = 0.0 if (n <= -1.26e-24) tmp = t_1; elseif (n <= -1.55e-213) tmp = t_0; elseif (n <= 9.2e-232) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) / 2.0) * K) - M)) / Float64(1.0 + Float64(m * Float64(m * 0.25)))); elseif (n <= 510000.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) / exp(l); t_1 = exp(n) ^ (n * -0.25); tmp = 0.0; if (n <= -1.26e-24) tmp = t_1; elseif (n <= -1.55e-213) tmp = t_0; elseif (n <= 9.2e-232) tmp = cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25))); elseif (n <= 510000.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Exp[n], $MachinePrecision], N[(n * -0.25), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -1.26e-24], t$95$1, If[LessEqual[n, -1.55e-213], t$95$0, If[LessEqual[n, 9.2e-232], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] * K), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] / N[(1.0 + N[(m * N[(m * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 510000.0], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\cos M}{e^{\ell}}\\
t_1 := {\left(e^{n}\right)}^{\left(n \cdot -0.25\right)}\\
\mathbf{if}\;n \leq -1.26 \cdot 10^{-24}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;n \leq -1.55 \cdot 10^{-213}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 9.2 \cdot 10^{-232}:\\
\;\;\;\;\frac{\cos \left(\frac{m + n}{2} \cdot K - M\right)}{1 + m \cdot \left(m \cdot 0.25\right)}\\
\mathbf{elif}\;n \leq 510000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if n < -1.25999999999999992e-24 or 5.1e5 < n Initial program 66.2%
associate-/l*66.9%
associate--r-66.9%
Simplified66.9%
Taylor expanded in K around 0 99.3%
cos-neg99.3%
Simplified99.3%
Taylor expanded in n around inf 93.7%
*-commutative93.7%
unpow293.7%
associate-*l*93.7%
Simplified93.7%
Taylor expanded in M around 0 93.7%
*-commutative93.7%
unpow293.7%
associate-*r*93.7%
exp-prod93.7%
Simplified93.7%
if -1.25999999999999992e-24 < n < -1.5499999999999999e-213 or 9.2e-232 < n < 5.1e5Initial program 85.0%
sub-neg85.0%
associate--r+85.0%
exp-diff52.6%
associate-*r/52.6%
associate-/l*52.6%
associate-*r/52.6%
exp-diff39.6%
Simplified85.0%
Taylor expanded in l around inf 43.1%
Taylor expanded in K around 0 43.0%
cos-neg43.0%
Simplified43.0%
if -1.5499999999999999e-213 < n < 9.2e-232Initial program 85.0%
sub-neg85.0%
associate--r+85.0%
exp-diff40.0%
associate-*r/40.0%
associate-/l*40.0%
associate-*r/40.0%
exp-diff32.5%
Simplified85.0%
Taylor expanded in m around inf 60.7%
*-commutative60.7%
unpow260.7%
Simplified60.7%
Taylor expanded in m around inf 55.9%
*-commutative55.9%
unpow255.9%
associate-*r*55.9%
Simplified55.9%
Taylor expanded in m around 0 32.3%
*-commutative32.3%
unpow232.3%
associate-*r*32.3%
Simplified32.3%
Final simplification68.9%
(FPCore (K m n M l)
:precision binary64
(if (<= m -1550.0)
(* (cos M) (exp (* m (* m -0.25))))
(if (<= m 9e-249)
(* (cos M) (exp (* M (- M))))
(* (cos M) (exp (* n (* n -0.25)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1550.0) {
tmp = cos(M) * exp((m * (m * -0.25)));
} else if (m <= 9e-249) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = cos(M) * exp((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 <= (-1550.0d0)) then
tmp = cos(m_1) * exp((m * (m * (-0.25d0))))
else if (m <= 9d-249) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = cos(m_1) * exp((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 <= -1550.0) {
tmp = Math.cos(M) * Math.exp((m * (m * -0.25)));
} else if (m <= 9e-249) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp((n * (n * -0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1550.0: tmp = math.cos(M) * math.exp((m * (m * -0.25))) elif m <= 9e-249: tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp((n * (n * -0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1550.0) tmp = Float64(cos(M) * exp(Float64(m * Float64(m * -0.25)))); elseif (m <= 9e-249) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(n * -0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1550.0) tmp = cos(M) * exp((m * (m * -0.25))); elseif (m <= 9e-249) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp((n * (n * -0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1550.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 9e-249], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1550:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 9 \cdot 10^{-249}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if m < -1550Initial program 74.6%
associate-/l*74.6%
associate--r-74.6%
Simplified74.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 98.6%
*-commutative98.6%
unpow298.6%
associate-*l*98.6%
Simplified98.6%
if -1550 < m < 8.99999999999999962e-249Initial program 86.1%
associate-/l*87.5%
associate--r-87.5%
Simplified87.5%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in M around inf 72.8%
mul-1-neg72.8%
unpow272.8%
distribute-rgt-neg-in72.8%
Simplified72.8%
if 8.99999999999999962e-249 < m Initial program 67.7%
associate-/l*66.8%
associate--r-66.8%
Simplified66.8%
Taylor expanded in K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Taylor expanded in n around inf 56.2%
*-commutative56.2%
unpow256.2%
associate-*l*56.2%
Simplified56.2%
Final simplification72.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (pow (exp n) (* n -0.25))))
(if (<= n -54.0)
t_0
(if (<= n 2.8e-25)
(* (cos M) (exp (* M (- M))))
(if (<= n 510000.0) (/ (cos M) (exp l)) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = pow(exp(n), (n * -0.25));
double tmp;
if (n <= -54.0) {
tmp = t_0;
} else if (n <= 2.8e-25) {
tmp = cos(M) * exp((M * -M));
} else if (n <= 510000.0) {
tmp = cos(M) / exp(l);
} else {
tmp = t_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 = exp(n) ** (n * (-0.25d0))
if (n <= (-54.0d0)) then
tmp = t_0
else if (n <= 2.8d-25) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else if (n <= 510000.0d0) then
tmp = cos(m_1) / exp(l)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.pow(Math.exp(n), (n * -0.25));
double tmp;
if (n <= -54.0) {
tmp = t_0;
} else if (n <= 2.8e-25) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else if (n <= 510000.0) {
tmp = Math.cos(M) / Math.exp(l);
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.pow(math.exp(n), (n * -0.25)) tmp = 0 if n <= -54.0: tmp = t_0 elif n <= 2.8e-25: tmp = math.cos(M) * math.exp((M * -M)) elif n <= 510000.0: tmp = math.cos(M) / math.exp(l) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(n) ^ Float64(n * -0.25) tmp = 0.0 if (n <= -54.0) tmp = t_0; elseif (n <= 2.8e-25) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); elseif (n <= 510000.0) tmp = Float64(cos(M) / exp(l)); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(n) ^ (n * -0.25); tmp = 0.0; if (n <= -54.0) tmp = t_0; elseif (n <= 2.8e-25) tmp = cos(M) * exp((M * -M)); elseif (n <= 510000.0) tmp = cos(M) / exp(l); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Power[N[Exp[n], $MachinePrecision], N[(n * -0.25), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -54.0], t$95$0, If[LessEqual[n, 2.8e-25], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 510000.0], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(e^{n}\right)}^{\left(n \cdot -0.25\right)}\\
\mathbf{if}\;n \leq -54:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 2.8 \cdot 10^{-25}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{elif}\;n \leq 510000:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -54 or 5.1e5 < n Initial program 66.2%
associate-/l*66.9%
associate--r-66.9%
Simplified66.9%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 97.8%
*-commutative97.8%
unpow297.8%
associate-*l*97.8%
Simplified97.8%
Taylor expanded in M around 0 97.8%
*-commutative97.8%
unpow297.8%
associate-*r*97.8%
exp-prod97.8%
Simplified97.8%
if -54 < n < 2.79999999999999988e-25Initial program 84.8%
associate-/l*83.9%
associate--r-83.9%
Simplified83.9%
Taylor expanded in K around 0 94.8%
cos-neg94.8%
Simplified94.8%
Taylor expanded in M around inf 64.3%
mul-1-neg64.3%
unpow264.3%
distribute-rgt-neg-in64.3%
Simplified64.3%
if 2.79999999999999988e-25 < n < 5.1e5Initial program 75.0%
sub-neg75.0%
associate--r+75.0%
exp-diff62.5%
associate-*r/62.5%
associate-/l*62.5%
associate-*r/62.5%
exp-diff25.0%
Simplified75.0%
Taylor expanded in l around inf 75.0%
Taylor expanded in K around 0 75.6%
cos-neg75.6%
Simplified75.6%
Final simplification82.1%
(FPCore (K m n M l) :precision binary64 (if (<= m -1550.0) (* (cos M) (exp (* m (* m -0.25)))) (if (<= m 5e-237) (* (cos M) (exp (* M (- M)))) (pow (exp n) (* n -0.25)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1550.0) {
tmp = cos(M) * exp((m * (m * -0.25)));
} else if (m <= 5e-237) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = pow(exp(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 <= (-1550.0d0)) then
tmp = cos(m_1) * exp((m * (m * (-0.25d0))))
else if (m <= 5d-237) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = exp(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 <= -1550.0) {
tmp = Math.cos(M) * Math.exp((m * (m * -0.25)));
} else if (m <= 5e-237) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.pow(Math.exp(n), (n * -0.25));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1550.0: tmp = math.cos(M) * math.exp((m * (m * -0.25))) elif m <= 5e-237: tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.pow(math.exp(n), (n * -0.25)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1550.0) tmp = Float64(cos(M) * exp(Float64(m * Float64(m * -0.25)))); elseif (m <= 5e-237) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = exp(n) ^ Float64(n * -0.25); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1550.0) tmp = cos(M) * exp((m * (m * -0.25))); elseif (m <= 5e-237) tmp = cos(M) * exp((M * -M)); else tmp = exp(n) ^ (n * -0.25); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1550.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 5e-237], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Exp[n], $MachinePrecision], N[(n * -0.25), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1550:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq 5 \cdot 10^{-237}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;{\left(e^{n}\right)}^{\left(n \cdot -0.25\right)}\\
\end{array}
\end{array}
if m < -1550Initial program 74.6%
associate-/l*74.6%
associate--r-74.6%
Simplified74.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 98.6%
*-commutative98.6%
unpow298.6%
associate-*l*98.6%
Simplified98.6%
if -1550 < m < 5.0000000000000002e-237Initial program 86.7%
associate-/l*88.0%
associate--r-88.0%
Simplified88.0%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in M around inf 71.3%
mul-1-neg71.3%
unpow271.3%
distribute-rgt-neg-in71.3%
Simplified71.3%
if 5.0000000000000002e-237 < m Initial program 66.8%
associate-/l*65.9%
associate--r-65.9%
Simplified65.9%
Taylor expanded in K around 0 96.5%
cos-neg96.5%
Simplified96.5%
Taylor expanded in n around inf 56.7%
*-commutative56.7%
unpow256.7%
associate-*l*56.7%
Simplified56.7%
Taylor expanded in M around 0 56.7%
*-commutative56.7%
unpow256.7%
associate-*r*56.7%
exp-prod56.7%
Simplified56.7%
Final simplification72.6%
(FPCore (K m n M l) :precision binary64 (if (<= m -8.5e+164) (/ (cos (- (* (/ (+ m n) 2.0) K) M)) (+ 1.0 (* m (* m 0.25)))) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -8.5e+164) {
tmp = cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25)));
} 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 <= (-8.5d+164)) then
tmp = cos(((((m + n) / 2.0d0) * k) - m_1)) / (1.0d0 + (m * (m * 0.25d0)))
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 <= -8.5e+164) {
tmp = Math.cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25)));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -8.5e+164: tmp = math.cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25))) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -8.5e+164) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) / 2.0) * K) - M)) / Float64(1.0 + Float64(m * Float64(m * 0.25)))); 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 <= -8.5e+164) tmp = cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25))); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -8.5e+164], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] * K), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] / N[(1.0 + N[(m * N[(m * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -8.5 \cdot 10^{+164}:\\
\;\;\;\;\frac{\cos \left(\frac{m + n}{2} \cdot K - M\right)}{1 + m \cdot \left(m \cdot 0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if m < -8.50000000000000027e164Initial program 73.2%
sub-neg73.2%
associate--r+73.2%
exp-diff0.0%
associate-*r/0.0%
associate-/l*0.0%
associate-*r/0.0%
exp-diff0.0%
Simplified73.2%
Taylor expanded in m around inf 73.2%
*-commutative73.2%
unpow273.2%
Simplified73.2%
Taylor expanded in m around inf 73.2%
*-commutative73.2%
unpow273.2%
associate-*r*73.2%
Simplified73.2%
Taylor expanded in m around 0 73.2%
*-commutative73.2%
unpow273.2%
associate-*r*73.2%
Simplified73.2%
if -8.50000000000000027e164 < m Initial program 75.1%
sub-neg75.1%
associate--r+75.1%
exp-diff28.1%
associate-*r/28.1%
associate-/l*28.1%
associate-*r/28.1%
exp-diff20.7%
Simplified75.1%
Taylor expanded in l around inf 32.4%
Taylor expanded in K around 0 36.9%
cos-neg36.9%
Simplified36.9%
Final simplification42.7%
(FPCore (K m n M l) :precision binary64 (if (<= m -8.5e+164) (/ (cos (- (* (/ (+ m n) 2.0) K) M)) (+ 1.0 (* m (* m 0.25)))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -8.5e+164) {
tmp = cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (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 <= (-8.5d+164)) then
tmp = cos(((((m + n) / 2.0d0) * k) - m_1)) / (1.0d0 + (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 <= -8.5e+164) {
tmp = Math.cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25)));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -8.5e+164: tmp = math.cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -8.5e+164) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) / 2.0) * K) - M)) / Float64(1.0 + 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 <= -8.5e+164) tmp = cos(((((m + n) / 2.0) * K) - M)) / (1.0 + (m * (m * 0.25))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -8.5e+164], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] * K), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] / N[(1.0 + N[(m * N[(m * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -8.5 \cdot 10^{+164}:\\
\;\;\;\;\frac{\cos \left(\frac{m + n}{2} \cdot K - M\right)}{1 + m \cdot \left(m \cdot 0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if m < -8.50000000000000027e164Initial program 73.2%
sub-neg73.2%
associate--r+73.2%
exp-diff0.0%
associate-*r/0.0%
associate-/l*0.0%
associate-*r/0.0%
exp-diff0.0%
Simplified73.2%
Taylor expanded in m around inf 73.2%
*-commutative73.2%
unpow273.2%
Simplified73.2%
Taylor expanded in m around inf 73.2%
*-commutative73.2%
unpow273.2%
associate-*r*73.2%
Simplified73.2%
Taylor expanded in m around 0 73.2%
*-commutative73.2%
unpow273.2%
associate-*r*73.2%
Simplified73.2%
if -8.50000000000000027e164 < m Initial program 75.1%
sub-neg75.1%
associate--r+75.1%
exp-diff28.1%
associate-*r/28.1%
associate-/l*28.1%
associate-*r/28.1%
exp-diff20.7%
Simplified75.1%
Taylor expanded in l around inf 32.4%
Taylor expanded in K around 0 36.9%
cos-neg36.9%
Simplified36.9%
Taylor expanded in M around 0 36.5%
rec-exp36.5%
Simplified36.5%
Final simplification42.3%
(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.8%
sub-neg74.8%
associate--r+74.8%
exp-diff23.6%
associate-*r/23.6%
associate-/l*23.6%
associate-*r/23.6%
exp-diff17.4%
Simplified74.8%
Taylor expanded in l around inf 31.0%
Taylor expanded in K around 0 36.0%
cos-neg36.0%
Simplified36.0%
Taylor expanded in M around 0 35.6%
rec-exp35.6%
Simplified35.6%
Final simplification35.6%
(FPCore (K m n M l) :precision binary64 (- 1.0 l))
double code(double K, double m, double n, double M, double l) {
return 1.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 = 1.0d0 - l
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0 - l;
}
def code(K, m, n, M, l): return 1.0 - l
function code(K, m, n, M, l) return Float64(1.0 - l) end
function tmp = code(K, m, n, M, l) tmp = 1.0 - l; end
code[K_, m_, n_, M_, l_] := N[(1.0 - l), $MachinePrecision]
\begin{array}{l}
\\
1 - \ell
\end{array}
Initial program 74.8%
sub-neg74.8%
associate--r+74.8%
exp-diff23.6%
associate-*r/23.6%
associate-/l*23.6%
associate-*r/23.6%
exp-diff17.4%
Simplified74.8%
Taylor expanded in l around inf 31.0%
Taylor expanded in K around 0 36.0%
cos-neg36.0%
Simplified36.0%
Taylor expanded in l around 0 6.5%
+-commutative6.5%
mul-1-neg6.5%
unsub-neg6.5%
*-commutative6.5%
Simplified6.5%
Taylor expanded in M around 0 6.5%
Final simplification6.5%
herbie shell --seed 2023175
(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)))))))