
(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 7 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 (<= m -1.5e+19)
(* (cos M) (exp (- t_0 (+ (* (* m m) 0.25) l))))
(*
(cos M)
(exp (+ t_0 (- (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (m <= -1.5e+19) {
tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l)));
} else {
tmp = cos(M) * exp((t_0 + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - 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.5d+19)) then
tmp = cos(m_1) * exp((t_0 - (((m * m) * 0.25d0) + l)))
else
tmp = cos(m_1) * exp((t_0 + ((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) - 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.5e+19) {
tmp = Math.cos(M) * Math.exp((t_0 - (((m * m) * 0.25) + l)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if m <= -1.5e+19: tmp = math.cos(M) * math.exp((t_0 - (((m * m) * 0.25) + l))) else: tmp = math.cos(M) * math.exp((t_0 + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (m <= -1.5e+19) 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(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) - 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.5e+19) tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l))); else tmp = cos(M) * exp((t_0 + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - 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.5e+19], 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[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;m \leq -1.5 \cdot 10^{+19}:\\
\;\;\;\;\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(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) - \ell\right)}\\
\end{array}
\end{array}
if m < -1.5e19Initial program 55.2%
+-commutative55.2%
+-commutative55.2%
fabs-sub55.2%
associate-/l*55.2%
+-commutative55.2%
Simplified55.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 88.1%
*-commutative88.1%
unpow288.1%
Simplified88.1%
if -1.5e19 < m Initial program 78.2%
+-commutative78.2%
+-commutative78.2%
fabs-sub78.2%
associate-/l*78.8%
+-commutative78.8%
Simplified78.8%
Taylor expanded in K around 0 95.7%
cos-neg95.7%
Simplified95.7%
Taylor expanded in m around 0 78.8%
+-commutative78.8%
unpow278.8%
distribute-rgt-out82.9%
*-commutative82.9%
*-commutative82.9%
Simplified82.9%
Final simplification84.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= m -8.2e+14)
(* (cos M) (exp (- t_0 (+ (* (* m m) 0.25) l))))
(if (<= m 4.7e-278)
(* (cos M) (exp (- t_0 (+ (* M M) l))))
(* (cos M) (exp (- t_0 (+ (* 0.25 (* n n)) l))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (m <= -8.2e+14) {
tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l)));
} else if (m <= 4.7e-278) {
tmp = cos(M) * exp((t_0 - ((M * M) + l)));
} else {
tmp = cos(M) * exp((t_0 - ((0.25 * (n * n)) + 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 <= (-8.2d+14)) then
tmp = cos(m_1) * exp((t_0 - (((m * m) * 0.25d0) + l)))
else if (m <= 4.7d-278) 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)) + 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 <= -8.2e+14) {
tmp = Math.cos(M) * Math.exp((t_0 - (((m * m) * 0.25) + l)));
} else if (m <= 4.7e-278) {
tmp = Math.cos(M) * Math.exp((t_0 - ((M * M) + l)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 - ((0.25 * (n * n)) + l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if m <= -8.2e+14: tmp = math.cos(M) * math.exp((t_0 - (((m * m) * 0.25) + l))) elif m <= 4.7e-278: tmp = math.cos(M) * math.exp((t_0 - ((M * M) + l))) else: tmp = math.cos(M) * math.exp((t_0 - ((0.25 * (n * n)) + l))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (m <= -8.2e+14) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(Float64(Float64(m * m) * 0.25) + l)))); elseif (m <= 4.7e-278) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(Float64(M * M) + l)))); else tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(Float64(0.25 * Float64(n * n)) + l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (m <= -8.2e+14) tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l))); elseif (m <= 4.7e-278) tmp = cos(M) * exp((t_0 - ((M * M) + l))); else tmp = cos(M) * exp((t_0 - ((0.25 * (n * n)) + 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, -8.2e+14], 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[m, 4.7e-278], 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[(N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;m \leq -8.2 \cdot 10^{+14}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(\left(m \cdot m\right) \cdot 0.25 + \ell\right)}\\
\mathbf{elif}\;m \leq 4.7 \cdot 10^{-278}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(M \cdot M + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(0.25 \cdot \left(n \cdot n\right) + \ell\right)}\\
\end{array}
\end{array}
if m < -8.2e14Initial program 55.2%
+-commutative55.2%
+-commutative55.2%
fabs-sub55.2%
associate-/l*55.2%
+-commutative55.2%
Simplified55.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 88.1%
*-commutative88.1%
unpow288.1%
Simplified88.1%
if -8.2e14 < m < 4.6999999999999997e-278Initial program 82.7%
+-commutative82.7%
+-commutative82.7%
fabs-sub82.7%
associate-/l*84.3%
+-commutative84.3%
Simplified84.3%
Taylor expanded in K around 0 94.8%
cos-neg94.8%
Simplified94.8%
Taylor expanded in M around inf 65.1%
unpow265.1%
Simplified65.1%
if 4.6999999999999997e-278 < m Initial program 75.5%
+-commutative75.5%
+-commutative75.5%
fabs-sub75.5%
associate-/l*75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in K around 0 96.2%
cos-neg96.2%
Simplified96.2%
Taylor expanded in n around inf 57.2%
*-commutative57.2%
unpow257.2%
Simplified57.2%
Final simplification66.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= m -5000000000000.0)
(* (cos M) (exp (- t_0 (+ (* (* m m) 0.25) l))))
(* (cos M) (exp (- t_0 (+ (* M M) l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (m <= -5000000000000.0) {
tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l)));
} else {
tmp = cos(M) * exp((t_0 - ((M * M) + 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 <= (-5000000000000.0d0)) then
tmp = cos(m_1) * exp((t_0 - (((m * m) * 0.25d0) + l)))
else
tmp = cos(m_1) * exp((t_0 - ((m_1 * m_1) + 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 <= -5000000000000.0) {
tmp = Math.cos(M) * Math.exp((t_0 - (((m * m) * 0.25) + l)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 - ((M * M) + l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if m <= -5000000000000.0: tmp = math.cos(M) * math.exp((t_0 - (((m * m) * 0.25) + l))) else: tmp = math.cos(M) * math.exp((t_0 - ((M * M) + l))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (m <= -5000000000000.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(M * M) + l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (m <= -5000000000000.0) tmp = cos(M) * exp((t_0 - (((m * m) * 0.25) + l))); else tmp = cos(M) * exp((t_0 - ((M * M) + 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, -5000000000000.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[(M * M), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;m \leq -5000000000000:\\
\;\;\;\;\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(M \cdot M + \ell\right)}\\
\end{array}
\end{array}
if m < -5e12Initial program 55.2%
+-commutative55.2%
+-commutative55.2%
fabs-sub55.2%
associate-/l*55.2%
+-commutative55.2%
Simplified55.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 88.1%
*-commutative88.1%
unpow288.1%
Simplified88.1%
if -5e12 < m Initial program 78.2%
+-commutative78.2%
+-commutative78.2%
fabs-sub78.2%
associate-/l*78.8%
+-commutative78.8%
Simplified78.8%
Taylor expanded in K around 0 95.7%
cos-neg95.7%
Simplified95.7%
Taylor expanded in M around inf 62.5%
unpow262.5%
Simplified62.5%
Final simplification68.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (or (<= M -4.5e+37) (not (<= M 2.9e+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((m - n));
double tmp;
if ((M <= -4.5e+37) || !(M <= 2.9e+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((m - n))
if ((m_1 <= (-4.5d+37)) .or. (.not. (m_1 <= 2.9d+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((m - n));
double tmp;
if ((M <= -4.5e+37) || !(M <= 2.9e+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((m - n)) tmp = 0 if (M <= -4.5e+37) or not (M <= 2.9e+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(m - n)) tmp = 0.0 if ((M <= -4.5e+37) || !(M <= 2.9e+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((m - n)); tmp = 0.0; if ((M <= -4.5e+37) || ~((M <= 2.9e+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[(m - n), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[M, -4.5e+37], N[Not[LessEqual[M, 2.9e+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|m - n\right|\\
\mathbf{if}\;M \leq -4.5 \cdot 10^{+37} \lor \neg \left(M \leq 2.9 \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 < -4.49999999999999962e37 or 2.8999999999999999e25 < 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%
unpow288.5%
Simplified88.5%
Taylor expanded in M around inf 89.3%
mul-1-neg89.3%
unpow289.3%
distribute-rgt-neg-out89.3%
Simplified89.3%
if -4.49999999999999962e37 < M < 2.8999999999999999e25Initial program 66.0%
+-commutative66.0%
+-commutative66.0%
fabs-sub66.0%
associate-/l*67.0%
+-commutative67.0%
Simplified67.0%
Taylor expanded in K around 0 94.4%
cos-neg94.4%
Simplified94.4%
Taylor expanded in M around inf 30.2%
unpow230.2%
Simplified30.2%
Taylor expanded in M around 0 29.5%
neg-mul-129.5%
Simplified29.5%
Final simplification57.6%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (fabs (- n m)) (+ (* M M) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((n - m)) - ((M * 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)) - ((m_1 * m_1) + 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)) - ((M * M) + l)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((n - m)) - ((M * M) + l)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64(Float64(M * M) + l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((n - m)) - ((M * M) + 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[(M * M), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left(M \cdot M + \ell\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%
Taylor expanded in M around inf 57.6%
unpow257.6%
Simplified57.6%
Final simplification57.6%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (fabs (- m n)) l))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((m - n)) - 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((m - n)) - 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((m - n)) - l));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((m - n)) - l))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(m - n)) - l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((m - n)) - l)); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|m - n\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 K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Taylor expanded in M around inf 57.6%
unpow257.6%
Simplified57.6%
Taylor expanded in M around 0 22.7%
neg-mul-122.7%
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)))))))