
(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 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- n m)) 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((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 = cos(m_1) * 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.cos(M) * 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.cos(M) * math.exp(((math.fabs((n - m)) - 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(n - m)) - 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((n - m)) - 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[(n - m), $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|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 77.1%
associate-/l*76.8%
+-commutative76.8%
fabs-sub76.8%
+-commutative76.8%
Simplified76.8%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Final simplification97.4%
(FPCore (K m n M l)
:precision binary64
(if (<= m -65000000000000.0)
(exp (* -0.25 (pow m 2.0)))
(if (<= m -2.6e-280)
(* (cos (- (/ (* m K) 2.0) M)) (exp (- l)))
(if (or (<= m 3.3e-149) (not (<= m 1.45e-87)))
(* (cos M) (exp (* -0.25 (pow n 2.0))))
(* (cos M) (exp (- (pow M 2.0))))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -65000000000000.0) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= -2.6e-280) {
tmp = cos((((m * K) / 2.0) - M)) * exp(-l);
} else if ((m <= 3.3e-149) || !(m <= 1.45e-87)) {
tmp = cos(M) * exp((-0.25 * pow(n, 2.0)));
} else {
tmp = cos(M) * exp(-pow(M, 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) :: tmp
if (m <= (-65000000000000.0d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= (-2.6d-280)) then
tmp = cos((((m * k) / 2.0d0) - m_1)) * exp(-l)
else if ((m <= 3.3d-149) .or. (.not. (m <= 1.45d-87))) then
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
else
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -65000000000000.0) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= -2.6e-280) {
tmp = Math.cos((((m * K) / 2.0) - M)) * Math.exp(-l);
} else if ((m <= 3.3e-149) || !(m <= 1.45e-87)) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -65000000000000.0: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= -2.6e-280: tmp = math.cos((((m * K) / 2.0) - M)) * math.exp(-l) elif (m <= 3.3e-149) or not (m <= 1.45e-87): tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) else: tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -65000000000000.0) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= -2.6e-280) tmp = Float64(cos(Float64(Float64(Float64(m * K) / 2.0) - M)) * exp(Float64(-l))); elseif ((m <= 3.3e-149) || !(m <= 1.45e-87)) tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -65000000000000.0) tmp = exp((-0.25 * (m ^ 2.0))); elseif (m <= -2.6e-280) tmp = cos((((m * K) / 2.0) - M)) * exp(-l); elseif ((m <= 3.3e-149) || ~((m <= 1.45e-87))) tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); else tmp = cos(M) * exp(-(M ^ 2.0)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -65000000000000.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -2.6e-280], N[(N[Cos[N[(N[(N[(m * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[m, 3.3e-149], N[Not[LessEqual[m, 1.45e-87]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -65000000000000:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq -2.6 \cdot 10^{-280}:\\
\;\;\;\;\cos \left(\frac{m \cdot K}{2} - M\right) \cdot e^{-\ell}\\
\mathbf{elif}\;m \leq 3.3 \cdot 10^{-149} \lor \neg \left(m \leq 1.45 \cdot 10^{-87}\right):\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\end{array}
\end{array}
if m < -6.5e13Initial program 73.0%
associate-/l*73.0%
+-commutative73.0%
fabs-sub73.0%
+-commutative73.0%
Simplified73.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 96.9%
Taylor expanded in M around 0 96.9%
if -6.5e13 < m < -2.6e-280Initial program 82.0%
Taylor expanded in l around inf 44.5%
mul-1-neg44.5%
Simplified44.5%
Taylor expanded in m around inf 53.4%
if -2.6e-280 < m < 3.30000000000000017e-149 or 1.45e-87 < m Initial program 74.3%
Taylor expanded in n around inf 42.9%
*-commutative42.9%
Simplified42.9%
Taylor expanded in K around 0 61.7%
cos-neg61.7%
Simplified61.7%
if 3.30000000000000017e-149 < m < 1.45e-87Initial program 93.0%
associate-/l*93.8%
+-commutative93.8%
fabs-sub93.8%
+-commutative93.8%
Simplified93.8%
Taylor expanded in K around 0 93.0%
cos-neg93.0%
Simplified93.0%
Taylor expanded in M around inf 51.5%
mul-1-neg51.5%
Simplified51.5%
Final simplification67.5%
(FPCore (K m n M l)
:precision binary64
(if (<= m -1e+16)
(exp (* -0.25 (pow m 2.0)))
(*
(cos M)
(exp (- (* (+ m (- (* n 0.5) M)) (- M (* n 0.5))) (- l (fabs (- n m))))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1e+16) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(M) * exp((((m + ((n * 0.5) - M)) * (M - (n * 0.5))) - (l - fabs((n - 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 <= (-1d+16)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(m_1) * exp((((m + ((n * 0.5d0) - m_1)) * (m_1 - (n * 0.5d0))) - (l - abs((n - 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 <= -1e+16) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp((((m + ((n * 0.5) - M)) * (M - (n * 0.5))) - (l - Math.abs((n - m)))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1e+16: tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp((((m + ((n * 0.5) - M)) * (M - (n * 0.5))) - (l - math.fabs((n - m))))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1e+16) tmp = exp(Float64(-0.25 * (m ^ 2.0))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(m + Float64(Float64(n * 0.5) - M)) * Float64(M - Float64(n * 0.5))) - Float64(l - abs(Float64(n - m)))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1e+16) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp((((m + ((n * 0.5) - M)) * (M - (n * 0.5))) - (l - abs((n - m))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1e+16], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(m + N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(l - N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1 \cdot 10^{+16}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m + \left(n \cdot 0.5 - M\right)\right) \cdot \left(M - n \cdot 0.5\right) - \left(\ell - \left|n - m\right|\right)}\\
\end{array}
\end{array}
if m < -1e16Initial program 73.0%
associate-/l*73.0%
+-commutative73.0%
fabs-sub73.0%
+-commutative73.0%
Simplified73.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 96.9%
Taylor expanded in M around 0 96.9%
if -1e16 < m Initial program 78.4%
associate-/l*78.0%
+-commutative78.0%
fabs-sub78.0%
+-commutative78.0%
Simplified78.0%
Taylor expanded in K around 0 96.5%
cos-neg96.5%
Simplified96.5%
Taylor expanded in m around 0 84.2%
+-commutative84.2%
unpow284.2%
distribute-rgt-out88.4%
*-commutative88.4%
*-commutative88.4%
Simplified88.4%
Final simplification90.5%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (* -0.25 (pow m 2.0)))))
(if (<= m -65000000000000.0)
t_0
(if (<= m -3.4e-280)
(* (cos (- (/ (* m K) 2.0) M)) (exp (- l)))
(if (<= m 53.0) (* (cos M) (exp (- (pow M 2.0)))) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp((-0.25 * pow(m, 2.0)));
double tmp;
if (m <= -65000000000000.0) {
tmp = t_0;
} else if (m <= -3.4e-280) {
tmp = cos((((m * K) / 2.0) - M)) * exp(-l);
} else if (m <= 53.0) {
tmp = cos(M) * exp(-pow(M, 2.0));
} 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(((-0.25d0) * (m ** 2.0d0)))
if (m <= (-65000000000000.0d0)) then
tmp = t_0
else if (m <= (-3.4d-280)) then
tmp = cos((((m * k) / 2.0d0) - m_1)) * exp(-l)
else if (m <= 53.0d0) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
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.exp((-0.25 * Math.pow(m, 2.0)));
double tmp;
if (m <= -65000000000000.0) {
tmp = t_0;
} else if (m <= -3.4e-280) {
tmp = Math.cos((((m * K) / 2.0) - M)) * Math.exp(-l);
} else if (m <= 53.0) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp((-0.25 * math.pow(m, 2.0))) tmp = 0 if m <= -65000000000000.0: tmp = t_0 elif m <= -3.4e-280: tmp = math.cos((((m * K) / 2.0) - M)) * math.exp(-l) elif m <= 53.0: tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-0.25 * (m ^ 2.0))) tmp = 0.0 if (m <= -65000000000000.0) tmp = t_0; elseif (m <= -3.4e-280) tmp = Float64(cos(Float64(Float64(Float64(m * K) / 2.0) - M)) * exp(Float64(-l))); elseif (m <= 53.0) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp((-0.25 * (m ^ 2.0))); tmp = 0.0; if (m <= -65000000000000.0) tmp = t_0; elseif (m <= -3.4e-280) tmp = cos((((m * K) / 2.0) - M)) * exp(-l); elseif (m <= 53.0) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -65000000000000.0], t$95$0, If[LessEqual[m, -3.4e-280], N[(N[Cos[N[(N[(N[(m * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 53.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot {m}^{2}}\\
\mathbf{if}\;m \leq -65000000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;m \leq -3.4 \cdot 10^{-280}:\\
\;\;\;\;\cos \left(\frac{m \cdot K}{2} - M\right) \cdot e^{-\ell}\\
\mathbf{elif}\;m \leq 53:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if m < -6.5e13 or 53 < m Initial program 69.7%
associate-/l*69.7%
+-commutative69.7%
fabs-sub69.7%
+-commutative69.7%
Simplified69.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 97.6%
Taylor expanded in M around 0 97.6%
if -6.5e13 < m < -3.3999999999999998e-280Initial program 82.0%
Taylor expanded in l around inf 44.5%
mul-1-neg44.5%
Simplified44.5%
Taylor expanded in m around inf 53.4%
if -3.3999999999999998e-280 < m < 53Initial program 86.0%
associate-/l*86.1%
+-commutative86.1%
fabs-sub86.1%
+-commutative86.1%
Simplified86.1%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Taylor expanded in M around inf 63.5%
mul-1-neg63.5%
Simplified63.5%
Final simplification77.0%
(FPCore (K m n M l) :precision binary64 (if (<= l -2.4e-37) (* (cos M) (exp l)) (if (<= l 5.4e-11) (exp (* -0.25 (pow m 2.0))) (/ (cos M) (exp l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -2.4e-37) {
tmp = cos(M) * exp(l);
} else if (l <= 5.4e-11) {
tmp = exp((-0.25 * pow(m, 2.0)));
} 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 <= (-2.4d-37)) then
tmp = cos(m_1) * exp(l)
else if (l <= 5.4d-11) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
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 <= -2.4e-37) {
tmp = Math.cos(M) * Math.exp(l);
} else if (l <= 5.4e-11) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -2.4e-37: tmp = math.cos(M) * math.exp(l) elif l <= 5.4e-11: tmp = math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -2.4e-37) tmp = Float64(cos(M) * exp(l)); elseif (l <= 5.4e-11) tmp = exp(Float64(-0.25 * (m ^ 2.0))); 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 <= -2.4e-37) tmp = cos(M) * exp(l); elseif (l <= 5.4e-11) tmp = exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -2.4e-37], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.4e-11], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2.4 \cdot 10^{-37}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{elif}\;\ell \leq 5.4 \cdot 10^{-11}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if l < -2.39999999999999991e-37Initial program 71.5%
associate-/l*70.0%
+-commutative70.0%
fabs-sub70.0%
+-commutative70.0%
Simplified70.0%
Taylor expanded in K around 0 95.7%
cos-neg95.7%
Simplified95.7%
Taylor expanded in l around inf 25.5%
neg-mul-125.5%
Simplified25.5%
expm1-log1p-u23.7%
expm1-udef23.7%
add-sqr-sqrt23.7%
sqrt-unprod23.7%
sqr-neg23.7%
sqrt-unprod0.0%
add-sqr-sqrt69.1%
Applied egg-rr69.1%
expm1-def69.1%
expm1-log1p69.1%
Simplified69.1%
if -2.39999999999999991e-37 < l < 5.40000000000000009e-11Initial program 80.3%
associate-/l*80.4%
+-commutative80.4%
fabs-sub80.4%
+-commutative80.4%
Simplified80.4%
Taylor expanded in K around 0 97.7%
cos-neg97.7%
Simplified97.7%
Taylor expanded in m around inf 64.0%
Taylor expanded in M around 0 64.0%
if 5.40000000000000009e-11 < l Initial program 77.4%
associate-/l*77.4%
+-commutative77.4%
fabs-sub77.4%
+-commutative77.4%
Simplified77.4%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in l around inf 95.8%
neg-mul-195.8%
Simplified95.8%
exp-neg95.8%
un-div-inv95.8%
Applied egg-rr95.8%
Final simplification74.1%
(FPCore (K m n M l) :precision binary64 (if (<= l 1e-5) (* (cos M) (exp l)) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 1e-5) {
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 <= 1d-5) 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 <= 1e-5) {
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 <= 1e-5: 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 <= 1e-5) 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 <= 1e-5) tmp = cos(M) * exp(l); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 1e-5], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 10^{-5}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < 1.00000000000000008e-5Initial program 76.6%
associate-/l*76.1%
+-commutative76.1%
fabs-sub76.1%
+-commutative76.1%
Simplified76.1%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in l around inf 17.7%
neg-mul-117.7%
Simplified17.7%
expm1-log1p-u17.0%
expm1-udef17.0%
add-sqr-sqrt12.6%
sqrt-unprod17.0%
sqr-neg17.0%
sqrt-unprod4.4%
add-sqr-sqrt34.0%
Applied egg-rr34.0%
expm1-def34.0%
expm1-log1p34.0%
Simplified34.0%
if 1.00000000000000008e-5 < l Initial program 78.6%
associate-/l*78.6%
+-commutative78.6%
fabs-sub78.6%
+-commutative78.6%
Simplified78.6%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in l around inf 97.2%
neg-mul-197.2%
Simplified97.2%
Taylor expanded in M around 0 97.2%
Final simplification51.0%
(FPCore (K m n M l) :precision binary64 (if (<= l -5e-64) (* (cos M) (exp l)) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -5e-64) {
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 <= (-5d-64)) 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 <= -5e-64) {
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 <= -5e-64: 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 <= -5e-64) 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 <= -5e-64) 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, -5e-64], 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 -5 \cdot 10^{-64}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if l < -5.00000000000000033e-64Initial program 73.4%
associate-/l*72.2%
+-commutative72.2%
fabs-sub72.2%
+-commutative72.2%
Simplified72.2%
Taylor expanded in K around 0 96.2%
cos-neg96.2%
Simplified96.2%
Taylor expanded in l around inf 22.9%
neg-mul-122.9%
Simplified22.9%
expm1-log1p-u21.3%
expm1-udef21.3%
add-sqr-sqrt21.3%
sqrt-unprod21.3%
sqr-neg21.3%
sqrt-unprod0.0%
add-sqr-sqrt61.6%
Applied egg-rr61.6%
expm1-def61.6%
expm1-log1p61.6%
Simplified61.6%
if -5.00000000000000033e-64 < l Initial program 78.8%
associate-/l*78.8%
+-commutative78.8%
fabs-sub78.8%
+-commutative78.8%
Simplified78.8%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
Simplified97.9%
Taylor expanded in l around inf 46.3%
neg-mul-146.3%
Simplified46.3%
exp-neg46.3%
un-div-inv46.3%
Applied egg-rr46.3%
Final simplification51.0%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return exp(-l);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 77.1%
associate-/l*76.8%
+-commutative76.8%
fabs-sub76.8%
+-commutative76.8%
Simplified76.8%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in l around inf 39.1%
neg-mul-139.1%
Simplified39.1%
Taylor expanded in M around 0 39.1%
Final simplification39.1%
herbie shell --seed 2024011
(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)))))))