
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 79.9%
*-commutative79.9%
associate-*r/79.9%
associate--r-79.9%
+-commutative79.9%
associate-+r-79.9%
unsub-neg79.9%
associate--r+79.9%
+-commutative79.9%
associate--r+79.9%
Simplified79.9%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (+ (- (fabs (- m n)) l) (* m (* m -0.25))))))
(if (<= n 5.2e-178)
t_0
(if (<= n 7.8e-18)
(* (cos M) (exp (* M (- M))))
(if (<= n 0.88) t_0 (* (cos M) (exp (* -0.25 (* n n)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(((fabs((m - n)) - l) + (m * (m * -0.25))));
double tmp;
if (n <= 5.2e-178) {
tmp = t_0;
} else if (n <= 7.8e-18) {
tmp = cos(M) * exp((M * -M));
} else if (n <= 0.88) {
tmp = t_0;
} 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 = exp(((abs((m - n)) - l) + (m * (m * (-0.25d0)))))
if (n <= 5.2d-178) then
tmp = t_0
else if (n <= 7.8d-18) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else if (n <= 0.88d0) then
tmp = t_0
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.exp(((Math.abs((m - n)) - l) + (m * (m * -0.25))));
double tmp;
if (n <= 5.2e-178) {
tmp = t_0;
} else if (n <= 7.8e-18) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else if (n <= 0.88) {
tmp = t_0;
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(((math.fabs((m - n)) - l) + (m * (m * -0.25)))) tmp = 0 if n <= 5.2e-178: tmp = t_0 elif n <= 7.8e-18: tmp = math.cos(M) * math.exp((M * -M)) elif n <= 0.88: tmp = t_0 else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(Float64(abs(Float64(m - n)) - l) + Float64(m * Float64(m * -0.25)))) tmp = 0.0 if (n <= 5.2e-178) tmp = t_0; elseif (n <= 7.8e-18) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); elseif (n <= 0.88) tmp = t_0; 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 = exp(((abs((m - n)) - l) + (m * (m * -0.25)))); tmp = 0.0; if (n <= 5.2e-178) tmp = t_0; elseif (n <= 7.8e-18) tmp = cos(M) * exp((M * -M)); elseif (n <= 0.88) tmp = t_0; 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[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] + N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 5.2e-178], t$95$0, If[LessEqual[n, 7.8e-18], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.88], t$95$0, 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 := e^{\left(\left|m - n\right| - \ell\right) + m \cdot \left(m \cdot -0.25\right)}\\
\mathbf{if}\;n \leq 5.2 \cdot 10^{-178}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 7.8 \cdot 10^{-18}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{elif}\;n \leq 0.88:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 5.19999999999999997e-178 or 7.8000000000000001e-18 < n < 0.880000000000000004Initial program 83.7%
*-commutative83.7%
associate-*r/83.7%
associate--r-83.7%
+-commutative83.7%
associate-+r-83.7%
unsub-neg83.7%
associate--r+83.7%
+-commutative83.7%
associate--r+83.7%
Simplified83.7%
Taylor expanded in K around 0 97.6%
cos-neg97.6%
Simplified97.6%
Taylor expanded in m around inf 65.8%
*-commutative65.8%
unpow265.8%
Simplified65.8%
Taylor expanded in M around 0 65.1%
associate--r+65.1%
unpow265.1%
cancel-sign-sub-inv65.1%
metadata-eval65.1%
*-commutative65.1%
associate-*l*65.1%
Simplified65.1%
if 5.19999999999999997e-178 < n < 7.8000000000000001e-18Initial program 90.9%
*-commutative90.9%
associate-*r/90.9%
associate--r-90.9%
+-commutative90.9%
associate-+r-90.9%
unsub-neg90.9%
associate--r+90.9%
+-commutative90.9%
associate--r+90.9%
Simplified90.9%
Taylor expanded in K around 0 93.6%
cos-neg93.6%
Simplified93.6%
Taylor expanded in M around inf 59.2%
mul-1-neg59.2%
unpow259.2%
distribute-rgt-neg-in59.2%
Simplified59.2%
if 0.880000000000000004 < n Initial program 65.7%
*-commutative65.7%
associate-*r/65.7%
associate--r-65.7%
+-commutative65.7%
associate-+r-65.7%
unsub-neg65.7%
associate--r+65.7%
+-commutative65.7%
associate--r+65.7%
Simplified65.7%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in n around inf 95.6%
unpow295.6%
Simplified95.6%
Final simplification72.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (* M (- M)))))
(t_1 (* -0.25 (* m m)))
(t_2 (* (cos M) (exp t_1))))
(if (<= m -52.0)
t_2
(if (<= m -7.8e-255)
t_0
(if (<= m 7.8e-153) (* (cos M) t_1) (if (<= m 55.0) t_0 t_2))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp((M * -M));
double t_1 = -0.25 * (m * m);
double t_2 = cos(M) * exp(t_1);
double tmp;
if (m <= -52.0) {
tmp = t_2;
} else if (m <= -7.8e-255) {
tmp = t_0;
} else if (m <= 7.8e-153) {
tmp = cos(M) * t_1;
} else if (m <= 55.0) {
tmp = t_0;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = cos(m_1) * exp((m_1 * -m_1))
t_1 = (-0.25d0) * (m * m)
t_2 = cos(m_1) * exp(t_1)
if (m <= (-52.0d0)) then
tmp = t_2
else if (m <= (-7.8d-255)) then
tmp = t_0
else if (m <= 7.8d-153) then
tmp = cos(m_1) * t_1
else if (m <= 55.0d0) then
tmp = t_0
else
tmp = t_2
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((M * -M));
double t_1 = -0.25 * (m * m);
double t_2 = Math.cos(M) * Math.exp(t_1);
double tmp;
if (m <= -52.0) {
tmp = t_2;
} else if (m <= -7.8e-255) {
tmp = t_0;
} else if (m <= 7.8e-153) {
tmp = Math.cos(M) * t_1;
} else if (m <= 55.0) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(M) * math.exp((M * -M)) t_1 = -0.25 * (m * m) t_2 = math.cos(M) * math.exp(t_1) tmp = 0 if m <= -52.0: tmp = t_2 elif m <= -7.8e-255: tmp = t_0 elif m <= 7.8e-153: tmp = math.cos(M) * t_1 elif m <= 55.0: tmp = t_0 else: tmp = t_2 return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(M) * exp(Float64(M * Float64(-M)))) t_1 = Float64(-0.25 * Float64(m * m)) t_2 = Float64(cos(M) * exp(t_1)) tmp = 0.0 if (m <= -52.0) tmp = t_2; elseif (m <= -7.8e-255) tmp = t_0; elseif (m <= 7.8e-153) tmp = Float64(cos(M) * t_1); elseif (m <= 55.0) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) * exp((M * -M)); t_1 = -0.25 * (m * m); t_2 = cos(M) * exp(t_1); tmp = 0.0; if (m <= -52.0) tmp = t_2; elseif (m <= -7.8e-255) tmp = t_0; elseif (m <= 7.8e-153) tmp = cos(M) * t_1; elseif (m <= 55.0) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[M], $MachinePrecision] * N[Exp[t$95$1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -52.0], t$95$2, If[LessEqual[m, -7.8e-255], t$95$0, If[LessEqual[m, 7.8e-153], N[(N[Cos[M], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[m, 55.0], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{M \cdot \left(-M\right)}\\
t_1 := -0.25 \cdot \left(m \cdot m\right)\\
t_2 := \cos M \cdot e^{t_1}\\
\mathbf{if}\;m \leq -52:\\
\;\;\;\;t_2\\
\mathbf{elif}\;m \leq -7.8 \cdot 10^{-255}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;m \leq 7.8 \cdot 10^{-153}:\\
\;\;\;\;\cos M \cdot t_1\\
\mathbf{elif}\;m \leq 55:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if m < -52 or 55 < m Initial program 75.0%
*-commutative75.0%
associate-*r/75.0%
associate--r-75.0%
+-commutative75.0%
associate-+r-75.0%
unsub-neg75.0%
associate--r+75.0%
+-commutative75.0%
associate--r+75.0%
Simplified75.0%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in m around inf 96.0%
unpow296.0%
Simplified96.0%
if -52 < m < -7.8000000000000001e-255 or 7.8000000000000004e-153 < m < 55Initial program 83.6%
*-commutative83.6%
associate-*r/83.6%
associate--r-83.6%
+-commutative83.6%
associate-+r-83.6%
unsub-neg83.6%
associate--r+83.6%
+-commutative83.6%
associate--r+83.6%
Simplified83.6%
Taylor expanded in K around 0 97.8%
cos-neg97.8%
Simplified97.8%
Taylor expanded in M around inf 59.1%
mul-1-neg59.1%
unpow259.1%
distribute-rgt-neg-in59.1%
Simplified59.1%
if -7.8000000000000001e-255 < m < 7.8000000000000004e-153Initial program 85.2%
*-commutative85.2%
associate-*r/85.2%
associate--r-85.2%
+-commutative85.2%
associate-+r-85.2%
unsub-neg85.2%
associate--r+85.2%
+-commutative85.2%
associate--r+85.2%
Simplified85.2%
Taylor expanded in K around 0 94.0%
cos-neg94.0%
Simplified94.0%
Taylor expanded in m around inf 12.8%
unpow212.8%
Simplified12.8%
Taylor expanded in m around 0 12.8%
unpow212.8%
associate-*r*12.8%
metadata-eval12.8%
distribute-lft-neg-in12.8%
*-commutative12.8%
associate-*r*12.8%
distribute-lft1-in12.8%
distribute-rgt-neg-in12.8%
fma-def12.8%
distribute-rgt-neg-in12.8%
metadata-eval12.8%
Simplified12.8%
Taylor expanded in m around inf 75.7%
associate-*r*75.7%
unpow275.7%
Simplified75.7%
Final simplification79.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* -0.25 (* m m))))
(if (<= m -52.0)
(* (cos M) (exp t_0))
(if (<= m -7.8e-255)
(* (cos M) (exp (* M (- M))))
(if (<= m 6.2e-182)
(* (cos M) t_0)
(* (cos M) (exp (* -0.25 (* n n)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = -0.25 * (m * m);
double tmp;
if (m <= -52.0) {
tmp = cos(M) * exp(t_0);
} else if (m <= -7.8e-255) {
tmp = cos(M) * exp((M * -M));
} else if (m <= 6.2e-182) {
tmp = cos(M) * t_0;
} 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 = (-0.25d0) * (m * m)
if (m <= (-52.0d0)) then
tmp = cos(m_1) * exp(t_0)
else if (m <= (-7.8d-255)) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else if (m <= 6.2d-182) then
tmp = cos(m_1) * t_0
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 = -0.25 * (m * m);
double tmp;
if (m <= -52.0) {
tmp = Math.cos(M) * Math.exp(t_0);
} else if (m <= -7.8e-255) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else if (m <= 6.2e-182) {
tmp = Math.cos(M) * t_0;
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = -0.25 * (m * m) tmp = 0 if m <= -52.0: tmp = math.cos(M) * math.exp(t_0) elif m <= -7.8e-255: tmp = math.cos(M) * math.exp((M * -M)) elif m <= 6.2e-182: tmp = math.cos(M) * t_0 else: tmp = math.cos(M) * math.exp((-0.25 * (n * n))) return tmp
function code(K, m, n, M, l) t_0 = Float64(-0.25 * Float64(m * m)) tmp = 0.0 if (m <= -52.0) tmp = Float64(cos(M) * exp(t_0)); elseif (m <= -7.8e-255) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); elseif (m <= 6.2e-182) tmp = Float64(cos(M) * t_0); 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 = -0.25 * (m * m); tmp = 0.0; if (m <= -52.0) tmp = cos(M) * exp(t_0); elseif (m <= -7.8e-255) tmp = cos(M) * exp((M * -M)); elseif (m <= 6.2e-182) tmp = cos(M) * t_0; 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[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -52.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[t$95$0], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -7.8e-255], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 6.2e-182], N[(N[Cos[M], $MachinePrecision] * t$95$0), $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 := -0.25 \cdot \left(m \cdot m\right)\\
\mathbf{if}\;m \leq -52:\\
\;\;\;\;\cos M \cdot e^{t_0}\\
\mathbf{elif}\;m \leq -7.8 \cdot 10^{-255}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{elif}\;m \leq 6.2 \cdot 10^{-182}:\\
\;\;\;\;\cos M \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -52Initial program 82.8%
*-commutative82.8%
associate-*r/82.8%
associate--r-82.8%
+-commutative82.8%
associate-+r-82.8%
unsub-neg82.8%
associate--r+82.8%
+-commutative82.8%
associate--r+82.8%
Simplified82.8%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in m around inf 95.5%
unpow295.5%
Simplified95.5%
if -52 < m < -7.8000000000000001e-255Initial program 79.3%
*-commutative79.3%
associate-*r/79.3%
associate--r-79.3%
+-commutative79.3%
associate-+r-79.3%
unsub-neg79.3%
associate--r+79.3%
+-commutative79.3%
associate--r+79.3%
Simplified79.3%
Taylor expanded in K around 0 98.3%
cos-neg98.3%
Simplified98.3%
Taylor expanded in M around inf 55.4%
mul-1-neg55.4%
unpow255.4%
distribute-rgt-neg-in55.4%
Simplified55.4%
if -7.8000000000000001e-255 < m < 6.20000000000000016e-182Initial program 83.0%
*-commutative83.0%
associate-*r/83.0%
associate--r-83.0%
+-commutative83.0%
associate-+r-83.0%
unsub-neg83.0%
associate--r+83.0%
+-commutative83.0%
associate--r+83.0%
Simplified83.0%
Taylor expanded in K around 0 93.1%
cos-neg93.1%
Simplified93.1%
Taylor expanded in m around inf 11.9%
unpow211.9%
Simplified11.9%
Taylor expanded in m around 0 11.9%
unpow211.9%
associate-*r*11.9%
metadata-eval11.9%
distribute-lft-neg-in11.9%
*-commutative11.9%
associate-*r*11.9%
distribute-lft1-in11.9%
distribute-rgt-neg-in11.9%
fma-def11.9%
distribute-rgt-neg-in11.9%
metadata-eval11.9%
Simplified11.9%
Taylor expanded in m around inf 78.1%
associate-*r*78.1%
unpow278.1%
Simplified78.1%
if 6.20000000000000016e-182 < m Initial program 76.8%
*-commutative76.8%
associate-*r/76.8%
associate--r-76.8%
+-commutative76.8%
associate-+r-76.8%
unsub-neg76.8%
associate--r+76.8%
+-commutative76.8%
associate--r+76.8%
Simplified76.8%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Taylor expanded in n around inf 51.3%
unpow251.3%
Simplified51.3%
Final simplification67.5%
(FPCore (K m n M l) :precision binary64 (if (<= n 5e+67) (* (cos M) (exp (- (- (- m n) 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 <= 5e+67) {
tmp = cos(M) * exp((((m - n) - 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 <= 5d+67) then
tmp = cos(m_1) * exp((((m - n) - 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 <= 5e+67) {
tmp = Math.cos(M) * Math.exp((((m - n) - 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 <= 5e+67: tmp = math.cos(M) * math.exp((((m - n) - 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 <= 5e+67) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(m - n) - 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 <= 5e+67) tmp = cos(M) * exp((((m - n) - 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, 5e+67], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 5 \cdot 10^{+67}:\\
\;\;\;\;\cos M \cdot e^{\left(\left(m - n\right) - \ell\right) - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 4.99999999999999976e67Initial program 84.3%
*-commutative84.3%
associate-*r/84.3%
associate--r-84.3%
+-commutative84.3%
associate-+r-84.3%
unsub-neg84.3%
associate--r+84.3%
+-commutative84.3%
associate--r+84.3%
Simplified84.3%
Taylor expanded in M around inf 58.9%
unpow258.9%
Simplified58.9%
Taylor expanded in K around 0 62.3%
cos-neg62.3%
*-commutative62.3%
exp-diff32.2%
fabs-sub32.2%
sub-neg32.2%
mul-1-neg32.2%
fabs-neg32.2%
exp-diff62.3%
fabs-neg62.3%
mul-1-neg62.3%
sub-neg62.3%
unpow262.3%
Simplified62.3%
fabs-sub62.3%
associate--r+62.3%
cancel-sign-sub-inv62.3%
add-sqr-sqrt34.6%
fabs-sqr34.6%
add-sqr-sqrt74.2%
Applied egg-rr74.2%
if 4.99999999999999976e67 < n Initial program 61.2%
*-commutative61.2%
associate-*r/61.2%
associate--r-61.2%
+-commutative61.2%
associate-+r-61.2%
unsub-neg61.2%
associate--r+61.2%
+-commutative61.2%
associate--r+61.2%
Simplified61.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification79.2%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -62.0) (not (<= M 26.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 <= -62.0) || !(M <= 26.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 <= (-62.0d0)) .or. (.not. (m_1 <= 26.5d0))) 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 <= -62.0) || !(M <= 26.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 <= -62.0) or not (M <= 26.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 <= -62.0) || !(M <= 26.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 <= -62.0) || ~((M <= 26.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, -62.0], N[Not[LessEqual[M, 26.5]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -62 \lor \neg \left(M \leq 26.5\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if M < -62 or 26.5 < M Initial program 81.6%
*-commutative81.6%
associate-*r/81.6%
associate--r-81.6%
+-commutative81.6%
associate-+r-81.6%
unsub-neg81.6%
associate--r+81.6%
+-commutative81.6%
associate--r+81.6%
Simplified81.6%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in M around inf 96.9%
mul-1-neg96.9%
unpow296.9%
distribute-rgt-neg-in96.9%
Simplified96.9%
if -62 < M < 26.5Initial program 78.2%
*-commutative78.2%
associate-*r/78.2%
associate--r-78.2%
+-commutative78.2%
associate-+r-78.2%
unsub-neg78.2%
associate--r+78.2%
+-commutative78.2%
associate--r+78.2%
Simplified78.2%
Taylor expanded in K around 0 94.8%
cos-neg94.8%
Simplified94.8%
Taylor expanded in l around inf 47.4%
mul-1-neg47.4%
Simplified47.4%
Final simplification71.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -3.2e-158) (not (<= m 6.2e-182))) (* (cos M) (exp (- l))) (* (cos M) (* -0.25 (* m m)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -3.2e-158) || !(m <= 6.2e-182)) {
tmp = cos(M) * exp(-l);
} else {
tmp = cos(M) * (-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 <= (-3.2d-158)) .or. (.not. (m <= 6.2d-182))) then
tmp = cos(m_1) * exp(-l)
else
tmp = cos(m_1) * ((-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 <= -3.2e-158) || !(m <= 6.2e-182)) {
tmp = Math.cos(M) * Math.exp(-l);
} else {
tmp = Math.cos(M) * (-0.25 * (m * m));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -3.2e-158) or not (m <= 6.2e-182): tmp = math.cos(M) * math.exp(-l) else: tmp = math.cos(M) * (-0.25 * (m * m)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -3.2e-158) || !(m <= 6.2e-182)) tmp = Float64(cos(M) * exp(Float64(-l))); else tmp = Float64(cos(M) * Float64(-0.25 * Float64(m * m))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -3.2e-158) || ~((m <= 6.2e-182))) tmp = cos(M) * exp(-l); else tmp = cos(M) * (-0.25 * (m * m)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -3.2e-158], N[Not[LessEqual[m, 6.2e-182]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.2 \cdot 10^{-158} \lor \neg \left(m \leq 6.2 \cdot 10^{-182}\right):\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot \left(-0.25 \cdot \left(m \cdot m\right)\right)\\
\end{array}
\end{array}
if m < -3.19999999999999996e-158 or 6.20000000000000016e-182 < m Initial program 78.9%
*-commutative78.9%
associate-*r/78.9%
associate--r-78.9%
+-commutative78.9%
associate-+r-78.9%
unsub-neg78.9%
associate--r+78.9%
+-commutative78.9%
associate--r+78.9%
Simplified78.9%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in l around inf 37.3%
mul-1-neg37.3%
Simplified37.3%
if -3.19999999999999996e-158 < m < 6.20000000000000016e-182Initial program 83.1%
*-commutative83.1%
associate-*r/83.1%
associate--r-83.1%
+-commutative83.1%
associate-+r-83.1%
unsub-neg83.1%
associate--r+83.1%
+-commutative83.1%
associate--r+83.1%
Simplified83.1%
Taylor expanded in K around 0 95.2%
cos-neg95.2%
Simplified95.2%
Taylor expanded in m around inf 10.8%
unpow210.8%
Simplified10.8%
Taylor expanded in m around 0 10.8%
unpow210.8%
associate-*r*10.8%
metadata-eval10.8%
distribute-lft-neg-in10.8%
*-commutative10.8%
associate-*r*10.8%
distribute-lft1-in10.8%
distribute-rgt-neg-in10.8%
fma-def10.8%
distribute-rgt-neg-in10.8%
metadata-eval10.8%
Simplified10.8%
Taylor expanded in m around inf 77.8%
associate-*r*77.8%
unpow277.8%
Simplified77.8%
Final simplification46.5%
(FPCore (K m n M l) :precision binary64 (if (<= m -3.6e-134) (cos M) (* (cos M) (* -0.25 (* m m)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -3.6e-134) {
tmp = cos(M);
} else {
tmp = cos(M) * (-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 <= (-3.6d-134)) then
tmp = cos(m_1)
else
tmp = cos(m_1) * ((-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 <= -3.6e-134) {
tmp = Math.cos(M);
} else {
tmp = Math.cos(M) * (-0.25 * (m * m));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -3.6e-134: tmp = math.cos(M) else: tmp = math.cos(M) * (-0.25 * (m * m)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -3.6e-134) tmp = cos(M); else tmp = Float64(cos(M) * Float64(-0.25 * Float64(m * m))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -3.6e-134) tmp = cos(M); else tmp = cos(M) * (-0.25 * (m * m)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -3.6e-134], N[Cos[M], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.6 \cdot 10^{-134}:\\
\;\;\;\;\cos M\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot \left(-0.25 \cdot \left(m \cdot m\right)\right)\\
\end{array}
\end{array}
if m < -3.5999999999999999e-134Initial program 79.6%
*-commutative79.6%
associate-*r/79.6%
associate--r-79.6%
+-commutative79.6%
associate-+r-79.6%
unsub-neg79.6%
associate--r+79.6%
+-commutative79.6%
associate--r+79.6%
Simplified79.6%
Taylor expanded in K around 0 97.8%
cos-neg97.8%
Simplified97.8%
Taylor expanded in m around inf 70.2%
unpow270.2%
Simplified70.2%
Taylor expanded in m around 0 6.6%
if -3.5999999999999999e-134 < m Initial program 80.0%
*-commutative80.0%
associate-*r/80.0%
associate--r-80.0%
+-commutative80.0%
associate-+r-80.0%
unsub-neg80.0%
associate--r+80.0%
+-commutative80.0%
associate--r+80.0%
Simplified80.0%
Taylor expanded in K around 0 96.5%
cos-neg96.5%
Simplified96.5%
Taylor expanded in m around inf 40.8%
unpow240.8%
Simplified40.8%
Taylor expanded in m around 0 8.3%
unpow28.3%
associate-*r*8.3%
metadata-eval8.3%
distribute-lft-neg-in8.3%
*-commutative8.3%
associate-*r*8.3%
distribute-lft1-in8.3%
distribute-rgt-neg-in8.3%
fma-def8.3%
distribute-rgt-neg-in8.3%
metadata-eval8.3%
Simplified8.3%
Taylor expanded in m around inf 32.3%
associate-*r*32.3%
unpow232.3%
Simplified32.3%
Final simplification22.9%
(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.9%
*-commutative79.9%
associate-*r/79.9%
associate--r-79.9%
+-commutative79.9%
associate-+r-79.9%
unsub-neg79.9%
associate--r+79.9%
+-commutative79.9%
associate--r+79.9%
Simplified79.9%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in m around inf 51.5%
unpow251.5%
Simplified51.5%
Taylor expanded in m around 0 7.9%
Final simplification7.9%
herbie shell --seed 2023200
(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)))))))