
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (fabs (- n m)) (+ (pow (- (/ (+ m n) 2.0) M) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((n - m)) - (pow((((m + n) / 2.0) - M), 2.0) + 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)) - (((((m + n) / 2.0d0) - m_1) ** 2.0d0) + 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)) - (Math.pow((((m + n) / 2.0) - M), 2.0) + l)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((n - m)) - (math.pow((((m + n) / 2.0) - M), 2.0) + l)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64((Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0) + l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((n - m)) - (((((m + n) / 2.0) - M) ^ 2.0) + l))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Final simplification95.5%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (or (<= M -4e+126) (not (<= M 1.55e+77)))
(* (cos M) (exp (- t_0 (* M M))))
(exp (- t_0 (+ l (* (pow (+ m n) 2.0) 0.25)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if ((M <= -4e+126) || !(M <= 1.55e+77)) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = exp((t_0 - (l + (pow((m + n), 2.0) * 0.25))));
}
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 <= (-4d+126)) .or. (.not. (m_1 <= 1.55d+77))) then
tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
else
tmp = exp((t_0 - (l + (((m + n) ** 2.0d0) * 0.25d0))))
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 <= -4e+126) || !(M <= 1.55e+77)) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
} else {
tmp = Math.exp((t_0 - (l + (Math.pow((m + n), 2.0) * 0.25))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if (M <= -4e+126) or not (M <= 1.55e+77): tmp = math.cos(M) * math.exp((t_0 - (M * M))) else: tmp = math.exp((t_0 - (l + (math.pow((m + n), 2.0) * 0.25)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if ((M <= -4e+126) || !(M <= 1.55e+77)) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = exp(Float64(t_0 - Float64(l + Float64((Float64(m + n) ^ 2.0) * 0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if ((M <= -4e+126) || ~((M <= 1.55e+77))) tmp = cos(M) * exp((t_0 - (M * M))); else tmp = exp((t_0 - (l + (((m + n) ^ 2.0) * 0.25)))); 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, -4e+126], N[Not[LessEqual[M, 1.55e+77]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(l + N[(N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;M \leq -4 \cdot 10^{+126} \lor \neg \left(M \leq 1.55 \cdot 10^{+77}\right):\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \left(\ell + {\left(m + n\right)}^{2} \cdot 0.25\right)}\\
\end{array}
\end{array}
if M < -3.9999999999999997e126 or 1.54999999999999999e77 < M Initial program 78.8%
+-commutative78.8%
+-commutative78.8%
fabs-sub78.8%
associate-/l*80.0%
+-commutative80.0%
Simplified80.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 97.7%
mul-1-neg97.7%
unpow297.7%
distribute-rgt-neg-in97.7%
Simplified97.7%
if -3.9999999999999997e126 < M < 1.54999999999999999e77Initial program 73.5%
+-commutative73.5%
+-commutative73.5%
fabs-sub73.5%
associate-/l*73.1%
+-commutative73.1%
Simplified73.1%
Taylor expanded in K around 0 84.8%
cos-neg84.8%
sin-neg84.8%
Simplified84.8%
Taylor expanded in M around 0 92.1%
*-commutative92.1%
Simplified92.1%
Final simplification94.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 1.35e-122)
(exp (- t_0 (* 0.25 (* m m))))
(if (<= n 2.8e+31)
(* (cos M) (exp (- t_0 (* M 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.35e-122) {
tmp = exp((t_0 - (0.25 * (m * m))));
} else if (n <= 2.8e+31) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = 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.35d-122) then
tmp = exp((t_0 - (0.25d0 * (m * m))))
else if (n <= 2.8d+31) then
tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
else
tmp = 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.35e-122) {
tmp = Math.exp((t_0 - (0.25 * (m * m))));
} else if (n <= 2.8e+31) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
} else {
tmp = 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.35e-122: tmp = math.exp((t_0 - (0.25 * (m * m)))) elif n <= 2.8e+31: tmp = math.cos(M) * math.exp((t_0 - (M * M))) else: tmp = 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.35e-122) tmp = exp(Float64(t_0 - Float64(0.25 * Float64(m * m)))); elseif (n <= 2.8e+31) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = 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.35e-122) tmp = exp((t_0 - (0.25 * (m * m)))); elseif (n <= 2.8e+31) tmp = cos(M) * exp((t_0 - (M * M))); else tmp = 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.35e-122], N[Exp[N[(t$95$0 - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 2.8e+31], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 1.35 \cdot 10^{-122}:\\
\;\;\;\;e^{t_0 - 0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 2.8 \cdot 10^{+31}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - 0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 1.35000000000000005e-122Initial program 77.2%
+-commutative77.2%
+-commutative77.2%
fabs-sub77.2%
associate-/l*78.0%
+-commutative78.0%
Simplified78.0%
Taylor expanded in K around 0 83.9%
cos-neg83.9%
sin-neg83.9%
Simplified83.9%
Taylor expanded in M around 0 83.6%
*-commutative83.6%
Simplified83.6%
Taylor expanded in m around inf 52.0%
*-commutative52.0%
unpow252.0%
Simplified52.0%
if 1.35000000000000005e-122 < n < 2.80000000000000017e31Initial program 80.1%
+-commutative80.1%
+-commutative80.1%
fabs-sub80.1%
associate-/l*77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in K around 0 89.5%
cos-neg89.5%
Simplified89.5%
Taylor expanded in M around inf 57.7%
mul-1-neg57.7%
unpow257.7%
distribute-rgt-neg-in57.7%
Simplified57.7%
if 2.80000000000000017e31 < n Initial program 68.2%
+-commutative68.2%
+-commutative68.2%
fabs-sub68.2%
associate-/l*68.2%
+-commutative68.2%
Simplified68.2%
Taylor expanded in K around 0 81.8%
cos-neg81.8%
sin-neg81.8%
Simplified81.8%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in n around inf 94.0%
*-commutative94.0%
unpow294.0%
Simplified94.0%
Final simplification63.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 3.6e-121)
(* (cos M) (exp (+ t_0 (* (* m m) -0.25))))
(if (<= n 1e+36)
(* (cos M) (exp (- t_0 (* M 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 <= 3.6e-121) {
tmp = cos(M) * exp((t_0 + ((m * m) * -0.25)));
} else if (n <= 1e+36) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = 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 <= 3.6d-121) then
tmp = cos(m_1) * exp((t_0 + ((m * m) * (-0.25d0))))
else if (n <= 1d+36) then
tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
else
tmp = 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 <= 3.6e-121) {
tmp = Math.cos(M) * Math.exp((t_0 + ((m * m) * -0.25)));
} else if (n <= 1e+36) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
} else {
tmp = 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 <= 3.6e-121: tmp = math.cos(M) * math.exp((t_0 + ((m * m) * -0.25))) elif n <= 1e+36: tmp = math.cos(M) * math.exp((t_0 - (M * M))) else: tmp = 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 <= 3.6e-121) tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(Float64(m * m) * -0.25)))); elseif (n <= 1e+36) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = 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 <= 3.6e-121) tmp = cos(M) * exp((t_0 + ((m * m) * -0.25))); elseif (n <= 1e+36) tmp = cos(M) * exp((t_0 - (M * M))); else tmp = 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, 3.6e-121], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1e+36], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 3.6 \cdot 10^{-121}:\\
\;\;\;\;\cos M \cdot e^{t_0 + \left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;n \leq 10^{+36}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - 0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 3.59999999999999984e-121Initial program 77.2%
+-commutative77.2%
+-commutative77.2%
fabs-sub77.2%
associate-/l*78.0%
+-commutative78.0%
Simplified78.0%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in m around inf 52.0%
*-commutative52.0%
unpow252.0%
Simplified52.0%
if 3.59999999999999984e-121 < n < 1.00000000000000004e36Initial program 80.1%
+-commutative80.1%
+-commutative80.1%
fabs-sub80.1%
associate-/l*77.2%
+-commutative77.2%
Simplified77.2%
Taylor expanded in K around 0 89.5%
cos-neg89.5%
Simplified89.5%
Taylor expanded in M around inf 57.7%
mul-1-neg57.7%
unpow257.7%
distribute-rgt-neg-in57.7%
Simplified57.7%
if 1.00000000000000004e36 < n Initial program 68.2%
+-commutative68.2%
+-commutative68.2%
fabs-sub68.2%
associate-/l*68.2%
+-commutative68.2%
Simplified68.2%
Taylor expanded in K around 0 81.8%
cos-neg81.8%
sin-neg81.8%
Simplified81.8%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in n around inf 94.0%
*-commutative94.0%
unpow294.0%
Simplified94.0%
Final simplification63.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 8.2e-102)
(exp (- t_0 (* 0.25 (* m m))))
(if (<= n 1.02e+31)
(* (cos (- (/ (* (+ m n) K) 2.0) M)) (exp (- (* M 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 <= 8.2e-102) {
tmp = exp((t_0 - (0.25 * (m * m))));
} else if (n <= 1.02e+31) {
tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(-(M * M));
} else {
tmp = 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 <= 8.2d-102) then
tmp = exp((t_0 - (0.25d0 * (m * m))))
else if (n <= 1.02d+31) then
tmp = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp(-(m_1 * m_1))
else
tmp = 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 <= 8.2e-102) {
tmp = Math.exp((t_0 - (0.25 * (m * m))));
} else if (n <= 1.02e+31) {
tmp = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp(-(M * M));
} else {
tmp = 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 <= 8.2e-102: tmp = math.exp((t_0 - (0.25 * (m * m)))) elif n <= 1.02e+31: tmp = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp(-(M * M)) else: tmp = 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 <= 8.2e-102) tmp = exp(Float64(t_0 - Float64(0.25 * Float64(m * m)))); elseif (n <= 1.02e+31) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(-Float64(M * M)))); else tmp = 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 <= 8.2e-102) tmp = exp((t_0 - (0.25 * (m * m)))); elseif (n <= 1.02e+31) tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(-(M * M)); else tmp = 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, 8.2e-102], N[Exp[N[(t$95$0 - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 1.02e+31], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[(-N[(M * M), $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 8.2 \cdot 10^{-102}:\\
\;\;\;\;e^{t_0 - 0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 1.02 \cdot 10^{+31}:\\
\;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{-M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - 0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 8.2000000000000005e-102Initial program 77.2%
+-commutative77.2%
+-commutative77.2%
fabs-sub77.2%
associate-/l*77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in K around 0 83.7%
cos-neg83.7%
sin-neg83.7%
Simplified83.7%
Taylor expanded in M around 0 83.5%
*-commutative83.5%
Simplified83.5%
Taylor expanded in m around inf 52.1%
*-commutative52.1%
unpow252.1%
Simplified52.1%
if 8.2000000000000005e-102 < n < 1.02000000000000007e31Initial program 80.7%
Taylor expanded in M around inf 61.0%
unpow261.0%
Simplified61.0%
Taylor expanded in M around inf 61.3%
mul-1-neg61.3%
unpow261.3%
distribute-rgt-neg-out61.3%
Simplified61.3%
if 1.02000000000000007e31 < n Initial program 68.2%
+-commutative68.2%
+-commutative68.2%
fabs-sub68.2%
associate-/l*68.2%
+-commutative68.2%
Simplified68.2%
Taylor expanded in K around 0 81.8%
cos-neg81.8%
sin-neg81.8%
Simplified81.8%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in n around inf 94.0%
*-commutative94.0%
unpow294.0%
Simplified94.0%
Final simplification64.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= m -1.6e+38)
(exp (- t_0 (* 0.25 (* m m))))
(if (or (<= m -3.2e-150) (not (<= m -9.4e-194)))
(exp (- t_0 (* 0.25 (* n n))))
(* (cos (* 0.5 (* m K))) (exp (- l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (m <= -1.6e+38) {
tmp = exp((t_0 - (0.25 * (m * m))));
} else if ((m <= -3.2e-150) || !(m <= -9.4e-194)) {
tmp = exp((t_0 - (0.25 * (n * n))));
} else {
tmp = cos((0.5 * (m * K))) * 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) :: t_0
real(8) :: tmp
t_0 = abs((n - m))
if (m <= (-1.6d+38)) then
tmp = exp((t_0 - (0.25d0 * (m * m))))
else if ((m <= (-3.2d-150)) .or. (.not. (m <= (-9.4d-194)))) then
tmp = exp((t_0 - (0.25d0 * (n * n))))
else
tmp = cos((0.5d0 * (m * k))) * exp(-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 <= -1.6e+38) {
tmp = Math.exp((t_0 - (0.25 * (m * m))));
} else if ((m <= -3.2e-150) || !(m <= -9.4e-194)) {
tmp = Math.exp((t_0 - (0.25 * (n * n))));
} else {
tmp = Math.cos((0.5 * (m * K))) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if m <= -1.6e+38: tmp = math.exp((t_0 - (0.25 * (m * m)))) elif (m <= -3.2e-150) or not (m <= -9.4e-194): tmp = math.exp((t_0 - (0.25 * (n * n)))) else: tmp = math.cos((0.5 * (m * K))) * math.exp(-l) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (m <= -1.6e+38) tmp = exp(Float64(t_0 - Float64(0.25 * Float64(m * m)))); elseif ((m <= -3.2e-150) || !(m <= -9.4e-194)) tmp = exp(Float64(t_0 - Float64(0.25 * Float64(n * n)))); else tmp = Float64(cos(Float64(0.5 * Float64(m * K))) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (m <= -1.6e+38) tmp = exp((t_0 - (0.25 * (m * m)))); elseif ((m <= -3.2e-150) || ~((m <= -9.4e-194))) tmp = exp((t_0 - (0.25 * (n * n)))); else tmp = cos((0.5 * (m * K))) * exp(-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, -1.6e+38], N[Exp[N[(t$95$0 - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[m, -3.2e-150], N[Not[LessEqual[m, -9.4e-194]], $MachinePrecision]], N[Exp[N[(t$95$0 - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(0.5 * N[(m * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;m \leq -1.6 \cdot 10^{+38}:\\
\;\;\;\;e^{t_0 - 0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;m \leq -3.2 \cdot 10^{-150} \lor \neg \left(m \leq -9.4 \cdot 10^{-194}\right):\\
\;\;\;\;e^{t_0 - 0.25 \cdot \left(n \cdot n\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(0.5 \cdot \left(m \cdot K\right)\right) \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -1.59999999999999993e38Initial program 69.8%
+-commutative69.8%
+-commutative69.8%
fabs-sub69.8%
associate-/l*69.8%
+-commutative69.8%
Simplified69.8%
Taylor expanded in K around 0 81.1%
cos-neg81.1%
sin-neg81.1%
Simplified81.1%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in m around inf 98.1%
*-commutative98.1%
unpow298.1%
Simplified98.1%
if -1.59999999999999993e38 < m < -3.1999999999999998e-150 or -9.4000000000000005e-194 < m Initial program 76.3%
+-commutative76.3%
+-commutative76.3%
fabs-sub76.3%
associate-/l*76.4%
+-commutative76.4%
Simplified76.4%
Taylor expanded in K around 0 83.3%
cos-neg83.3%
sin-neg83.3%
Simplified83.3%
Taylor expanded in M around 0 83.3%
*-commutative83.3%
Simplified83.3%
Taylor expanded in n around inf 55.9%
*-commutative55.9%
unpow255.9%
Simplified55.9%
if -3.1999999999999998e-150 < m < -9.4000000000000005e-194Initial program 83.6%
+-commutative83.6%
+-commutative83.6%
fabs-sub83.6%
associate-/l*83.6%
+-commutative83.6%
Simplified83.6%
Taylor expanded in l around inf 39.0%
neg-mul-139.0%
Simplified39.0%
Taylor expanded in l around inf 39.3%
neg-mul-139.3%
Simplified39.3%
Taylor expanded in m around inf 48.4%
Final simplification64.3%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -1e+41) (not (<= m 7.8e+88))) (exp (- (fabs (- n m)) (* 0.25 (* m m)))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -1e+41) || !(m <= 7.8e+88)) {
tmp = exp((fabs((n - m)) - (0.25 * (m * m))));
} else {
tmp = cos(M) * exp(-l);
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if ((m <= (-1d+41)) .or. (.not. (m <= 7.8d+88))) then
tmp = exp((abs((n - m)) - (0.25d0 * (m * m))))
else
tmp = cos(m_1) * exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -1e+41) || !(m <= 7.8e+88)) {
tmp = Math.exp((Math.abs((n - m)) - (0.25 * (m * m))));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -1e+41) or not (m <= 7.8e+88): tmp = math.exp((math.fabs((n - m)) - (0.25 * (m * m)))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -1e+41) || !(m <= 7.8e+88)) tmp = exp(Float64(abs(Float64(n - m)) - Float64(0.25 * Float64(m * m)))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -1e+41) || ~((m <= 7.8e+88))) tmp = exp((abs((n - m)) - (0.25 * (m * m)))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -1e+41], N[Not[LessEqual[m, 7.8e+88]], $MachinePrecision]], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1 \cdot 10^{+41} \lor \neg \left(m \leq 7.8 \cdot 10^{+88}\right):\\
\;\;\;\;e^{\left|n - m\right| - 0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -1.00000000000000001e41 or 7.8000000000000002e88 < m Initial program 68.1%
+-commutative68.1%
+-commutative68.1%
fabs-sub68.1%
associate-/l*68.1%
+-commutative68.1%
Simplified68.1%
Taylor expanded in K around 0 80.9%
cos-neg80.9%
sin-neg80.9%
Simplified80.9%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in m around inf 99.0%
*-commutative99.0%
unpow299.0%
Simplified99.0%
if -1.00000000000000001e41 < m < 7.8000000000000002e88Initial program 79.4%
+-commutative79.4%
+-commutative79.4%
fabs-sub79.4%
associate-/l*79.6%
+-commutative79.6%
Simplified79.6%
Taylor expanded in l around inf 30.1%
neg-mul-130.1%
Simplified30.1%
Taylor expanded in l around inf 35.2%
neg-mul-135.2%
Simplified35.2%
Taylor expanded in K around 0 41.3%
cos-neg41.3%
Simplified41.3%
Final simplification62.4%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * 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 = cos(m_1) * exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(-l);
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(-l)
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{-\ell}
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in l around inf 21.4%
neg-mul-121.4%
Simplified21.4%
Taylor expanded in l around inf 27.5%
neg-mul-127.5%
Simplified27.5%
Taylor expanded in K around 0 34.7%
cos-neg34.7%
Simplified34.7%
Final simplification34.7%
(FPCore (K m n M l) :precision binary64 (exp (fabs (- n m))))
double code(double K, double m, double n, double M, double l) {
return exp(fabs((n - m)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(abs((n - m)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(Math.abs((n - m)));
}
def code(K, m, n, M, l): return math.exp(math.fabs((n - m)))
function code(K, m, n, M, l) return exp(abs(Float64(n - m))) end
function tmp = code(K, m, n, M, l) tmp = exp(abs((n - m))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|n - m\right|}
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in n around inf 51.5%
*-commutative51.5%
unpow251.5%
Simplified51.5%
Taylor expanded in n around 0 8.2%
Taylor expanded in M around 0 8.6%
Final simplification8.6%
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
def code(K, m, n, M, l): return math.cos(M)
function code(K, m, n, M, l) return cos(M) end
function tmp = code(K, m, n, M, l) tmp = cos(M); end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
\\
\cos M
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in l around inf 21.4%
neg-mul-121.4%
Simplified21.4%
Taylor expanded in l around inf 27.5%
neg-mul-127.5%
Simplified27.5%
Taylor expanded in l around 0 5.8%
associate-*r*5.8%
Simplified5.8%
Taylor expanded in K around 0 6.7%
cos-neg6.7%
Simplified6.7%
Final simplification6.7%
herbie shell --seed 2023279
(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)))))))