
(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 (exp (- (- (fabs (- n m)) l) (pow (- (/ (+ m n) 2.0) M) 2.0))))
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((n - m)) - 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 = exp(((abs((n - m)) - 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.exp(((Math.abs((n - m)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.exp(((math.fabs((n - m)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((n - m)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 81.3%
associate-/l*81.7%
+-commutative81.7%
fabs-sub81.7%
+-commutative81.7%
Simplified81.7%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in M around 0 97.0%
Final simplification97.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- (pow M 2.0)))))
(if (<= m -6.5e-6)
(exp (* -0.25 (pow m 2.0)))
(if (<= m -5.6e-149)
t_0
(if (<= m -3.3e-168)
(/ (cos M) (exp l))
(if (<= m -2.1e-286) t_0 (* (cos M) (exp (* -0.25 (pow n 2.0))))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-pow(M, 2.0));
double tmp;
if (m <= -6.5e-6) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= -5.6e-149) {
tmp = t_0;
} else if (m <= -3.3e-168) {
tmp = cos(M) / exp(l);
} else if (m <= -2.1e-286) {
tmp = t_0;
} else {
tmp = cos(M) * exp((-0.25 * pow(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 = exp(-(m_1 ** 2.0d0))
if (m <= (-6.5d-6)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= (-5.6d-149)) then
tmp = t_0
else if (m <= (-3.3d-168)) then
tmp = cos(m_1) / exp(l)
else if (m <= (-2.1d-286)) then
tmp = t_0
else
tmp = cos(m_1) * exp(((-0.25d0) * (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.exp(-Math.pow(M, 2.0));
double tmp;
if (m <= -6.5e-6) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= -5.6e-149) {
tmp = t_0;
} else if (m <= -3.3e-168) {
tmp = Math.cos(M) / Math.exp(l);
} else if (m <= -2.1e-286) {
tmp = t_0;
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-math.pow(M, 2.0)) tmp = 0 if m <= -6.5e-6: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= -5.6e-149: tmp = t_0 elif m <= -3.3e-168: tmp = math.cos(M) / math.exp(l) elif m <= -2.1e-286: tmp = t_0 else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-(M ^ 2.0))) tmp = 0.0 if (m <= -6.5e-6) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= -5.6e-149) tmp = t_0; elseif (m <= -3.3e-168) tmp = Float64(cos(M) / exp(l)); elseif (m <= -2.1e-286) tmp = t_0; else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-(M ^ 2.0)); tmp = 0.0; if (m <= -6.5e-6) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= -5.6e-149) tmp = t_0; elseif (m <= -3.3e-168) tmp = cos(M) / exp(l); elseif (m <= -2.1e-286) tmp = t_0; else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]}, If[LessEqual[m, -6.5e-6], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -5.6e-149], t$95$0, If[LessEqual[m, -3.3e-168], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -2.1e-286], t$95$0, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-{M}^{2}}\\
\mathbf{if}\;m \leq -6.5 \cdot 10^{-6}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq -5.6 \cdot 10^{-149}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;m \leq -3.3 \cdot 10^{-168}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{elif}\;m \leq -2.1 \cdot 10^{-286}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if m < -6.4999999999999996e-6Initial program 72.5%
associate-/l*72.5%
+-commutative72.5%
fabs-sub72.5%
+-commutative72.5%
Simplified72.5%
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.1%
if -6.4999999999999996e-6 < m < -5.5999999999999997e-149 or -3.3000000000000001e-168 < m < -2.09999999999999988e-286Initial program 81.4%
associate-/l*81.4%
+-commutative81.4%
fabs-sub81.4%
+-commutative81.4%
Simplified81.4%
Taylor expanded in K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Taylor expanded in M around 0 94.9%
Taylor expanded in M around inf 58.9%
mul-1-neg58.9%
Simplified58.9%
if -5.5999999999999997e-149 < m < -3.3000000000000001e-168Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
fabs-sub100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around inf 61.3%
mul-1-neg61.3%
Simplified61.3%
Taylor expanded in l around -inf 61.3%
neg-mul-161.3%
exp-neg61.3%
associate-*r/61.3%
*-rgt-identity61.3%
Simplified61.3%
if -2.09999999999999988e-286 < m Initial program 83.7%
associate-/l*84.4%
+-commutative84.4%
fabs-sub84.4%
+-commutative84.4%
Simplified84.4%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in n around inf 61.0%
Final simplification67.9%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- (pow M 2.0)))) (t_1 (exp (* -0.25 (pow m 2.0)))))
(if (<= m -6.5e-6)
t_1
(if (<= m -3.6e-149)
t_0
(if (<= m -3.1e-168) (/ (cos M) (exp l)) (if (<= m 53.0) t_0 t_1))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-pow(M, 2.0));
double t_1 = exp((-0.25 * pow(m, 2.0)));
double tmp;
if (m <= -6.5e-6) {
tmp = t_1;
} else if (m <= -3.6e-149) {
tmp = t_0;
} else if (m <= -3.1e-168) {
tmp = cos(M) / exp(l);
} else if (m <= 53.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 = exp(-(m_1 ** 2.0d0))
t_1 = exp(((-0.25d0) * (m ** 2.0d0)))
if (m <= (-6.5d-6)) then
tmp = t_1
else if (m <= (-3.6d-149)) then
tmp = t_0
else if (m <= (-3.1d-168)) then
tmp = cos(m_1) / exp(l)
else if (m <= 53.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.exp(-Math.pow(M, 2.0));
double t_1 = Math.exp((-0.25 * Math.pow(m, 2.0)));
double tmp;
if (m <= -6.5e-6) {
tmp = t_1;
} else if (m <= -3.6e-149) {
tmp = t_0;
} else if (m <= -3.1e-168) {
tmp = Math.cos(M) / Math.exp(l);
} else if (m <= 53.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-math.pow(M, 2.0)) t_1 = math.exp((-0.25 * math.pow(m, 2.0))) tmp = 0 if m <= -6.5e-6: tmp = t_1 elif m <= -3.6e-149: tmp = t_0 elif m <= -3.1e-168: tmp = math.cos(M) / math.exp(l) elif m <= 53.0: tmp = t_0 else: tmp = t_1 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-(M ^ 2.0))) t_1 = exp(Float64(-0.25 * (m ^ 2.0))) tmp = 0.0 if (m <= -6.5e-6) tmp = t_1; elseif (m <= -3.6e-149) tmp = t_0; elseif (m <= -3.1e-168) tmp = Float64(cos(M) / exp(l)); elseif (m <= 53.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-(M ^ 2.0)); t_1 = exp((-0.25 * (m ^ 2.0))); tmp = 0.0; if (m <= -6.5e-6) tmp = t_1; elseif (m <= -3.6e-149) tmp = t_0; elseif (m <= -3.1e-168) tmp = cos(M) / exp(l); elseif (m <= 53.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -6.5e-6], t$95$1, If[LessEqual[m, -3.6e-149], t$95$0, If[LessEqual[m, -3.1e-168], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 53.0], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-{M}^{2}}\\
t_1 := e^{-0.25 \cdot {m}^{2}}\\
\mathbf{if}\;m \leq -6.5 \cdot 10^{-6}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;m \leq -3.6 \cdot 10^{-149}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;m \leq -3.1 \cdot 10^{-168}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{elif}\;m \leq 53:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if m < -6.4999999999999996e-6 or 53 < m Initial program 79.3%
associate-/l*79.3%
+-commutative79.3%
fabs-sub79.3%
+-commutative79.3%
Simplified79.3%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in M around 0 99.2%
Taylor expanded in m around inf 98.4%
if -6.4999999999999996e-6 < m < -3.6000000000000002e-149 or -3.1e-168 < m < 53Initial program 82.3%
associate-/l*83.1%
+-commutative83.1%
fabs-sub83.1%
+-commutative83.1%
Simplified83.1%
Taylor expanded in K around 0 94.8%
cos-neg94.8%
Simplified94.8%
Taylor expanded in M around 0 94.8%
Taylor expanded in M around inf 56.2%
mul-1-neg56.2%
Simplified56.2%
if -3.6000000000000002e-149 < m < -3.1e-168Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
fabs-sub100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around inf 61.3%
mul-1-neg61.3%
Simplified61.3%
Taylor expanded in l around -inf 61.3%
neg-mul-161.3%
exp-neg61.3%
associate-*r/61.3%
*-rgt-identity61.3%
Simplified61.3%
Final simplification76.2%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- (pow M 2.0)))))
(if (<= m -6.5e-6)
(exp (* -0.25 (pow m 2.0)))
(if (<= m -3.7e-149)
t_0
(if (<= m -1.5e-168)
(/ (cos M) (exp l))
(if (<= m -3.25e-286) t_0 (exp (* -0.25 (pow n 2.0)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-pow(M, 2.0));
double tmp;
if (m <= -6.5e-6) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= -3.7e-149) {
tmp = t_0;
} else if (m <= -1.5e-168) {
tmp = cos(M) / exp(l);
} else if (m <= -3.25e-286) {
tmp = t_0;
} else {
tmp = exp((-0.25 * pow(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 = exp(-(m_1 ** 2.0d0))
if (m <= (-6.5d-6)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= (-3.7d-149)) then
tmp = t_0
else if (m <= (-1.5d-168)) then
tmp = cos(m_1) / exp(l)
else if (m <= (-3.25d-286)) then
tmp = t_0
else
tmp = exp(((-0.25d0) * (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.exp(-Math.pow(M, 2.0));
double tmp;
if (m <= -6.5e-6) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= -3.7e-149) {
tmp = t_0;
} else if (m <= -1.5e-168) {
tmp = Math.cos(M) / Math.exp(l);
} else if (m <= -3.25e-286) {
tmp = t_0;
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-math.pow(M, 2.0)) tmp = 0 if m <= -6.5e-6: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= -3.7e-149: tmp = t_0 elif m <= -1.5e-168: tmp = math.cos(M) / math.exp(l) elif m <= -3.25e-286: tmp = t_0 else: tmp = math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-(M ^ 2.0))) tmp = 0.0 if (m <= -6.5e-6) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= -3.7e-149) tmp = t_0; elseif (m <= -1.5e-168) tmp = Float64(cos(M) / exp(l)); elseif (m <= -3.25e-286) tmp = t_0; else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-(M ^ 2.0)); tmp = 0.0; if (m <= -6.5e-6) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= -3.7e-149) tmp = t_0; elseif (m <= -1.5e-168) tmp = cos(M) / exp(l); elseif (m <= -3.25e-286) tmp = t_0; else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]}, If[LessEqual[m, -6.5e-6], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -3.7e-149], t$95$0, If[LessEqual[m, -1.5e-168], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -3.25e-286], t$95$0, N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-{M}^{2}}\\
\mathbf{if}\;m \leq -6.5 \cdot 10^{-6}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq -3.7 \cdot 10^{-149}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;m \leq -1.5 \cdot 10^{-168}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{elif}\;m \leq -3.25 \cdot 10^{-286}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if m < -6.4999999999999996e-6Initial program 72.5%
associate-/l*72.5%
+-commutative72.5%
fabs-sub72.5%
+-commutative72.5%
Simplified72.5%
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.1%
if -6.4999999999999996e-6 < m < -3.6999999999999999e-149 or -1.49999999999999996e-168 < m < -3.2500000000000002e-286Initial program 81.4%
associate-/l*81.4%
+-commutative81.4%
fabs-sub81.4%
+-commutative81.4%
Simplified81.4%
Taylor expanded in K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Taylor expanded in M around 0 94.9%
Taylor expanded in M around inf 58.9%
mul-1-neg58.9%
Simplified58.9%
if -3.6999999999999999e-149 < m < -1.49999999999999996e-168Initial program 100.0%
associate-/l*100.0%
+-commutative100.0%
fabs-sub100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around inf 61.3%
mul-1-neg61.3%
Simplified61.3%
Taylor expanded in l around -inf 61.3%
neg-mul-161.3%
exp-neg61.3%
associate-*r/61.3%
*-rgt-identity61.3%
Simplified61.3%
if -3.2500000000000002e-286 < m Initial program 83.7%
associate-/l*84.4%
+-commutative84.4%
fabs-sub84.4%
+-commutative84.4%
Simplified84.4%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in M around 0 96.6%
Taylor expanded in n around inf 61.0%
Final simplification67.9%
(FPCore (K m n M l) :precision binary64 (if (<= l -740.0) (* (cos M) (exp l)) (if (<= l 1.02e-10) (exp (- (pow M 2.0))) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -740.0) {
tmp = cos(M) * exp(l);
} else if (l <= 1.02e-10) {
tmp = exp(-pow(M, 2.0));
} 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 (l <= (-740.0d0)) then
tmp = cos(m_1) * exp(l)
else if (l <= 1.02d-10) then
tmp = exp(-(m_1 ** 2.0d0))
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 (l <= -740.0) {
tmp = Math.cos(M) * Math.exp(l);
} else if (l <= 1.02e-10) {
tmp = Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -740.0: tmp = math.cos(M) * math.exp(l) elif l <= 1.02e-10: tmp = math.exp(-math.pow(M, 2.0)) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -740.0) tmp = Float64(cos(M) * exp(l)); elseif (l <= 1.02e-10) tmp = exp(Float64(-(M ^ 2.0))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -740.0) tmp = cos(M) * exp(l); elseif (l <= 1.02e-10) tmp = exp(-(M ^ 2.0)); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -740.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.02e-10], N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -740:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{elif}\;\ell \leq 1.02 \cdot 10^{-10}:\\
\;\;\;\;e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < -740Initial program 79.0%
associate-/l*80.6%
+-commutative80.6%
fabs-sub80.6%
+-commutative80.6%
Simplified80.6%
Taylor expanded in K around 0 91.9%
cos-neg91.9%
Simplified91.9%
Taylor expanded in l around inf 23.7%
mul-1-neg23.7%
Simplified23.7%
expm1-log1p-u21.7%
expm1-udef21.7%
add-sqr-sqrt21.7%
sqrt-unprod21.7%
sqr-neg21.7%
sqrt-unprod0.0%
add-sqr-sqrt69.8%
Applied egg-rr69.8%
expm1-def69.8%
expm1-log1p69.8%
Simplified69.8%
if -740 < l < 1.01999999999999997e-10Initial program 79.3%
associate-/l*79.3%
+-commutative79.3%
fabs-sub79.3%
+-commutative79.3%
Simplified79.3%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
Simplified97.9%
Taylor expanded in M around 0 97.9%
Taylor expanded in M around inf 58.5%
mul-1-neg58.5%
Simplified58.5%
if 1.01999999999999997e-10 < l Initial program 87.5%
associate-/l*87.5%
+-commutative87.5%
fabs-sub87.5%
+-commutative87.5%
Simplified87.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around inf 97.0%
mul-1-neg97.0%
Simplified97.0%
Taylor expanded in M around 0 97.0%
Final simplification70.9%
(FPCore (K m n M l) :precision binary64 (if (<= l -580.0) (* (cos M) (exp l)) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -580.0) {
tmp = cos(M) * exp(l);
} 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 (l <= (-580.0d0)) then
tmp = cos(m_1) * exp(l)
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 (l <= -580.0) {
tmp = Math.cos(M) * Math.exp(l);
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -580.0: tmp = math.cos(M) * math.exp(l) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -580.0) tmp = Float64(cos(M) * exp(l)); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -580.0) tmp = cos(M) * exp(l); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -580.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -580:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < -580Initial program 79.0%
associate-/l*80.6%
+-commutative80.6%
fabs-sub80.6%
+-commutative80.6%
Simplified80.6%
Taylor expanded in K around 0 91.9%
cos-neg91.9%
Simplified91.9%
Taylor expanded in l around inf 23.7%
mul-1-neg23.7%
Simplified23.7%
expm1-log1p-u21.7%
expm1-udef21.7%
add-sqr-sqrt21.7%
sqrt-unprod21.7%
sqr-neg21.7%
sqrt-unprod0.0%
add-sqr-sqrt69.8%
Applied egg-rr69.8%
expm1-def69.8%
expm1-log1p69.8%
Simplified69.8%
if -580 < l Initial program 82.0%
associate-/l*82.0%
+-commutative82.0%
fabs-sub82.0%
+-commutative82.0%
Simplified82.0%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in l around inf 39.1%
mul-1-neg39.1%
Simplified39.1%
Taylor expanded in M around 0 39.1%
Final simplification46.6%
(FPCore (K m n M l) :precision binary64 (if (<= l -660.0) (* (cos M) (exp l)) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -660.0) {
tmp = cos(M) * exp(l);
} 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 (l <= (-660.0d0)) then
tmp = cos(m_1) * exp(l)
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 (l <= -660.0) {
tmp = Math.cos(M) * Math.exp(l);
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -660.0: tmp = math.cos(M) * math.exp(l) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -660.0) tmp = Float64(cos(M) * exp(l)); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -660.0) tmp = cos(M) * exp(l); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -660.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -660:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if l < -660Initial program 79.0%
associate-/l*80.6%
+-commutative80.6%
fabs-sub80.6%
+-commutative80.6%
Simplified80.6%
Taylor expanded in K around 0 91.9%
cos-neg91.9%
Simplified91.9%
Taylor expanded in l around inf 23.7%
mul-1-neg23.7%
Simplified23.7%
expm1-log1p-u21.7%
expm1-udef21.7%
add-sqr-sqrt21.7%
sqrt-unprod21.7%
sqr-neg21.7%
sqrt-unprod0.0%
add-sqr-sqrt69.8%
Applied egg-rr69.8%
expm1-def69.8%
expm1-log1p69.8%
Simplified69.8%
if -660 < l Initial program 82.0%
associate-/l*82.0%
+-commutative82.0%
fabs-sub82.0%
+-commutative82.0%
Simplified82.0%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in l around inf 39.1%
mul-1-neg39.1%
Simplified39.1%
Taylor expanded in l around -inf 39.1%
neg-mul-139.1%
exp-neg39.1%
associate-*r/39.1%
*-rgt-identity39.1%
Simplified39.1%
Final simplification46.6%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return exp(-l);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 81.3%
associate-/l*81.7%
+-commutative81.7%
fabs-sub81.7%
+-commutative81.7%
Simplified81.7%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in l around inf 35.4%
mul-1-neg35.4%
Simplified35.4%
Taylor expanded in M around 0 35.4%
Final simplification35.4%
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
def code(K, m, n, M, l): return math.cos(M)
function code(K, m, n, M, l) return cos(M) end
function tmp = code(K, m, n, M, l) tmp = cos(M); end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
\\
\cos M
\end{array}
Initial program 81.3%
associate-/l*81.7%
+-commutative81.7%
fabs-sub81.7%
+-commutative81.7%
Simplified81.7%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in l around inf 35.4%
mul-1-neg35.4%
Simplified35.4%
Taylor expanded in l around 0 6.6%
Final simplification6.6%
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
return 1.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 = 1.0d0
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0;
}
def code(K, m, n, M, l): return 1.0
function code(K, m, n, M, l) return 1.0 end
function tmp = code(K, m, n, M, l) tmp = 1.0; end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 81.3%
associate-/l*81.7%
+-commutative81.7%
fabs-sub81.7%
+-commutative81.7%
Simplified81.7%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in l around inf 35.4%
mul-1-neg35.4%
Simplified35.4%
Taylor expanded in l around 0 6.6%
Taylor expanded in M around 0 6.6%
Final simplification6.6%
herbie shell --seed 2024019
(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)))))))