
(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 6 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 (+ (pow (- (/ (+ m n) 2.0) M) 2.0) (- l (fabs (- n m)))))))
double code(double K, double m, double n, double M, double l) {
return cos(-M) / exp((pow((((m + n) / 2.0) - M), 2.0) + (l - 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 = cos(-m_1) / exp((((((m + n) / 2.0d0) - m_1) ** 2.0d0) + (l - abs((n - m)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(-M) / Math.exp((Math.pow((((m + n) / 2.0) - M), 2.0) + (l - Math.abs((n - m)))));
}
def code(K, m, n, M, l): return math.cos(-M) / math.exp((math.pow((((m + n) / 2.0) - M), 2.0) + (l - math.fabs((n - m)))))
function code(K, m, n, M, l) return Float64(cos(Float64(-M)) / exp(Float64((Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0) + Float64(l - abs(Float64(n - m)))))) end
function tmp = code(K, m, n, M, l) tmp = cos(-M) / exp((((((m + n) / 2.0) - M) ^ 2.0) + (l - abs((n - m))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[(-M)], $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[(n - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos \left(-M\right)}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|n - m\right|\right)}}
\end{array}
Initial program 74.3%
Simplified74.3%
Taylor expanded in K around 0 98.4%
neg-mul-198.4%
Simplified98.4%
Final simplification98.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m)))
(t_1 (/ (cos M) (exp (+ (- l t_0) (* M M)))))
(t_2 (exp (- t_0 (+ l (* 0.25 (* m m)))))))
(if (<= n -1.02e-179)
t_2
(if (<= n -3.1e-257)
t_1
(if (<= n 1.15e-126)
t_2
(if (<= n 52.0) t_1 (/ (cos M) (exp (* 0.25 (* n n))))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double t_1 = cos(M) / exp(((l - t_0) + (M * M)));
double t_2 = exp((t_0 - (l + (0.25 * (m * m)))));
double tmp;
if (n <= -1.02e-179) {
tmp = t_2;
} else if (n <= -3.1e-257) {
tmp = t_1;
} else if (n <= 1.15e-126) {
tmp = t_2;
} else if (n <= 52.0) {
tmp = t_1;
} else {
tmp = cos(M) / exp((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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = abs((n - m))
t_1 = cos(m_1) / exp(((l - t_0) + (m_1 * m_1)))
t_2 = exp((t_0 - (l + (0.25d0 * (m * m)))))
if (n <= (-1.02d-179)) then
tmp = t_2
else if (n <= (-3.1d-257)) then
tmp = t_1
else if (n <= 1.15d-126) then
tmp = t_2
else if (n <= 52.0d0) then
tmp = t_1
else
tmp = cos(m_1) / exp((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 t_1 = Math.cos(M) / Math.exp(((l - t_0) + (M * M)));
double t_2 = Math.exp((t_0 - (l + (0.25 * (m * m)))));
double tmp;
if (n <= -1.02e-179) {
tmp = t_2;
} else if (n <= -3.1e-257) {
tmp = t_1;
} else if (n <= 1.15e-126) {
tmp = t_2;
} else if (n <= 52.0) {
tmp = t_1;
} else {
tmp = Math.cos(M) / Math.exp((0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) t_1 = math.cos(M) / math.exp(((l - t_0) + (M * M))) t_2 = math.exp((t_0 - (l + (0.25 * (m * m))))) tmp = 0 if n <= -1.02e-179: tmp = t_2 elif n <= -3.1e-257: tmp = t_1 elif n <= 1.15e-126: tmp = t_2 elif n <= 52.0: tmp = t_1 else: tmp = math.cos(M) / math.exp((0.25 * (n * n))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) t_1 = Float64(cos(M) / exp(Float64(Float64(l - t_0) + Float64(M * M)))) t_2 = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(m * m))))) tmp = 0.0 if (n <= -1.02e-179) tmp = t_2; elseif (n <= -3.1e-257) tmp = t_1; elseif (n <= 1.15e-126) tmp = t_2; elseif (n <= 52.0) tmp = t_1; else tmp = Float64(cos(M) / exp(Float64(0.25 * Float64(n * n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); t_1 = cos(M) / exp(((l - t_0) + (M * M))); t_2 = exp((t_0 - (l + (0.25 * (m * m))))); tmp = 0.0; if (n <= -1.02e-179) tmp = t_2; elseif (n <= -3.1e-257) tmp = t_1; elseif (n <= 1.15e-126) tmp = t_2; elseif (n <= 52.0) tmp = t_1; else tmp = cos(M) / exp((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]}, Block[{t$95$1 = N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(N[(l - t$95$0), $MachinePrecision] + N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -1.02e-179], t$95$2, If[LessEqual[n, -3.1e-257], t$95$1, If[LessEqual[n, 1.15e-126], t$95$2, If[LessEqual[n, 52.0], t$95$1, N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
t_1 := \frac{\cos M}{e^{\left(\ell - t_0\right) + M \cdot M}}\\
t_2 := e^{t_0 - \left(\ell + 0.25 \cdot \left(m \cdot m\right)\right)}\\
\mathbf{if}\;n \leq -1.02 \cdot 10^{-179}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;n \leq -3.1 \cdot 10^{-257}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;n \leq 1.15 \cdot 10^{-126}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;n \leq 52:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
\end{array}
\end{array}
if n < -1.02e-179 or -3.10000000000000008e-257 < n < 1.15000000000000005e-126Initial program 76.6%
Simplified76.6%
Taylor expanded in m around inf 55.5%
*-commutative55.5%
unpow255.5%
Simplified55.5%
Taylor expanded in K around 0 68.0%
cos-neg59.1%
Simplified68.0%
Taylor expanded in M around 0 67.3%
sub-neg67.3%
mul-1-neg67.3%
+-commutative67.3%
mul-1-neg67.3%
sub-neg67.3%
associate-+r-67.3%
*-commutative67.3%
fma-def67.3%
unpow267.3%
rem-log-exp67.3%
rec-exp67.3%
rem-log-exp67.3%
Simplified67.3%
if -1.02e-179 < n < -3.10000000000000008e-257 or 1.15000000000000005e-126 < n < 52Initial program 76.7%
Simplified76.7%
Taylor expanded in M around inf 67.6%
unpow267.6%
Simplified67.6%
Taylor expanded in K around 0 78.5%
cos-neg24.0%
Simplified78.5%
if 52 < n Initial program 68.1%
Simplified68.1%
Taylor expanded in n around inf 58.1%
*-commutative58.1%
unpow258.1%
Simplified58.1%
Taylor expanded in K around 0 82.9%
cos-neg82.9%
Simplified82.9%
Taylor expanded in n around inf 98.6%
unpow298.6%
Simplified98.6%
Final simplification77.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* 0.25 (* m m)))
(t_1 (fabs (- n m)))
(t_2 (- l t_1))
(t_3 (/ (cos M) (exp (+ t_2 (* M M))))))
(if (<= n -1.35e-179)
(exp (- t_1 (+ l t_0)))
(if (<= n -9.5e-257)
t_3
(if (<= n 1.45e-126)
(/ (cos M) (exp (+ t_2 t_0)))
(if (<= n 52.0) t_3 (/ (cos M) (exp (* 0.25 (* n n))))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = 0.25 * (m * m);
double t_1 = fabs((n - m));
double t_2 = l - t_1;
double t_3 = cos(M) / exp((t_2 + (M * M)));
double tmp;
if (n <= -1.35e-179) {
tmp = exp((t_1 - (l + t_0)));
} else if (n <= -9.5e-257) {
tmp = t_3;
} else if (n <= 1.45e-126) {
tmp = cos(M) / exp((t_2 + t_0));
} else if (n <= 52.0) {
tmp = t_3;
} else {
tmp = cos(M) / exp((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) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 0.25d0 * (m * m)
t_1 = abs((n - m))
t_2 = l - t_1
t_3 = cos(m_1) / exp((t_2 + (m_1 * m_1)))
if (n <= (-1.35d-179)) then
tmp = exp((t_1 - (l + t_0)))
else if (n <= (-9.5d-257)) then
tmp = t_3
else if (n <= 1.45d-126) then
tmp = cos(m_1) / exp((t_2 + t_0))
else if (n <= 52.0d0) then
tmp = t_3
else
tmp = cos(m_1) / exp((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 = 0.25 * (m * m);
double t_1 = Math.abs((n - m));
double t_2 = l - t_1;
double t_3 = Math.cos(M) / Math.exp((t_2 + (M * M)));
double tmp;
if (n <= -1.35e-179) {
tmp = Math.exp((t_1 - (l + t_0)));
} else if (n <= -9.5e-257) {
tmp = t_3;
} else if (n <= 1.45e-126) {
tmp = Math.cos(M) / Math.exp((t_2 + t_0));
} else if (n <= 52.0) {
tmp = t_3;
} else {
tmp = Math.cos(M) / Math.exp((0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = 0.25 * (m * m) t_1 = math.fabs((n - m)) t_2 = l - t_1 t_3 = math.cos(M) / math.exp((t_2 + (M * M))) tmp = 0 if n <= -1.35e-179: tmp = math.exp((t_1 - (l + t_0))) elif n <= -9.5e-257: tmp = t_3 elif n <= 1.45e-126: tmp = math.cos(M) / math.exp((t_2 + t_0)) elif n <= 52.0: tmp = t_3 else: tmp = math.cos(M) / math.exp((0.25 * (n * n))) return tmp
function code(K, m, n, M, l) t_0 = Float64(0.25 * Float64(m * m)) t_1 = abs(Float64(n - m)) t_2 = Float64(l - t_1) t_3 = Float64(cos(M) / exp(Float64(t_2 + Float64(M * M)))) tmp = 0.0 if (n <= -1.35e-179) tmp = exp(Float64(t_1 - Float64(l + t_0))); elseif (n <= -9.5e-257) tmp = t_3; elseif (n <= 1.45e-126) tmp = Float64(cos(M) / exp(Float64(t_2 + t_0))); elseif (n <= 52.0) tmp = t_3; else tmp = Float64(cos(M) / exp(Float64(0.25 * Float64(n * n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = 0.25 * (m * m); t_1 = abs((n - m)); t_2 = l - t_1; t_3 = cos(M) / exp((t_2 + (M * M))); tmp = 0.0; if (n <= -1.35e-179) tmp = exp((t_1 - (l + t_0))); elseif (n <= -9.5e-257) tmp = t_3; elseif (n <= 1.45e-126) tmp = cos(M) / exp((t_2 + t_0)); elseif (n <= 52.0) tmp = t_3; else tmp = cos(M) / exp((0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(l - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(t$95$2 + N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -1.35e-179], N[Exp[N[(t$95$1 - N[(l + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, -9.5e-257], t$95$3, If[LessEqual[n, 1.45e-126], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(t$95$2 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 52.0], t$95$3, N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.25 \cdot \left(m \cdot m\right)\\
t_1 := \left|n - m\right|\\
t_2 := \ell - t_1\\
t_3 := \frac{\cos M}{e^{t_2 + M \cdot M}}\\
\mathbf{if}\;n \leq -1.35 \cdot 10^{-179}:\\
\;\;\;\;e^{t_1 - \left(\ell + t_0\right)}\\
\mathbf{elif}\;n \leq -9.5 \cdot 10^{-257}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;n \leq 1.45 \cdot 10^{-126}:\\
\;\;\;\;\frac{\cos M}{e^{t_2 + t_0}}\\
\mathbf{elif}\;n \leq 52:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
\end{array}
\end{array}
if n < -1.34999999999999994e-179Initial program 73.2%
Simplified73.2%
Taylor expanded in m around inf 45.6%
*-commutative45.6%
unpow245.6%
Simplified45.6%
Taylor expanded in K around 0 57.3%
cos-neg70.6%
Simplified57.3%
Taylor expanded in M around 0 56.2%
sub-neg56.2%
mul-1-neg56.2%
+-commutative56.2%
mul-1-neg56.2%
sub-neg56.2%
associate-+r-56.2%
*-commutative56.2%
fma-def56.2%
unpow256.2%
rem-log-exp56.2%
rec-exp56.2%
rem-log-exp56.2%
Simplified56.2%
if -1.34999999999999994e-179 < n < -9.49999999999999941e-257 or 1.44999999999999994e-126 < n < 52Initial program 76.7%
Simplified76.7%
Taylor expanded in M around inf 67.6%
unpow267.6%
Simplified67.6%
Taylor expanded in K around 0 78.5%
cos-neg24.0%
Simplified78.5%
if -9.49999999999999941e-257 < n < 1.44999999999999994e-126Initial program 82.2%
Simplified82.2%
Taylor expanded in m around inf 71.5%
*-commutative71.5%
unpow271.5%
Simplified71.5%
Taylor expanded in K around 0 85.4%
cos-neg40.6%
Simplified85.4%
if 52 < n Initial program 68.1%
Simplified68.1%
Taylor expanded in n around inf 58.1%
*-commutative58.1%
unpow258.1%
Simplified58.1%
Taylor expanded in K around 0 82.9%
cos-neg82.9%
Simplified82.9%
Taylor expanded in n around inf 98.6%
unpow298.6%
Simplified98.6%
Final simplification77.6%
(FPCore (K m n M l) :precision binary64 (if (<= n 0.42) (exp (- (fabs (- n m)) (+ l (* 0.25 (* m m))))) (/ (cos M) (exp (* 0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 0.42) {
tmp = exp((fabs((n - m)) - (l + (0.25 * (m * m)))));
} else {
tmp = cos(M) / exp((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) :: tmp
if (n <= 0.42d0) then
tmp = exp((abs((n - m)) - (l + (0.25d0 * (m * m)))))
else
tmp = cos(m_1) / exp((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 tmp;
if (n <= 0.42) {
tmp = Math.exp((Math.abs((n - m)) - (l + (0.25 * (m * m)))));
} else {
tmp = Math.cos(M) / Math.exp((0.25 * (n * n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 0.42: tmp = math.exp((math.fabs((n - m)) - (l + (0.25 * (m * m))))) else: tmp = math.cos(M) / math.exp((0.25 * (n * n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 0.42) tmp = exp(Float64(abs(Float64(n - m)) - Float64(l + Float64(0.25 * Float64(m * m))))); else tmp = Float64(cos(M) / exp(Float64(0.25 * Float64(n * n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 0.42) tmp = exp((abs((n - m)) - (l + (0.25 * (m * m))))); else tmp = cos(M) / exp((0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 0.42], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 0.42:\\
\;\;\;\;e^{\left|n - m\right| - \left(\ell + 0.25 \cdot \left(m \cdot m\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
\end{array}
\end{array}
if n < 0.419999999999999984Initial program 76.6%
Simplified76.6%
Taylor expanded in m around inf 52.0%
*-commutative52.0%
unpow252.0%
Simplified52.0%
Taylor expanded in K around 0 66.9%
cos-neg51.1%
Simplified66.9%
Taylor expanded in M around 0 66.3%
sub-neg66.3%
mul-1-neg66.3%
+-commutative66.3%
mul-1-neg66.3%
sub-neg66.3%
associate-+r-66.3%
*-commutative66.3%
fma-def66.3%
unpow266.3%
rem-log-exp66.3%
rec-exp66.3%
rem-log-exp66.3%
Simplified66.3%
if 0.419999999999999984 < n Initial program 68.1%
Simplified68.1%
Taylor expanded in n around inf 58.1%
*-commutative58.1%
unpow258.1%
Simplified58.1%
Taylor expanded in K around 0 82.9%
cos-neg82.9%
Simplified82.9%
Taylor expanded in n around inf 98.6%
unpow298.6%
Simplified98.6%
Final simplification75.0%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -54.0) (not (<= n 0.42))) (/ (cos M) (exp (* 0.25 (* n n)))) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -54.0) || !(n <= 0.42)) {
tmp = cos(M) / exp((0.25 * (n * n)));
} 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 ((n <= (-54.0d0)) .or. (.not. (n <= 0.42d0))) then
tmp = cos(m_1) / exp((0.25d0 * (n * n)))
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 ((n <= -54.0) || !(n <= 0.42)) {
tmp = Math.cos(M) / Math.exp((0.25 * (n * n)));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -54.0) or not (n <= 0.42): tmp = math.cos(M) / math.exp((0.25 * (n * n))) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -54.0) || !(n <= 0.42)) tmp = Float64(cos(M) / exp(Float64(0.25 * Float64(n * n)))); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((n <= -54.0) || ~((n <= 0.42))) tmp = cos(M) / exp((0.25 * (n * n))); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -54.0], N[Not[LessEqual[n, 0.42]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -54 \lor \neg \left(n \leq 0.42\right):\\
\;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if n < -54 or 0.419999999999999984 < n Initial program 67.2%
Simplified67.2%
Taylor expanded in n around inf 57.4%
*-commutative57.4%
unpow257.4%
Simplified57.4%
Taylor expanded in K around 0 81.2%
cos-neg81.2%
Simplified81.2%
Taylor expanded in n around inf 97.0%
unpow297.0%
Simplified97.0%
if -54 < n < 0.419999999999999984Initial program 81.9%
Simplified81.9%
Taylor expanded in n around inf 34.8%
*-commutative34.8%
unpow234.8%
Simplified34.8%
Taylor expanded in K around 0 37.0%
cos-neg37.0%
Simplified37.0%
Taylor expanded in l around inf 42.7%
Final simplification70.5%
(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(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}
\\
\frac{\cos M}{e^{\ell}}
\end{array}
Initial program 74.3%
Simplified74.3%
Taylor expanded in n around inf 46.4%
*-commutative46.4%
unpow246.4%
Simplified46.4%
Taylor expanded in K around 0 59.6%
cos-neg59.6%
Simplified59.6%
Taylor expanded in l around inf 38.6%
Final simplification38.6%
herbie shell --seed 2023182
(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)))))))