
(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 (- m n)) (+ (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((m - n)) - (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((m - n)) - (((((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((m - n)) - (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((m - n)) - (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(m - n)) - 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((m - n)) - (((((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[(m - n), $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|m - n\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 74.3%
associate-/l*74.6%
associate--r-74.6%
Simplified74.6%
Taylor expanded in K around 0 98.3%
cos-neg98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))) (t_1 (exp (+ (* M M) (- l t_0)))))
(if (<= M -3.3e+163)
(/ 1.0 t_1)
(if (<= M 1.48e+29)
(exp (- t_0 (+ l (* 0.25 (pow (+ m n) 2.0)))))
(/ (cos M) t_1)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double t_1 = exp(((M * M) + (l - t_0)));
double tmp;
if (M <= -3.3e+163) {
tmp = 1.0 / t_1;
} else if (M <= 1.48e+29) {
tmp = exp((t_0 - (l + (0.25 * pow((m + n), 2.0)))));
} else {
tmp = cos(M) / t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = abs((m - n))
t_1 = exp(((m_1 * m_1) + (l - t_0)))
if (m_1 <= (-3.3d+163)) then
tmp = 1.0d0 / t_1
else if (m_1 <= 1.48d+29) then
tmp = exp((t_0 - (l + (0.25d0 * ((m + n) ** 2.0d0)))))
else
tmp = cos(m_1) / t_1
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 t_1 = Math.exp(((M * M) + (l - t_0)));
double tmp;
if (M <= -3.3e+163) {
tmp = 1.0 / t_1;
} else if (M <= 1.48e+29) {
tmp = Math.exp((t_0 - (l + (0.25 * Math.pow((m + n), 2.0)))));
} else {
tmp = Math.cos(M) / t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) t_1 = math.exp(((M * M) + (l - t_0))) tmp = 0 if M <= -3.3e+163: tmp = 1.0 / t_1 elif M <= 1.48e+29: tmp = math.exp((t_0 - (l + (0.25 * math.pow((m + n), 2.0))))) else: tmp = math.cos(M) / t_1 return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) t_1 = exp(Float64(Float64(M * M) + Float64(l - t_0))) tmp = 0.0 if (M <= -3.3e+163) tmp = Float64(1.0 / t_1); elseif (M <= 1.48e+29) tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * (Float64(m + n) ^ 2.0))))); else tmp = Float64(cos(M) / t_1); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); t_1 = exp(((M * M) + (l - t_0))); tmp = 0.0; if (M <= -3.3e+163) tmp = 1.0 / t_1; elseif (M <= 1.48e+29) tmp = exp((t_0 - (l + (0.25 * ((m + n) ^ 2.0))))); else tmp = cos(M) / t_1; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(M * M), $MachinePrecision] + N[(l - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -3.3e+163], N[(1.0 / t$95$1), $MachinePrecision], If[LessEqual[M, 1.48e+29], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
t_1 := e^{M \cdot M + \left(\ell - t_0\right)}\\
\mathbf{if}\;M \leq -3.3 \cdot 10^{+163}:\\
\;\;\;\;\frac{1}{t_1}\\
\mathbf{elif}\;M \leq 1.48 \cdot 10^{+29}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot {\left(m + n\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{t_1}\\
\end{array}
\end{array}
if M < -3.3e163Initial program 73.8%
Simplified73.8%
Taylor expanded in M around inf 73.8%
unpow273.8%
Simplified73.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
if -3.3e163 < M < 1.48e29Initial program 74.9%
associate-/l*75.5%
associate--r-75.5%
Simplified75.5%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in M around 0 94.2%
fabs-sub94.2%
+-commutative94.2%
Simplified94.2%
if 1.48e29 < M Initial program 72.1%
Simplified72.1%
Taylor expanded in M around inf 67.5%
unpow267.5%
Simplified67.5%
Taylor expanded in K around 0 90.8%
cos-neg90.8%
Simplified90.8%
Final simplification94.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (<= m -3.8e-7)
(exp (- t_0 (+ l (* 0.25 (* m m)))))
(if (<= m -3.5e-224)
(/ (cos M) (exp (+ (* M M) (- l t_0))))
(exp (- t_0 (+ l (* 0.25 (* n n)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if (m <= -3.8e-7) {
tmp = exp((t_0 - (l + (0.25 * (m * m)))));
} else if (m <= -3.5e-224) {
tmp = cos(M) / exp(((M * M) + (l - t_0)));
} else {
tmp = exp((t_0 - (l + (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((m - n))
if (m <= (-3.8d-7)) then
tmp = exp((t_0 - (l + (0.25d0 * (m * m)))))
else if (m <= (-3.5d-224)) then
tmp = cos(m_1) / exp(((m_1 * m_1) + (l - t_0)))
else
tmp = exp((t_0 - (l + (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((m - n));
double tmp;
if (m <= -3.8e-7) {
tmp = Math.exp((t_0 - (l + (0.25 * (m * m)))));
} else if (m <= -3.5e-224) {
tmp = Math.cos(M) / Math.exp(((M * M) + (l - t_0)));
} else {
tmp = Math.exp((t_0 - (l + (0.25 * (n * n)))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if m <= -3.8e-7: tmp = math.exp((t_0 - (l + (0.25 * (m * m))))) elif m <= -3.5e-224: tmp = math.cos(M) / math.exp(((M * M) + (l - t_0))) else: tmp = math.exp((t_0 - (l + (0.25 * (n * n))))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if (m <= -3.8e-7) tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(m * m))))); elseif (m <= -3.5e-224) tmp = Float64(cos(M) / exp(Float64(Float64(M * M) + Float64(l - t_0)))); else tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if (m <= -3.8e-7) tmp = exp((t_0 - (l + (0.25 * (m * m))))); elseif (m <= -3.5e-224) tmp = cos(M) / exp(((M * M) + (l - t_0))); else tmp = exp((t_0 - (l + (0.25 * (n * n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -3.8e-7], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -3.5e-224], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(N[(M * M), $MachinePrecision] + N[(l - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;m \leq -3.8 \cdot 10^{-7}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(m \cdot m\right)\right)}\\
\mathbf{elif}\;m \leq -3.5 \cdot 10^{-224}:\\
\;\;\;\;\frac{\cos M}{e^{M \cdot M + \left(\ell - t_0\right)}}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(n \cdot n\right)\right)}\\
\end{array}
\end{array}
if m < -3.80000000000000015e-7Initial program 67.8%
associate-/l*67.8%
associate--r-67.8%
Simplified67.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 98.3%
fabs-sub98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in m around inf 88.3%
unpow288.3%
Simplified88.3%
if -3.80000000000000015e-7 < m < -3.50000000000000019e-224Initial program 72.1%
Simplified72.1%
Taylor expanded in M around inf 59.0%
unpow259.0%
Simplified59.0%
Taylor expanded in K around 0 79.1%
cos-neg79.1%
Simplified79.1%
if -3.50000000000000019e-224 < m Initial program 77.4%
associate-/l*77.4%
associate--r-77.4%
Simplified77.4%
Taylor expanded in K around 0 98.8%
cos-neg98.8%
Simplified98.8%
Taylor expanded in M around 0 86.7%
fabs-sub86.7%
+-commutative86.7%
Simplified86.7%
Taylor expanded in m around 0 70.5%
unpow270.5%
Simplified70.5%
Final simplification76.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (<= m -3.8e-7)
(exp (- t_0 (+ l (* 0.25 (* m m)))))
(if (<= m -4.6e-225)
(/ 1.0 (exp (+ (* M M) (- l t_0))))
(exp (- t_0 (+ l (* 0.25 (* n n)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if (m <= -3.8e-7) {
tmp = exp((t_0 - (l + (0.25 * (m * m)))));
} else if (m <= -4.6e-225) {
tmp = 1.0 / exp(((M * M) + (l - t_0)));
} else {
tmp = exp((t_0 - (l + (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((m - n))
if (m <= (-3.8d-7)) then
tmp = exp((t_0 - (l + (0.25d0 * (m * m)))))
else if (m <= (-4.6d-225)) then
tmp = 1.0d0 / exp(((m_1 * m_1) + (l - t_0)))
else
tmp = exp((t_0 - (l + (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((m - n));
double tmp;
if (m <= -3.8e-7) {
tmp = Math.exp((t_0 - (l + (0.25 * (m * m)))));
} else if (m <= -4.6e-225) {
tmp = 1.0 / Math.exp(((M * M) + (l - t_0)));
} else {
tmp = Math.exp((t_0 - (l + (0.25 * (n * n)))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if m <= -3.8e-7: tmp = math.exp((t_0 - (l + (0.25 * (m * m))))) elif m <= -4.6e-225: tmp = 1.0 / math.exp(((M * M) + (l - t_0))) else: tmp = math.exp((t_0 - (l + (0.25 * (n * n))))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if (m <= -3.8e-7) tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(m * m))))); elseif (m <= -4.6e-225) tmp = Float64(1.0 / exp(Float64(Float64(M * M) + Float64(l - t_0)))); else tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if (m <= -3.8e-7) tmp = exp((t_0 - (l + (0.25 * (m * m))))); elseif (m <= -4.6e-225) tmp = 1.0 / exp(((M * M) + (l - t_0))); else tmp = exp((t_0 - (l + (0.25 * (n * n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -3.8e-7], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -4.6e-225], N[(1.0 / N[Exp[N[(N[(M * M), $MachinePrecision] + N[(l - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;m \leq -3.8 \cdot 10^{-7}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(m \cdot m\right)\right)}\\
\mathbf{elif}\;m \leq -4.6 \cdot 10^{-225}:\\
\;\;\;\;\frac{1}{e^{M \cdot M + \left(\ell - t_0\right)}}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(n \cdot n\right)\right)}\\
\end{array}
\end{array}
if m < -3.80000000000000015e-7Initial program 67.8%
associate-/l*67.8%
associate--r-67.8%
Simplified67.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 98.3%
fabs-sub98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in m around inf 88.3%
unpow288.3%
Simplified88.3%
if -3.80000000000000015e-7 < m < -4.5999999999999998e-225Initial program 72.1%
Simplified72.1%
Taylor expanded in M around inf 59.0%
unpow259.0%
Simplified59.0%
Taylor expanded in K around 0 79.1%
cos-neg79.1%
Simplified79.1%
Taylor expanded in M around 0 79.1%
if -4.5999999999999998e-225 < m Initial program 77.4%
associate-/l*77.4%
associate--r-77.4%
Simplified77.4%
Taylor expanded in K around 0 98.8%
cos-neg98.8%
Simplified98.8%
Taylor expanded in M around 0 86.7%
fabs-sub86.7%
+-commutative86.7%
Simplified86.7%
Taylor expanded in m around 0 70.5%
unpow270.5%
Simplified70.5%
Final simplification76.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (<= m -3.8e-7)
(exp (- t_0 (+ l (* 0.25 (* m m)))))
(exp (- t_0 (+ l (* 0.25 (* n n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if (m <= -3.8e-7) {
tmp = exp((t_0 - (l + (0.25 * (m * m)))));
} else {
tmp = exp((t_0 - (l + (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((m - n))
if (m <= (-3.8d-7)) then
tmp = exp((t_0 - (l + (0.25d0 * (m * m)))))
else
tmp = exp((t_0 - (l + (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((m - n));
double tmp;
if (m <= -3.8e-7) {
tmp = Math.exp((t_0 - (l + (0.25 * (m * m)))));
} else {
tmp = Math.exp((t_0 - (l + (0.25 * (n * n)))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if m <= -3.8e-7: tmp = math.exp((t_0 - (l + (0.25 * (m * m))))) else: tmp = math.exp((t_0 - (l + (0.25 * (n * n))))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if (m <= -3.8e-7) tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(m * m))))); else tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if (m <= -3.8e-7) tmp = exp((t_0 - (l + (0.25 * (m * m))))); else tmp = exp((t_0 - (l + (0.25 * (n * n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -3.8e-7], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;m \leq -3.8 \cdot 10^{-7}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(m \cdot m\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(n \cdot n\right)\right)}\\
\end{array}
\end{array}
if m < -3.80000000000000015e-7Initial program 67.8%
associate-/l*67.8%
associate--r-67.8%
Simplified67.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 98.3%
fabs-sub98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in m around inf 88.3%
unpow288.3%
Simplified88.3%
if -3.80000000000000015e-7 < m Initial program 76.2%
associate-/l*76.7%
associate--r-76.7%
Simplified76.7%
Taylor expanded in K around 0 97.8%
cos-neg97.8%
Simplified97.8%
Taylor expanded in M around 0 81.6%
fabs-sub81.6%
+-commutative81.6%
Simplified81.6%
Taylor expanded in m around 0 69.1%
unpow269.1%
Simplified69.1%
Final simplification73.5%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- m n)) (+ l (* 0.25 (* m m))))))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((m - n)) - (l + (0.25 * (m * 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((m - n)) - (l + (0.25d0 * (m * m)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((m - n)) - (l + (0.25 * (m * m)))));
}
def code(K, m, n, M, l): return math.exp((math.fabs((m - n)) - (l + (0.25 * (m * m)))))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(m - n)) - Float64(l + Float64(0.25 * Float64(m * m))))) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((m - n)) - (l + (0.25 * (m * m))))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|m - n\right| - \left(\ell + 0.25 \cdot \left(m \cdot m\right)\right)}
\end{array}
Initial program 74.3%
associate-/l*74.6%
associate--r-74.6%
Simplified74.6%
Taylor expanded in K around 0 98.3%
cos-neg98.3%
Simplified98.3%
Taylor expanded in M around 0 85.4%
fabs-sub85.4%
+-commutative85.4%
Simplified85.4%
Taylor expanded in m around inf 61.2%
unpow261.2%
Simplified61.2%
Final simplification61.2%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- m n)) l)))
double code(double K, double m, double n, double M, double l) {
return 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 = exp((abs((m - n)) - l))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((m - n)) - l));
}
def code(K, m, n, M, l): return math.exp((math.fabs((m - n)) - l))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(m - n)) - l)) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((m - n)) - l)); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|m - n\right| - \ell}
\end{array}
Initial program 74.3%
Simplified74.3%
Taylor expanded in M around inf 46.1%
unpow246.1%
Simplified46.1%
Taylor expanded in K around 0 58.7%
cos-neg58.7%
Simplified58.7%
Taylor expanded in M around 0 25.4%
rec-exp25.4%
fabs-sub25.4%
sub-neg25.4%
+-commutative25.4%
distribute-neg-in25.4%
remove-double-neg25.4%
sub-neg25.4%
fabs-sub25.4%
Simplified25.4%
Final simplification25.4%
herbie shell --seed 2023255
(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)))))))