
(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}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (<= n 5e+70) (exp (+ (* (+ n (- (* m 0.5) M)) (- M (* m 0.5))) (- (fabs (- n m)) l))) (* (cos M) (exp (* -0.25 (pow n 2.0))))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 5e+70) {
tmp = exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (fabs((n - m)) - l)));
} else {
tmp = cos(M) * exp((-0.25 * pow(n, 2.0)));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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+70) then
tmp = exp((((n + ((m * 0.5d0) - m_1)) * (m_1 - (m * 0.5d0))) + (abs((n - m)) - l)))
else
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 5e+70) {
tmp = Math.exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (Math.abs((n - m)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if n <= 5e+70: tmp = math.exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (math.fabs((n - m)) - l))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (n <= 5e+70) tmp = exp(Float64(Float64(Float64(n + Float64(Float64(m * 0.5) - M)) * Float64(M - Float64(m * 0.5))) + Float64(abs(Float64(n - m)) - l))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (n <= 5e+70)
tmp = exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (abs((n - m)) - l)));
else
tmp = cos(M) * exp((-0.25 * (n ^ 2.0)));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[n, 5e+70], N[Exp[N[(N[(N[(n + N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;n \leq 5 \cdot 10^{+70}:\\
\;\;\;\;e^{\left(n + \left(m \cdot 0.5 - M\right)\right) \cdot \left(M - m \cdot 0.5\right) + \left(\left|n - m\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 5.0000000000000002e70Initial program 76.8%
associate-/l*76.8%
+-commutative76.8%
fabs-sub76.8%
+-commutative76.8%
Simplified76.8%
Taylor expanded in n around 0 65.0%
+-commutative65.0%
unpow265.0%
distribute-rgt-out68.5%
*-commutative68.5%
*-commutative68.5%
Simplified68.5%
Taylor expanded in m around inf 70.5%
associate-*r*70.5%
Simplified70.5%
Taylor expanded in K around 0 82.9%
if 5.0000000000000002e70 < n Initial program 76.4%
associate-/l*76.4%
+-commutative76.4%
fabs-sub76.4%
+-commutative76.4%
Simplified76.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
Final simplification86.6%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- n m)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
assert(K < m && m < n && n < M && M < l);
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)));
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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
assert K < m && m < n && n < M && M < l;
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)));
}
[K, m, n, M, l] = sort([K, m, n, M, l]) 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)))
K, m, n, M, l = sort([K, m, n, M, l]) 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
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = cos(M) * exp(((abs((n - m)) - l) - ((((m + n) / 2.0) - M) ^ 2.0)));
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. 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}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 76.7%
associate-/l*76.7%
+-commutative76.7%
fabs-sub76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in K around 0 96.2%
cos-neg96.2%
Simplified96.2%
Final simplification96.2%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- M (* m 0.5))))
(if (<= m -7.2e+63)
(exp (* -0.25 (pow m 2.0)))
(if (<= m 1.05e-108)
(exp (+ (* (+ n (- (* m 0.5) M)) t_0) (- (fabs (- n m)) l)))
(exp (* n t_0))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = M - (m * 0.5);
double tmp;
if (m <= -7.2e+63) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 1.05e-108) {
tmp = exp((((n + ((m * 0.5) - M)) * t_0) + (fabs((n - m)) - l)));
} else {
tmp = exp((n * t_0));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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 = m_1 - (m * 0.5d0)
if (m <= (-7.2d+63)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 1.05d-108) then
tmp = exp((((n + ((m * 0.5d0) - m_1)) * t_0) + (abs((n - m)) - l)))
else
tmp = exp((n * t_0))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double t_0 = M - (m * 0.5);
double tmp;
if (m <= -7.2e+63) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 1.05e-108) {
tmp = Math.exp((((n + ((m * 0.5) - M)) * t_0) + (Math.abs((n - m)) - l)));
} else {
tmp = Math.exp((n * t_0));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = M - (m * 0.5) tmp = 0 if m <= -7.2e+63: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 1.05e-108: tmp = math.exp((((n + ((m * 0.5) - M)) * t_0) + (math.fabs((n - m)) - l))) else: tmp = math.exp((n * t_0)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(M - Float64(m * 0.5)) tmp = 0.0 if (m <= -7.2e+63) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 1.05e-108) tmp = exp(Float64(Float64(Float64(n + Float64(Float64(m * 0.5) - M)) * t_0) + Float64(abs(Float64(n - m)) - l))); else tmp = exp(Float64(n * t_0)); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
t_0 = M - (m * 0.5);
tmp = 0.0;
if (m <= -7.2e+63)
tmp = exp((-0.25 * (m ^ 2.0)));
elseif (m <= 1.05e-108)
tmp = exp((((n + ((m * 0.5) - M)) * t_0) + (abs((n - m)) - l)));
else
tmp = exp((n * t_0));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -7.2e+63], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 1.05e-108], N[Exp[N[(N[(N[(n + N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(n * t$95$0), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := M - m \cdot 0.5\\
\mathbf{if}\;m \leq -7.2 \cdot 10^{+63}:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 1.05 \cdot 10^{-108}:\\
\;\;\;\;e^{\left(n + \left(m \cdot 0.5 - M\right)\right) \cdot t\_0 + \left(\left|n - m\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{n \cdot t\_0}\\
\end{array}
\end{array}
if m < -7.19999999999999998e63Initial program 70.5%
associate-/l*70.5%
+-commutative70.5%
fabs-sub70.5%
+-commutative70.5%
Simplified70.5%
Taylor expanded in n around 0 50.1%
+-commutative50.1%
unpow250.1%
distribute-rgt-out59.3%
*-commutative59.3%
*-commutative59.3%
Simplified59.3%
Taylor expanded in m around inf 59.3%
associate-*r*59.3%
Simplified59.3%
Taylor expanded in K around 0 82.1%
Taylor expanded in m around inf 97.8%
*-commutative97.8%
Simplified97.8%
if -7.19999999999999998e63 < m < 1.05e-108Initial program 87.9%
associate-/l*87.9%
+-commutative87.9%
fabs-sub87.9%
+-commutative87.9%
Simplified87.9%
Taylor expanded in n around 0 65.1%
+-commutative65.1%
unpow265.1%
distribute-rgt-out69.6%
*-commutative69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in m around inf 73.0%
associate-*r*73.0%
Simplified73.0%
Taylor expanded in K around 0 71.3%
if 1.05e-108 < m Initial program 66.8%
associate-/l*66.8%
+-commutative66.8%
fabs-sub66.8%
+-commutative66.8%
Simplified66.8%
Taylor expanded in n around 0 51.8%
+-commutative51.8%
unpow251.8%
distribute-rgt-out56.9%
*-commutative56.9%
*-commutative56.9%
Simplified56.9%
Taylor expanded in m around inf 59.0%
associate-*r*59.0%
Simplified59.0%
Taylor expanded in K around 0 83.2%
Taylor expanded in n around inf 39.0%
Final simplification63.4%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(if (<= m -55.0)
(exp (* -0.25 (pow m 2.0)))
(if (<= m 3.15e-108)
(exp (- (* M (- n M)) (- l (fabs (- n m)))))
(exp (* n (- M (* m 0.5)))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 3.15e-108) {
tmp = exp(((M * (n - M)) - (l - fabs((n - m)))));
} else {
tmp = exp((n * (M - (m * 0.5))));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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 <= (-55.0d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 3.15d-108) then
tmp = exp(((m_1 * (n - m_1)) - (l - abs((n - m)))))
else
tmp = exp((n * (m_1 - (m * 0.5d0))))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -55.0) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 3.15e-108) {
tmp = Math.exp(((M * (n - M)) - (l - Math.abs((n - m)))));
} else {
tmp = Math.exp((n * (M - (m * 0.5))));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if m <= -55.0: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 3.15e-108: tmp = math.exp(((M * (n - M)) - (l - math.fabs((n - m))))) else: tmp = math.exp((n * (M - (m * 0.5)))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (m <= -55.0) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 3.15e-108) tmp = exp(Float64(Float64(M * Float64(n - M)) - Float64(l - abs(Float64(n - m))))); else tmp = exp(Float64(n * Float64(M - Float64(m * 0.5)))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (m <= -55.0)
tmp = exp((-0.25 * (m ^ 2.0)));
elseif (m <= 3.15e-108)
tmp = exp(((M * (n - M)) - (l - abs((n - m)))));
else
tmp = exp((n * (M - (m * 0.5))));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[m, -55.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 3.15e-108], N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] - N[(l - N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -55:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 3.15 \cdot 10^{-108}:\\
\;\;\;\;e^{M \cdot \left(n - M\right) - \left(\ell - \left|n - m\right|\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\end{array}
\end{array}
if m < -55Initial program 72.5%
associate-/l*72.5%
+-commutative72.5%
fabs-sub72.5%
+-commutative72.5%
Simplified72.5%
Taylor expanded in n around 0 55.0%
+-commutative55.0%
unpow255.0%
distribute-rgt-out62.9%
*-commutative62.9%
*-commutative62.9%
Simplified62.9%
Taylor expanded in m around inf 63.0%
associate-*r*63.0%
Simplified63.0%
Taylor expanded in K around 0 82.6%
Taylor expanded in m around inf 98.1%
*-commutative98.1%
Simplified98.1%
if -55 < m < 3.1499999999999999e-108Initial program 88.0%
associate-/l*88.0%
+-commutative88.0%
fabs-sub88.0%
+-commutative88.0%
Simplified88.0%
Taylor expanded in n around 0 63.8%
+-commutative63.8%
unpow263.8%
distribute-rgt-out68.5%
*-commutative68.5%
*-commutative68.5%
Simplified68.5%
Taylor expanded in m around inf 72.2%
associate-*r*72.2%
Simplified72.2%
Taylor expanded in K around 0 70.3%
Taylor expanded in m around 0 70.3%
associate--r+70.3%
associate-*r*70.3%
neg-mul-170.3%
cancel-sign-sub70.3%
fabs-sub70.3%
Simplified70.3%
if 3.1499999999999999e-108 < m Initial program 66.8%
associate-/l*66.8%
+-commutative66.8%
fabs-sub66.8%
+-commutative66.8%
Simplified66.8%
Taylor expanded in n around 0 51.8%
+-commutative51.8%
unpow251.8%
distribute-rgt-out56.9%
*-commutative56.9%
*-commutative56.9%
Simplified56.9%
Taylor expanded in m around inf 59.0%
associate-*r*59.0%
Simplified59.0%
Taylor expanded in K around 0 83.2%
Taylor expanded in n around inf 39.0%
Final simplification63.7%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- (pow M 2.0)))))
(if (<= M -5.0)
t_0
(if (<= M -2.1e-181)
(exp (* n (- M (* m 0.5))))
(if (<= M 7.1e-43) (exp (- l)) t_0)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-pow(M, 2.0));
double tmp;
if (M <= -5.0) {
tmp = t_0;
} else if (M <= -2.1e-181) {
tmp = exp((n * (M - (m * 0.5))));
} else if (M <= 7.1e-43) {
tmp = exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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_1 <= (-5.0d0)) then
tmp = t_0
else if (m_1 <= (-2.1d-181)) then
tmp = exp((n * (m_1 - (m * 0.5d0))))
else if (m_1 <= 7.1d-43) then
tmp = exp(-l)
else
tmp = t_0
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
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 <= -5.0) {
tmp = t_0;
} else if (M <= -2.1e-181) {
tmp = Math.exp((n * (M - (m * 0.5))));
} else if (M <= 7.1e-43) {
tmp = Math.exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.exp(-math.pow(M, 2.0)) tmp = 0 if M <= -5.0: tmp = t_0 elif M <= -2.1e-181: tmp = math.exp((n * (M - (m * 0.5)))) elif M <= 7.1e-43: tmp = math.exp(-l) else: tmp = t_0 return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = exp(Float64(-(M ^ 2.0))) tmp = 0.0 if (M <= -5.0) tmp = t_0; elseif (M <= -2.1e-181) tmp = exp(Float64(n * Float64(M - Float64(m * 0.5)))); elseif (M <= 7.1e-43) tmp = exp(Float64(-l)); else tmp = t_0; end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
t_0 = exp(-(M ^ 2.0));
tmp = 0.0;
if (M <= -5.0)
tmp = t_0;
elseif (M <= -2.1e-181)
tmp = exp((n * (M - (m * 0.5))));
elseif (M <= 7.1e-43)
tmp = exp(-l);
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]}, If[LessEqual[M, -5.0], t$95$0, If[LessEqual[M, -2.1e-181], N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[M, 7.1e-43], N[Exp[(-l)], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := e^{-{M}^{2}}\\
\mathbf{if}\;M \leq -5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq -2.1 \cdot 10^{-181}:\\
\;\;\;\;e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{elif}\;M \leq 7.1 \cdot 10^{-43}:\\
\;\;\;\;e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -5 or 7.10000000000000025e-43 < M Initial program 76.8%
associate-/l*76.8%
+-commutative76.8%
fabs-sub76.8%
+-commutative76.8%
Simplified76.8%
Taylor expanded in n around 0 61.0%
+-commutative61.0%
unpow261.0%
distribute-rgt-out69.7%
*-commutative69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in m around inf 73.4%
associate-*r*73.4%
Simplified73.4%
Taylor expanded in K around 0 86.4%
Taylor expanded in M around inf 95.1%
mul-1-neg95.1%
Simplified95.1%
if -5 < M < -2.10000000000000003e-181Initial program 77.8%
associate-/l*77.9%
+-commutative77.9%
fabs-sub77.9%
+-commutative77.9%
Simplified77.9%
Taylor expanded in n around 0 58.1%
+-commutative58.1%
unpow258.1%
distribute-rgt-out60.6%
*-commutative60.6%
*-commutative60.6%
Simplified60.6%
Taylor expanded in m around inf 63.2%
associate-*r*63.2%
Simplified63.2%
Taylor expanded in K around 0 75.8%
Taylor expanded in n around inf 44.0%
if -2.10000000000000003e-181 < M < 7.10000000000000025e-43Initial program 76.0%
associate-/l*76.0%
+-commutative76.0%
fabs-sub76.0%
+-commutative76.0%
Simplified76.0%
Taylor expanded in n around 0 50.7%
+-commutative50.7%
unpow250.7%
distribute-rgt-out52.1%
*-commutative52.1%
*-commutative52.1%
Simplified52.1%
Taylor expanded in m around inf 51.9%
associate-*r*51.9%
Simplified51.9%
Taylor expanded in l around inf 38.7%
neg-mul-138.7%
Simplified38.7%
Taylor expanded in K around 0 42.7%
Final simplification71.1%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (<= m -54.0) (exp (* -0.25 (pow m 2.0))) (if (<= m 2.45e-108) (exp (- (pow M 2.0))) (exp (* n (- M (* m 0.5)))))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = exp((-0.25 * pow(m, 2.0)));
} else if (m <= 2.45e-108) {
tmp = exp(-pow(M, 2.0));
} else {
tmp = exp((n * (M - (m * 0.5))));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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 <= (-54.0d0)) then
tmp = exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 2.45d-108) then
tmp = exp(-(m_1 ** 2.0d0))
else
tmp = exp((n * (m_1 - (m * 0.5d0))))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 2.45e-108) {
tmp = Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp((n * (M - (m * 0.5))));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if m <= -54.0: tmp = math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 2.45e-108: tmp = math.exp(-math.pow(M, 2.0)) else: tmp = math.exp((n * (M - (m * 0.5)))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (m <= -54.0) tmp = exp(Float64(-0.25 * (m ^ 2.0))); elseif (m <= 2.45e-108) tmp = exp(Float64(-(M ^ 2.0))); else tmp = exp(Float64(n * Float64(M - Float64(m * 0.5)))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (m <= -54.0)
tmp = exp((-0.25 * (m ^ 2.0)));
elseif (m <= 2.45e-108)
tmp = exp(-(M ^ 2.0));
else
tmp = exp((n * (M - (m * 0.5))));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[m, -54.0], N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 2.45e-108], N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision], N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -54:\\
\;\;\;\;e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 2.45 \cdot 10^{-108}:\\
\;\;\;\;e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\end{array}
\end{array}
if m < -54Initial program 72.5%
associate-/l*72.5%
+-commutative72.5%
fabs-sub72.5%
+-commutative72.5%
Simplified72.5%
Taylor expanded in n around 0 55.0%
+-commutative55.0%
unpow255.0%
distribute-rgt-out62.9%
*-commutative62.9%
*-commutative62.9%
Simplified62.9%
Taylor expanded in m around inf 63.0%
associate-*r*63.0%
Simplified63.0%
Taylor expanded in K around 0 82.6%
Taylor expanded in m around inf 98.1%
*-commutative98.1%
Simplified98.1%
if -54 < m < 2.4499999999999999e-108Initial program 88.0%
associate-/l*88.0%
+-commutative88.0%
fabs-sub88.0%
+-commutative88.0%
Simplified88.0%
Taylor expanded in n around 0 63.8%
+-commutative63.8%
unpow263.8%
distribute-rgt-out68.5%
*-commutative68.5%
*-commutative68.5%
Simplified68.5%
Taylor expanded in m around inf 72.2%
associate-*r*72.2%
Simplified72.2%
Taylor expanded in K around 0 70.3%
Taylor expanded in M around inf 66.1%
mul-1-neg66.1%
Simplified66.1%
if 2.4499999999999999e-108 < m Initial program 66.8%
associate-/l*66.8%
+-commutative66.8%
fabs-sub66.8%
+-commutative66.8%
Simplified66.8%
Taylor expanded in n around 0 51.8%
+-commutative51.8%
unpow251.8%
distribute-rgt-out56.9%
*-commutative56.9%
*-commutative56.9%
Simplified56.9%
Taylor expanded in m around inf 59.0%
associate-*r*59.0%
Simplified59.0%
Taylor expanded in K around 0 83.2%
Taylor expanded in n around inf 39.0%
Final simplification62.0%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (or (<= l -5.5e+269) (and (not (<= l -1.95e+231)) (<= l 700.0))) (exp (* n (- M (* m 0.5)))) (exp (- l))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((l <= -5.5e+269) || (!(l <= -1.95e+231) && (l <= 700.0))) {
tmp = exp((n * (M - (m * 0.5))));
} else {
tmp = exp(-l);
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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 <= (-5.5d+269)) .or. (.not. (l <= (-1.95d+231))) .and. (l <= 700.0d0)) then
tmp = exp((n * (m_1 - (m * 0.5d0))))
else
tmp = exp(-l)
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((l <= -5.5e+269) || (!(l <= -1.95e+231) && (l <= 700.0))) {
tmp = Math.exp((n * (M - (m * 0.5))));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if (l <= -5.5e+269) or (not (l <= -1.95e+231) and (l <= 700.0)): tmp = math.exp((n * (M - (m * 0.5)))) else: tmp = math.exp(-l) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if ((l <= -5.5e+269) || (!(l <= -1.95e+231) && (l <= 700.0))) tmp = exp(Float64(n * Float64(M - Float64(m * 0.5)))); else tmp = exp(Float64(-l)); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if ((l <= -5.5e+269) || (~((l <= -1.95e+231)) && (l <= 700.0)))
tmp = exp((n * (M - (m * 0.5))));
else
tmp = exp(-l);
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[Or[LessEqual[l, -5.5e+269], And[N[Not[LessEqual[l, -1.95e+231]], $MachinePrecision], LessEqual[l, 700.0]]], N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5.5 \cdot 10^{+269} \lor \neg \left(\ell \leq -1.95 \cdot 10^{+231}\right) \land \ell \leq 700:\\
\;\;\;\;e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < -5.50000000000000026e269 or -1.9500000000000001e231 < l < 700Initial program 75.8%
associate-/l*75.8%
+-commutative75.8%
fabs-sub75.8%
+-commutative75.8%
Simplified75.8%
Taylor expanded in n around 0 55.1%
+-commutative55.1%
unpow255.1%
distribute-rgt-out61.4%
*-commutative61.4%
*-commutative61.4%
Simplified61.4%
Taylor expanded in m around inf 63.0%
associate-*r*63.0%
Simplified63.0%
Taylor expanded in K around 0 75.5%
Taylor expanded in n around inf 43.0%
if -5.50000000000000026e269 < l < -1.9500000000000001e231 or 700 < l Initial program 79.7%
associate-/l*79.7%
+-commutative79.7%
fabs-sub79.7%
+-commutative79.7%
Simplified79.7%
Taylor expanded in n around 0 64.2%
+-commutative64.2%
unpow264.2%
distribute-rgt-out67.4%
*-commutative67.4%
*-commutative67.4%
Simplified67.4%
Taylor expanded in m around inf 72.1%
associate-*r*72.1%
Simplified72.1%
Taylor expanded in l around inf 79.8%
neg-mul-179.8%
Simplified79.8%
Taylor expanded in K around 0 90.8%
Final simplification55.0%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (exp (- l)))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp(-l);
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.exp(-l)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return exp(Float64(-l)) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = exp(-l);
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{-\ell}
\end{array}
Initial program 76.7%
associate-/l*76.7%
+-commutative76.7%
fabs-sub76.7%
+-commutative76.7%
Simplified76.7%
Taylor expanded in n around 0 57.4%
+-commutative57.4%
unpow257.4%
distribute-rgt-out62.9%
*-commutative62.9%
*-commutative62.9%
Simplified62.9%
Taylor expanded in m around inf 65.2%
associate-*r*65.2%
Simplified65.2%
Taylor expanded in l around inf 29.4%
neg-mul-129.4%
Simplified29.4%
Taylor expanded in K around 0 31.6%
Final simplification31.6%
herbie shell --seed 2024027
(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)))))))