
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- n m)) l) (pow (- (* (+ n m) 0.5) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((n - m)) - l) - pow((((n + m) * 0.5) - 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) - ((((n + m) * 0.5d0) - 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((((n + m) * 0.5) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((n - m)) - l) - math.pow((((n + m) * 0.5) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(n + m) * 0.5) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((n - m)) - l) - ((((n + m) * 0.5) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(n + m), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\left(n + m\right) \cdot 0.5 - M\right)}^{2}}
\end{array}
Initial program 75.3%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
sub-neg97.5%
sub-neg97.5%
associate--r+97.5%
*-commutative97.5%
fma-neg97.5%
unpow297.5%
cancel-sign-sub-inv97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (K m n M l)
:precision binary64
(if (<= n -2.55e-163)
(* (cos M) (exp (* (* m m) -0.25)))
(if (<= n 54.0)
(* (exp (- (fabs (- n m)) (+ l (* M M)))) (cos (- (* n (* 0.5 K)) M)))
(* (cos M) (exp (* -0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -2.55e-163) {
tmp = cos(M) * exp(((m * m) * -0.25));
} else if (n <= 54.0) {
tmp = exp((fabs((n - m)) - (l + (M * M)))) * cos(((n * (0.5 * K)) - 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 <= (-2.55d-163)) then
tmp = cos(m_1) * exp(((m * m) * (-0.25d0)))
else if (n <= 54.0d0) then
tmp = exp((abs((n - m)) - (l + (m_1 * m_1)))) * cos(((n * (0.5d0 * k)) - m_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 tmp;
if (n <= -2.55e-163) {
tmp = Math.cos(M) * Math.exp(((m * m) * -0.25));
} else if (n <= 54.0) {
tmp = Math.exp((Math.abs((n - m)) - (l + (M * M)))) * Math.cos(((n * (0.5 * K)) - 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 <= -2.55e-163: tmp = math.cos(M) * math.exp(((m * m) * -0.25)) elif n <= 54.0: tmp = math.exp((math.fabs((n - m)) - (l + (M * M)))) * math.cos(((n * (0.5 * K)) - 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 <= -2.55e-163) tmp = Float64(cos(M) * exp(Float64(Float64(m * m) * -0.25))); elseif (n <= 54.0) tmp = Float64(exp(Float64(abs(Float64(n - m)) - Float64(l + Float64(M * M)))) * cos(Float64(Float64(n * Float64(0.5 * K)) - 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 <= -2.55e-163) tmp = cos(M) * exp(((m * m) * -0.25)); elseif (n <= 54.0) tmp = exp((abs((n - m)) - (l + (M * M)))) * cos(((n * (0.5 * K)) - M)); else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, -2.55e-163], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[(N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(M * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(n * N[(0.5 * K), $MachinePrecision]), $MachinePrecision] - M), $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 -2.55 \cdot 10^{-163}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;n \leq 54:\\
\;\;\;\;e^{\left|n - m\right| - \left(\ell + M \cdot M\right)} \cdot \cos \left(n \cdot \left(0.5 \cdot K\right) - M\right)\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < -2.54999999999999995e-163Initial program 72.3%
Taylor expanded in K around 0 98.9%
cos-neg98.9%
sub-neg98.9%
sub-neg98.9%
associate--r+98.9%
*-commutative98.9%
fma-neg98.9%
unpow298.9%
cancel-sign-sub-inv98.9%
Simplified98.9%
Taylor expanded in m around inf 54.9%
*-commutative54.9%
unpow254.9%
Simplified54.9%
if -2.54999999999999995e-163 < n < 54Initial program 82.9%
+-commutative82.9%
+-commutative82.9%
fabs-sub82.9%
associate-/l*82.1%
+-commutative82.1%
Simplified82.1%
Taylor expanded in M around inf 71.9%
unpow271.9%
Simplified71.9%
Taylor expanded in m around 0 79.1%
*-commutative79.1%
Simplified79.1%
if 54 < n Initial program 68.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
sub-neg100.0%
sub-neg100.0%
associate--r+100.0%
*-commutative100.0%
fma-neg100.0%
unpow2100.0%
cancel-sign-sub-inv100.0%
Simplified100.0%
Taylor expanded in n around inf 97.3%
*-commutative97.3%
unpow297.3%
Simplified97.3%
Final simplification76.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (* (* m m) -0.25))))
(t_1 (* (cos M) (exp (- (* M M))))))
(if (<= M -8.2e-5)
t_1
(if (<= M -4.9e-183)
t_0
(if (<= M 7.2e-248)
(* (* (* M M) -0.5) (exp (- l)))
(if (<= M 27.0) t_0 t_1))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp(((m * m) * -0.25));
double t_1 = cos(M) * exp(-(M * M));
double tmp;
if (M <= -8.2e-5) {
tmp = t_1;
} else if (M <= -4.9e-183) {
tmp = t_0;
} else if (M <= 7.2e-248) {
tmp = ((M * M) * -0.5) * exp(-l);
} else if (M <= 27.0) {
tmp = t_0;
} else {
tmp = 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 = cos(m_1) * exp(((m * m) * (-0.25d0)))
t_1 = cos(m_1) * exp(-(m_1 * m_1))
if (m_1 <= (-8.2d-5)) then
tmp = t_1
else if (m_1 <= (-4.9d-183)) then
tmp = t_0
else if (m_1 <= 7.2d-248) then
tmp = ((m_1 * m_1) * (-0.5d0)) * exp(-l)
else if (m_1 <= 27.0d0) then
tmp = t_0
else
tmp = 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.cos(M) * Math.exp(((m * m) * -0.25));
double t_1 = Math.cos(M) * Math.exp(-(M * M));
double tmp;
if (M <= -8.2e-5) {
tmp = t_1;
} else if (M <= -4.9e-183) {
tmp = t_0;
} else if (M <= 7.2e-248) {
tmp = ((M * M) * -0.5) * Math.exp(-l);
} else if (M <= 27.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(M) * math.exp(((m * m) * -0.25)) t_1 = math.cos(M) * math.exp(-(M * M)) tmp = 0 if M <= -8.2e-5: tmp = t_1 elif M <= -4.9e-183: tmp = t_0 elif M <= 7.2e-248: tmp = ((M * M) * -0.5) * math.exp(-l) elif M <= 27.0: tmp = t_0 else: tmp = t_1 return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(M) * exp(Float64(Float64(m * m) * -0.25))) t_1 = Float64(cos(M) * exp(Float64(-Float64(M * M)))) tmp = 0.0 if (M <= -8.2e-5) tmp = t_1; elseif (M <= -4.9e-183) tmp = t_0; elseif (M <= 7.2e-248) tmp = Float64(Float64(Float64(M * M) * -0.5) * exp(Float64(-l))); elseif (M <= 27.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) * exp(((m * m) * -0.25)); t_1 = cos(M) * exp(-(M * M)); tmp = 0.0; if (M <= -8.2e-5) tmp = t_1; elseif (M <= -4.9e-183) tmp = t_0; elseif (M <= 7.2e-248) tmp = ((M * M) * -0.5) * exp(-l); elseif (M <= 27.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[(M * M), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -8.2e-5], t$95$1, If[LessEqual[M, -4.9e-183], t$95$0, If[LessEqual[M, 7.2e-248], N[(N[(N[(M * M), $MachinePrecision] * -0.5), $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 27.0], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\
t_1 := \cos M \cdot e^{-M \cdot M}\\
\mathbf{if}\;M \leq -8.2 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;M \leq -4.9 \cdot 10^{-183}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;M \leq 7.2 \cdot 10^{-248}:\\
\;\;\;\;\left(\left(M \cdot M\right) \cdot -0.5\right) \cdot e^{-\ell}\\
\mathbf{elif}\;M \leq 27:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if M < -8.20000000000000009e-5 or 27 < M Initial program 81.4%
Taylor expanded in K around 0 99.3%
cos-neg99.3%
sub-neg99.3%
sub-neg99.3%
associate--r+99.3%
*-commutative99.3%
fma-neg99.3%
unpow299.3%
cancel-sign-sub-inv99.3%
Simplified99.3%
Taylor expanded in M around inf 97.9%
mul-1-neg97.9%
unpow297.9%
distribute-rgt-neg-out97.9%
Simplified97.9%
if -8.20000000000000009e-5 < M < -4.9e-183 or 7.19999999999999969e-248 < M < 27Initial program 65.2%
Taylor expanded in K around 0 97.8%
cos-neg97.8%
sub-neg97.8%
sub-neg97.8%
associate--r+97.8%
*-commutative97.8%
fma-neg97.8%
unpow297.8%
cancel-sign-sub-inv97.8%
Simplified97.8%
Taylor expanded in m around inf 62.4%
*-commutative62.4%
unpow262.4%
Simplified62.4%
if -4.9e-183 < M < 7.19999999999999969e-248Initial program 72.3%
Taylor expanded in K around 0 91.2%
cos-neg91.2%
sub-neg91.2%
sub-neg91.2%
associate--r+91.2%
*-commutative91.2%
fma-neg91.2%
unpow291.2%
cancel-sign-sub-inv91.2%
Simplified91.2%
Taylor expanded in l around inf 42.8%
mul-1-neg42.8%
Simplified42.8%
Taylor expanded in M around 0 33.2%
associate-*r*33.2%
distribute-rgt1-in42.8%
unpow242.8%
Simplified42.8%
Taylor expanded in M around inf 78.8%
associate-*r*78.8%
unpow278.8%
Simplified78.8%
Final simplification84.5%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- l)))
(t_1 (* (* M M) -0.5))
(t_2 (* (cos M) (exp (- (* M M))))))
(if (<= M -4.45e-45)
t_2
(if (<= M -8.2e-169)
(* t_0 (+ t_1 1.0))
(if (<= M 1.65e-75) (* t_1 t_0) (if (<= M 26.0) t_0 t_2))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-l);
double t_1 = (M * M) * -0.5;
double t_2 = cos(M) * exp(-(M * M));
double tmp;
if (M <= -4.45e-45) {
tmp = t_2;
} else if (M <= -8.2e-169) {
tmp = t_0 * (t_1 + 1.0);
} else if (M <= 1.65e-75) {
tmp = t_1 * t_0;
} else if (M <= 26.0) {
tmp = t_0;
} else {
tmp = t_2;
}
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 = exp(-l)
t_1 = (m_1 * m_1) * (-0.5d0)
t_2 = cos(m_1) * exp(-(m_1 * m_1))
if (m_1 <= (-4.45d-45)) then
tmp = t_2
else if (m_1 <= (-8.2d-169)) then
tmp = t_0 * (t_1 + 1.0d0)
else if (m_1 <= 1.65d-75) then
tmp = t_1 * t_0
else if (m_1 <= 26.0d0) then
tmp = t_0
else
tmp = t_2
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp(-l);
double t_1 = (M * M) * -0.5;
double t_2 = Math.cos(M) * Math.exp(-(M * M));
double tmp;
if (M <= -4.45e-45) {
tmp = t_2;
} else if (M <= -8.2e-169) {
tmp = t_0 * (t_1 + 1.0);
} else if (M <= 1.65e-75) {
tmp = t_1 * t_0;
} else if (M <= 26.0) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-l) t_1 = (M * M) * -0.5 t_2 = math.cos(M) * math.exp(-(M * M)) tmp = 0 if M <= -4.45e-45: tmp = t_2 elif M <= -8.2e-169: tmp = t_0 * (t_1 + 1.0) elif M <= 1.65e-75: tmp = t_1 * t_0 elif M <= 26.0: tmp = t_0 else: tmp = t_2 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-l)) t_1 = Float64(Float64(M * M) * -0.5) t_2 = Float64(cos(M) * exp(Float64(-Float64(M * M)))) tmp = 0.0 if (M <= -4.45e-45) tmp = t_2; elseif (M <= -8.2e-169) tmp = Float64(t_0 * Float64(t_1 + 1.0)); elseif (M <= 1.65e-75) tmp = Float64(t_1 * t_0); elseif (M <= 26.0) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-l); t_1 = (M * M) * -0.5; t_2 = cos(M) * exp(-(M * M)); tmp = 0.0; if (M <= -4.45e-45) tmp = t_2; elseif (M <= -8.2e-169) tmp = t_0 * (t_1 + 1.0); elseif (M <= 1.65e-75) tmp = t_1 * t_0; elseif (M <= 26.0) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, Block[{t$95$1 = N[(N[(M * M), $MachinePrecision] * -0.5), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[(M * M), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -4.45e-45], t$95$2, If[LessEqual[M, -8.2e-169], N[(t$95$0 * N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 1.65e-75], N[(t$95$1 * t$95$0), $MachinePrecision], If[LessEqual[M, 26.0], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
t_1 := \left(M \cdot M\right) \cdot -0.5\\
t_2 := \cos M \cdot e^{-M \cdot M}\\
\mathbf{if}\;M \leq -4.45 \cdot 10^{-45}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;M \leq -8.2 \cdot 10^{-169}:\\
\;\;\;\;t_0 \cdot \left(t_1 + 1\right)\\
\mathbf{elif}\;M \leq 1.65 \cdot 10^{-75}:\\
\;\;\;\;t_1 \cdot t_0\\
\mathbf{elif}\;M \leq 26:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if M < -4.45000000000000017e-45 or 26 < M Initial program 81.9%
Taylor expanded in K around 0 99.3%
cos-neg99.3%
sub-neg99.3%
sub-neg99.3%
associate--r+99.3%
*-commutative99.3%
fma-neg99.3%
unpow299.3%
cancel-sign-sub-inv99.3%
Simplified99.3%
Taylor expanded in M around inf 92.8%
mul-1-neg92.8%
unpow292.8%
distribute-rgt-neg-out92.8%
Simplified92.8%
if -4.45000000000000017e-45 < M < -8.1999999999999996e-169Initial program 66.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
sub-neg100.0%
sub-neg100.0%
associate--r+100.0%
*-commutative100.0%
fma-neg100.0%
unpow2100.0%
cancel-sign-sub-inv100.0%
Simplified100.0%
Taylor expanded in l around inf 56.8%
mul-1-neg56.8%
Simplified56.8%
Taylor expanded in M around 0 34.4%
associate-*r*34.4%
distribute-rgt1-in56.8%
unpow256.8%
Simplified56.8%
if -8.1999999999999996e-169 < M < 1.65e-75Initial program 63.2%
Taylor expanded in K around 0 92.3%
cos-neg92.3%
sub-neg92.3%
sub-neg92.3%
associate--r+92.3%
*-commutative92.3%
fma-neg92.3%
unpow292.3%
cancel-sign-sub-inv92.3%
Simplified92.3%
Taylor expanded in l around inf 34.7%
mul-1-neg34.7%
Simplified34.7%
Taylor expanded in M around 0 28.8%
associate-*r*28.8%
distribute-rgt1-in34.7%
unpow234.7%
Simplified34.7%
Taylor expanded in M around inf 68.9%
associate-*r*68.9%
unpow268.9%
Simplified68.9%
if 1.65e-75 < M < 26Initial program 75.0%
Taylor expanded in K around 0 99.7%
cos-neg99.7%
sub-neg99.7%
sub-neg99.7%
associate--r+99.7%
*-commutative99.7%
fma-neg99.7%
unpow299.7%
cancel-sign-sub-inv99.7%
Simplified99.7%
Taylor expanded in l around inf 46.1%
mul-1-neg46.1%
Simplified46.1%
Taylor expanded in M around 0 46.1%
Final simplification80.2%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- l))))
(if (or (<= l -3.05e-33) (not (<= l 2.25e-64)))
(* (cos M) t_0)
(* (* (* M M) -0.5) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-l);
double tmp;
if ((l <= -3.05e-33) || !(l <= 2.25e-64)) {
tmp = cos(M) * t_0;
} else {
tmp = ((M * M) * -0.5) * t_0;
}
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 = exp(-l)
if ((l <= (-3.05d-33)) .or. (.not. (l <= 2.25d-64))) then
tmp = cos(m_1) * t_0
else
tmp = ((m_1 * m_1) * (-0.5d0)) * t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp(-l);
double tmp;
if ((l <= -3.05e-33) || !(l <= 2.25e-64)) {
tmp = Math.cos(M) * t_0;
} else {
tmp = ((M * M) * -0.5) * t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-l) tmp = 0 if (l <= -3.05e-33) or not (l <= 2.25e-64): tmp = math.cos(M) * t_0 else: tmp = ((M * M) * -0.5) * t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-l)) tmp = 0.0 if ((l <= -3.05e-33) || !(l <= 2.25e-64)) tmp = Float64(cos(M) * t_0); else tmp = Float64(Float64(Float64(M * M) * -0.5) * t_0); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-l); tmp = 0.0; if ((l <= -3.05e-33) || ~((l <= 2.25e-64))) tmp = cos(M) * t_0; else tmp = ((M * M) * -0.5) * t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, If[Or[LessEqual[l, -3.05e-33], N[Not[LessEqual[l, 2.25e-64]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[(M * M), $MachinePrecision] * -0.5), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
\mathbf{if}\;\ell \leq -3.05 \cdot 10^{-33} \lor \neg \left(\ell \leq 2.25 \cdot 10^{-64}\right):\\
\;\;\;\;\cos M \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(M \cdot M\right) \cdot -0.5\right) \cdot t_0\\
\end{array}
\end{array}
if l < -3.0500000000000001e-33 or 2.25000000000000005e-64 < l Initial program 75.6%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
sub-neg98.4%
sub-neg98.4%
associate--r+98.4%
*-commutative98.4%
fma-neg98.4%
unpow298.4%
cancel-sign-sub-inv98.4%
Simplified98.4%
Taylor expanded in l around inf 59.1%
mul-1-neg59.1%
Simplified59.1%
if -3.0500000000000001e-33 < l < 2.25000000000000005e-64Initial program 74.9%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
sub-neg96.7%
sub-neg96.7%
associate--r+96.7%
*-commutative96.7%
fma-neg96.7%
unpow296.7%
cancel-sign-sub-inv96.7%
Simplified96.7%
Taylor expanded in l around inf 6.6%
mul-1-neg6.6%
Simplified6.6%
Taylor expanded in M around 0 5.9%
associate-*r*5.9%
distribute-rgt1-in5.9%
unpow25.9%
Simplified5.9%
Taylor expanded in M around inf 26.0%
associate-*r*26.0%
unpow226.0%
Simplified26.0%
Final simplification42.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- l))))
(if (or (<= l -7.2e-33) (not (<= l 2.45e-64)))
t_0
(* (* (* M M) -0.5) t_0))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-l);
double tmp;
if ((l <= -7.2e-33) || !(l <= 2.45e-64)) {
tmp = t_0;
} else {
tmp = ((M * M) * -0.5) * t_0;
}
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 = exp(-l)
if ((l <= (-7.2d-33)) .or. (.not. (l <= 2.45d-64))) then
tmp = t_0
else
tmp = ((m_1 * m_1) * (-0.5d0)) * t_0
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp(-l);
double tmp;
if ((l <= -7.2e-33) || !(l <= 2.45e-64)) {
tmp = t_0;
} else {
tmp = ((M * M) * -0.5) * t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-l) tmp = 0 if (l <= -7.2e-33) or not (l <= 2.45e-64): tmp = t_0 else: tmp = ((M * M) * -0.5) * t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-l)) tmp = 0.0 if ((l <= -7.2e-33) || !(l <= 2.45e-64)) tmp = t_0; else tmp = Float64(Float64(Float64(M * M) * -0.5) * t_0); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-l); tmp = 0.0; if ((l <= -7.2e-33) || ~((l <= 2.45e-64))) tmp = t_0; else tmp = ((M * M) * -0.5) * t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, If[Or[LessEqual[l, -7.2e-33], N[Not[LessEqual[l, 2.45e-64]], $MachinePrecision]], t$95$0, N[(N[(N[(M * M), $MachinePrecision] * -0.5), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
\mathbf{if}\;\ell \leq -7.2 \cdot 10^{-33} \lor \neg \left(\ell \leq 2.45 \cdot 10^{-64}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(M \cdot M\right) \cdot -0.5\right) \cdot t_0\\
\end{array}
\end{array}
if l < -7.20000000000000068e-33 or 2.4500000000000001e-64 < l Initial program 75.6%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
sub-neg98.4%
sub-neg98.4%
associate--r+98.4%
*-commutative98.4%
fma-neg98.4%
unpow298.4%
cancel-sign-sub-inv98.4%
Simplified98.4%
Taylor expanded in l around inf 59.1%
mul-1-neg59.1%
Simplified59.1%
Taylor expanded in M around 0 59.1%
if -7.20000000000000068e-33 < l < 2.4500000000000001e-64Initial program 74.9%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
sub-neg96.7%
sub-neg96.7%
associate--r+96.7%
*-commutative96.7%
fma-neg96.7%
unpow296.7%
cancel-sign-sub-inv96.7%
Simplified96.7%
Taylor expanded in l around inf 6.6%
mul-1-neg6.6%
Simplified6.6%
Taylor expanded in M around 0 5.9%
associate-*r*5.9%
distribute-rgt1-in5.9%
unpow25.9%
Simplified5.9%
Taylor expanded in M around inf 26.0%
associate-*r*26.0%
unpow226.0%
Simplified26.0%
Final simplification42.4%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return 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 = exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 75.3%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
sub-neg97.5%
sub-neg97.5%
associate--r+97.5%
*-commutative97.5%
fma-neg97.5%
unpow297.5%
cancel-sign-sub-inv97.5%
Simplified97.5%
Taylor expanded in l around inf 32.6%
mul-1-neg32.6%
Simplified32.6%
Taylor expanded in M around 0 32.6%
Final simplification32.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%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
sub-neg97.5%
sub-neg97.5%
associate--r+97.5%
*-commutative97.5%
fma-neg97.5%
unpow297.5%
cancel-sign-sub-inv97.5%
Simplified97.5%
Taylor expanded in l around inf 32.6%
mul-1-neg32.6%
Simplified32.6%
Taylor expanded in l around 0 6.0%
Final simplification6.0%
herbie shell --seed 2023275
(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)))))))