
(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(abs(Float64(n - m)) - Float64(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[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left(\ell + {\left(\frac{m + n}{2} - M\right)}^{2}\right)}
\end{array}
Initial program 72.9%
+-commutative72.9%
+-commutative72.9%
fabs-sub72.9%
associate-/l*73.5%
+-commutative73.5%
Simplified73.5%
Taylor expanded in K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Final simplification96.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 2.8e-86)
(* (cos M) (exp (- t_0 (+ (* (* m m) 0.25) l))))
(if (<= n 4.1e+36)
(* (cos (- (/ K (/ 2.0 n)) M)) (exp (- t_0 (+ (* M M) l))))
(* (cos M) (exp (+ t_0 (* -0.25 (* n n)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= 2.8e-86) {
tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l)));
} else if (n <= 4.1e+36) {
tmp = cos(((K / (2.0 / n)) - M)) * exp((t_0 - ((M * M) + l)));
} else {
tmp = cos(M) * exp((t_0 + (-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 = abs((n - m))
if (n <= 2.8d-86) then
tmp = cos(m_1) * exp((t_0 - (((m * m) * 0.25d0) + l)))
else if (n <= 4.1d+36) then
tmp = cos(((k / (2.0d0 / n)) - m_1)) * exp((t_0 - ((m_1 * m_1) + l)))
else
tmp = cos(m_1) * exp((t_0 + ((-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.abs((n - m));
double tmp;
if (n <= 2.8e-86) {
tmp = Math.cos(M) * Math.exp((t_0 - (((m * m) * 0.25) + l)));
} else if (n <= 4.1e+36) {
tmp = Math.cos(((K / (2.0 / n)) - M)) * Math.exp((t_0 - ((M * M) + l)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 + (-0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if n <= 2.8e-86: tmp = math.cos(M) * math.exp((t_0 - (((m * m) * 0.25) + l))) elif n <= 4.1e+36: tmp = math.cos(((K / (2.0 / n)) - M)) * math.exp((t_0 - ((M * M) + l))) else: tmp = math.cos(M) * math.exp((t_0 + (-0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= 2.8e-86) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(Float64(Float64(m * m) * 0.25) + l)))); elseif (n <= 4.1e+36) tmp = Float64(cos(Float64(Float64(K / Float64(2.0 / n)) - M)) * exp(Float64(t_0 - Float64(Float64(M * M) + l)))); else tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(-0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (n <= 2.8e-86) tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l))); elseif (n <= 4.1e+36) tmp = cos(((K / (2.0 / n)) - M)) * exp((t_0 - ((M * M) + l))); else tmp = cos(M) * exp((t_0 + (-0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 2.8e-86], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(N[(N[(m * m), $MachinePrecision] * 0.25), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.1e+36], N[(N[Cos[N[(N[(K / N[(2.0 / n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(N[(M * M), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 2.8 \cdot 10^{-86}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(\left(m \cdot m\right) \cdot 0.25 + \ell\right)}\\
\mathbf{elif}\;n \leq 4.1 \cdot 10^{+36}:\\
\;\;\;\;\cos \left(\frac{K}{\frac{2}{n}} - M\right) \cdot e^{t_0 - \left(M \cdot M + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 + -0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 2.80000000000000009e-86Initial program 74.3%
+-commutative74.3%
+-commutative74.3%
fabs-sub74.3%
associate-/l*75.1%
+-commutative75.1%
Simplified75.1%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in m around inf 65.4%
*-commutative65.4%
unpow265.4%
Simplified65.4%
if 2.80000000000000009e-86 < n < 4.10000000000000013e36Initial program 80.5%
+-commutative80.5%
+-commutative80.5%
fabs-sub80.5%
associate-/l*80.5%
+-commutative80.5%
Simplified80.5%
Taylor expanded in M around inf 60.9%
unpow260.9%
Simplified60.9%
Taylor expanded in m around 0 77.5%
if 4.10000000000000013e36 < n Initial program 64.2%
+-commutative64.2%
+-commutative64.2%
fabs-sub64.2%
associate-/l*64.2%
+-commutative64.2%
Simplified64.2%
Taylor expanded in n around 0 47.2%
associate-+r+47.2%
unpow247.2%
distribute-rgt-out62.3%
*-commutative62.3%
*-commutative62.3%
unpow262.3%
associate-*r*62.3%
Simplified62.3%
Taylor expanded in m around 0 62.3%
+-commutative62.3%
*-commutative62.3%
unpow262.3%
associate-*r*62.3%
mul-1-neg62.3%
unsub-neg62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in K around 0 92.5%
cos-neg100.0%
Simplified92.5%
Taylor expanded in n around inf 94.4%
unpow294.4%
Simplified94.4%
Final simplification72.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= m -52000000000.0)
(* (cos M) (exp (- t_0 (+ (* (* m m) 0.25) l))))
(* (cos M) (exp (+ t_0 (- (- (* M (- n M)) (* n (* n 0.25))) l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (m <= -52000000000.0) {
tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l)));
} else {
tmp = cos(M) * exp((t_0 + (((M * (n - M)) - (n * (n * 0.25))) - 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) :: t_0
real(8) :: tmp
t_0 = abs((n - m))
if (m <= (-52000000000.0d0)) then
tmp = cos(m_1) * exp((t_0 - (((m * m) * 0.25d0) + l)))
else
tmp = cos(m_1) * exp((t_0 + (((m_1 * (n - m_1)) - (n * (n * 0.25d0))) - l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.abs((n - m));
double tmp;
if (m <= -52000000000.0) {
tmp = Math.cos(M) * Math.exp((t_0 - (((m * m) * 0.25) + l)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 + (((M * (n - M)) - (n * (n * 0.25))) - l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if m <= -52000000000.0: tmp = math.cos(M) * math.exp((t_0 - (((m * m) * 0.25) + l))) else: tmp = math.cos(M) * math.exp((t_0 + (((M * (n - M)) - (n * (n * 0.25))) - l))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (m <= -52000000000.0) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(Float64(Float64(m * m) * 0.25) + l)))); else tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(Float64(Float64(M * Float64(n - M)) - Float64(n * Float64(n * 0.25))) - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (m <= -52000000000.0) tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l))); else tmp = cos(M) * exp((t_0 + (((M * (n - M)) - (n * (n * 0.25))) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -52000000000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(N[(N[(m * m), $MachinePrecision] * 0.25), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] - N[(n * N[(n * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;m \leq -52000000000:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(\left(m \cdot m\right) \cdot 0.25 + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 + \left(\left(M \cdot \left(n - M\right) - n \cdot \left(n \cdot 0.25\right)\right) - \ell\right)}\\
\end{array}
\end{array}
if m < -5.2e10Initial program 54.2%
+-commutative54.2%
+-commutative54.2%
fabs-sub54.2%
associate-/l*54.2%
+-commutative54.2%
Simplified54.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 86.7%
*-commutative86.7%
unpow286.7%
Simplified86.7%
if -5.2e10 < m Initial program 78.5%
+-commutative78.5%
+-commutative78.5%
fabs-sub78.5%
associate-/l*79.2%
+-commutative79.2%
Simplified79.2%
Taylor expanded in n around 0 73.1%
associate-+r+73.1%
unpow273.1%
distribute-rgt-out78.2%
*-commutative78.2%
*-commutative78.2%
unpow278.2%
associate-*r*78.2%
Simplified78.2%
Taylor expanded in m around 0 73.4%
+-commutative73.4%
*-commutative73.4%
unpow273.4%
associate-*r*73.4%
mul-1-neg73.4%
unsub-neg73.4%
*-commutative73.4%
Simplified73.4%
Taylor expanded in K around 0 84.8%
cos-neg95.6%
Simplified84.8%
Final simplification85.2%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 1.4e-86)
(* (cos M) (exp (- t_0 (+ (* (* m m) 0.25) l))))
(if (<= n 1.5e+38)
(* (cos M) (exp (- t_0 (+ (* M M) l))))
(* (cos M) (exp (+ t_0 (* -0.25 (* n n)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= 1.4e-86) {
tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l)));
} else if (n <= 1.5e+38) {
tmp = cos(M) * exp((t_0 - ((M * M) + l)));
} else {
tmp = cos(M) * exp((t_0 + (-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 = abs((n - m))
if (n <= 1.4d-86) then
tmp = cos(m_1) * exp((t_0 - (((m * m) * 0.25d0) + l)))
else if (n <= 1.5d+38) then
tmp = cos(m_1) * exp((t_0 - ((m_1 * m_1) + l)))
else
tmp = cos(m_1) * exp((t_0 + ((-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.abs((n - m));
double tmp;
if (n <= 1.4e-86) {
tmp = Math.cos(M) * Math.exp((t_0 - (((m * m) * 0.25) + l)));
} else if (n <= 1.5e+38) {
tmp = Math.cos(M) * Math.exp((t_0 - ((M * M) + l)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 + (-0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if n <= 1.4e-86: tmp = math.cos(M) * math.exp((t_0 - (((m * m) * 0.25) + l))) elif n <= 1.5e+38: tmp = math.cos(M) * math.exp((t_0 - ((M * M) + l))) else: tmp = math.cos(M) * math.exp((t_0 + (-0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= 1.4e-86) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(Float64(Float64(m * m) * 0.25) + l)))); elseif (n <= 1.5e+38) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(Float64(M * M) + l)))); else tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(-0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (n <= 1.4e-86) tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l))); elseif (n <= 1.5e+38) tmp = cos(M) * exp((t_0 - ((M * M) + l))); else tmp = cos(M) * exp((t_0 + (-0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 1.4e-86], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(N[(N[(m * m), $MachinePrecision] * 0.25), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.5e+38], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(N[(M * M), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 1.4 \cdot 10^{-86}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(\left(m \cdot m\right) \cdot 0.25 + \ell\right)}\\
\mathbf{elif}\;n \leq 1.5 \cdot 10^{+38}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(M \cdot M + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 + -0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 1.40000000000000005e-86Initial program 74.6%
+-commutative74.6%
+-commutative74.6%
fabs-sub74.6%
associate-/l*75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in m around inf 65.6%
*-commutative65.6%
unpow265.6%
Simplified65.6%
if 1.40000000000000005e-86 < n < 1.5000000000000001e38Initial program 78.6%
+-commutative78.6%
+-commutative78.6%
fabs-sub78.6%
associate-/l*78.6%
+-commutative78.6%
Simplified78.6%
Taylor expanded in K around 0 95.3%
cos-neg95.3%
Simplified95.3%
Taylor expanded in M around inf 76.2%
unpow259.6%
Simplified76.2%
if 1.5000000000000001e38 < n Initial program 64.2%
+-commutative64.2%
+-commutative64.2%
fabs-sub64.2%
associate-/l*64.2%
+-commutative64.2%
Simplified64.2%
Taylor expanded in n around 0 47.2%
associate-+r+47.2%
unpow247.2%
distribute-rgt-out62.3%
*-commutative62.3%
*-commutative62.3%
unpow262.3%
associate-*r*62.3%
Simplified62.3%
Taylor expanded in m around 0 62.3%
+-commutative62.3%
*-commutative62.3%
unpow262.3%
associate-*r*62.3%
mul-1-neg62.3%
unsub-neg62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in K around 0 92.5%
cos-neg100.0%
Simplified92.5%
Taylor expanded in n around inf 94.4%
unpow294.4%
Simplified94.4%
Final simplification72.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (or (<= M -5.8e+37) (not (<= M 3.8e+25)))
(* (cos M) (exp (- t_0 (* M M))))
(* (cos M) (exp (- t_0 l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if ((M <= -5.8e+37) || !(M <= 3.8e+25)) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = cos(M) * exp((t_0 - 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) :: t_0
real(8) :: tmp
t_0 = abs((n - m))
if ((m_1 <= (-5.8d+37)) .or. (.not. (m_1 <= 3.8d+25))) then
tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
else
tmp = cos(m_1) * exp((t_0 - l))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.abs((n - m));
double tmp;
if ((M <= -5.8e+37) || !(M <= 3.8e+25)) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 - l));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if (M <= -5.8e+37) or not (M <= 3.8e+25): tmp = math.cos(M) * math.exp((t_0 - (M * M))) else: tmp = math.cos(M) * math.exp((t_0 - l)) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if ((M <= -5.8e+37) || !(M <= 3.8e+25)) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = Float64(cos(M) * exp(Float64(t_0 - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if ((M <= -5.8e+37) || ~((M <= 3.8e+25))) tmp = cos(M) * exp((t_0 - (M * M))); else tmp = cos(M) * exp((t_0 - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[M, -5.8e+37], N[Not[LessEqual[M, 3.8e+25]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;M \leq -5.8 \cdot 10^{+37} \lor \neg \left(M \leq 3.8 \cdot 10^{+25}\right):\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \ell}\\
\end{array}
\end{array}
if M < -5.79999999999999957e37 or 3.8e25 < M Initial program 80.8%
+-commutative80.8%
+-commutative80.8%
fabs-sub80.8%
associate-/l*80.8%
+-commutative80.8%
Simplified80.8%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in M around inf 88.5%
unpow276.7%
Simplified88.5%
Taylor expanded in M around inf 89.3%
mul-1-neg89.3%
unpow289.3%
distribute-rgt-neg-out89.3%
Simplified89.3%
if -5.79999999999999957e37 < M < 3.8e25Initial program 66.0%
+-commutative66.0%
+-commutative66.0%
fabs-sub66.0%
associate-/l*67.0%
+-commutative67.0%
Simplified67.0%
Taylor expanded in M around inf 27.4%
unpow227.4%
Simplified27.4%
Taylor expanded in M around 0 26.7%
neg-mul-126.7%
Simplified26.7%
Taylor expanded in K around 0 29.5%
cos-neg94.4%
Simplified29.5%
Final simplification57.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 5e+36)
(* (cos M) (exp (- t_0 (* M M))))
(* (cos M) (exp (+ t_0 (* -0.25 (* n n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= 5e+36) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = cos(M) * exp((t_0 + (-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 = abs((n - m))
if (n <= 5d+36) then
tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
else
tmp = cos(m_1) * exp((t_0 + ((-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.abs((n - m));
double tmp;
if (n <= 5e+36) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 + (-0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if n <= 5e+36: tmp = math.cos(M) * math.exp((t_0 - (M * M))) else: tmp = math.cos(M) * math.exp((t_0 + (-0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= 5e+36) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(-0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (n <= 5e+36) tmp = cos(M) * exp((t_0 - (M * M))); else tmp = cos(M) * exp((t_0 + (-0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 5e+36], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 5 \cdot 10^{+36}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 + -0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 4.99999999999999977e36Initial program 75.2%
+-commutative75.2%
+-commutative75.2%
fabs-sub75.2%
associate-/l*75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Taylor expanded in M around inf 61.0%
unpow254.7%
Simplified61.0%
Taylor expanded in M around inf 49.9%
mul-1-neg49.9%
unpow249.9%
distribute-rgt-neg-out49.9%
Simplified49.9%
if 4.99999999999999977e36 < n Initial program 64.2%
+-commutative64.2%
+-commutative64.2%
fabs-sub64.2%
associate-/l*64.2%
+-commutative64.2%
Simplified64.2%
Taylor expanded in n around 0 47.2%
associate-+r+47.2%
unpow247.2%
distribute-rgt-out62.3%
*-commutative62.3%
*-commutative62.3%
unpow262.3%
associate-*r*62.3%
Simplified62.3%
Taylor expanded in m around 0 62.3%
+-commutative62.3%
*-commutative62.3%
unpow262.3%
associate-*r*62.3%
mul-1-neg62.3%
unsub-neg62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in K around 0 92.5%
cos-neg100.0%
Simplified92.5%
Taylor expanded in n around inf 94.4%
unpow294.4%
Simplified94.4%
Final simplification59.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 5e+36)
(* (cos M) (exp (- t_0 (+ (* M M) l))))
(* (cos M) (exp (+ t_0 (* -0.25 (* n n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= 5e+36) {
tmp = cos(M) * exp((t_0 - ((M * M) + l)));
} else {
tmp = cos(M) * exp((t_0 + (-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 = abs((n - m))
if (n <= 5d+36) then
tmp = cos(m_1) * exp((t_0 - ((m_1 * m_1) + l)))
else
tmp = cos(m_1) * exp((t_0 + ((-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.abs((n - m));
double tmp;
if (n <= 5e+36) {
tmp = Math.cos(M) * Math.exp((t_0 - ((M * M) + l)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 + (-0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if n <= 5e+36: tmp = math.cos(M) * math.exp((t_0 - ((M * M) + l))) else: tmp = math.cos(M) * math.exp((t_0 + (-0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= 5e+36) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(Float64(M * M) + l)))); else tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(-0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (n <= 5e+36) tmp = cos(M) * exp((t_0 - ((M * M) + l))); else tmp = cos(M) * exp((t_0 + (-0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 5e+36], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(N[(M * M), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 5 \cdot 10^{+36}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(M \cdot M + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 + -0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 4.99999999999999977e36Initial program 75.2%
+-commutative75.2%
+-commutative75.2%
fabs-sub75.2%
associate-/l*75.9%
+-commutative75.9%
Simplified75.9%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Taylor expanded in M around inf 61.0%
unpow254.7%
Simplified61.0%
if 4.99999999999999977e36 < n Initial program 64.2%
+-commutative64.2%
+-commutative64.2%
fabs-sub64.2%
associate-/l*64.2%
+-commutative64.2%
Simplified64.2%
Taylor expanded in n around 0 47.2%
associate-+r+47.2%
unpow247.2%
distribute-rgt-out62.3%
*-commutative62.3%
*-commutative62.3%
unpow262.3%
associate-*r*62.3%
Simplified62.3%
Taylor expanded in m around 0 62.3%
+-commutative62.3%
*-commutative62.3%
unpow262.3%
associate-*r*62.3%
mul-1-neg62.3%
unsub-neg62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in K around 0 92.5%
cos-neg100.0%
Simplified92.5%
Taylor expanded in n around inf 94.4%
unpow294.4%
Simplified94.4%
Final simplification67.9%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (fabs (- n m)) l))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((n - m)) - l));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp((abs((n - m)) - l))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp((Math.abs((n - m)) - l));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((n - m)) - l))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((n - m)) - l)); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \ell}
\end{array}
Initial program 72.9%
+-commutative72.9%
+-commutative72.9%
fabs-sub72.9%
associate-/l*73.5%
+-commutative73.5%
Simplified73.5%
Taylor expanded in M around inf 50.5%
unpow250.5%
Simplified50.5%
Taylor expanded in M around 0 21.0%
neg-mul-121.0%
Simplified21.0%
Taylor expanded in K around 0 22.7%
cos-neg96.6%
Simplified22.7%
Final simplification22.7%
herbie shell --seed 2023272
(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)))))))