
(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)) 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((m - n)) - 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((m - n)) - 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((m - n)) - 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((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - 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((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 78.3%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (pow (exp m) (* m -0.25))) (t_1 (* (cos M) (exp (* M (- M))))))
(if (<= M -7.4e-32)
t_1
(if (<= M 1.85e-196)
t_0
(if (<= M 2.4e-98) (exp (- l)) (if (<= M 3e-9) t_0 t_1))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = pow(exp(m), (m * -0.25));
double t_1 = cos(M) * exp((M * -M));
double tmp;
if (M <= -7.4e-32) {
tmp = t_1;
} else if (M <= 1.85e-196) {
tmp = t_0;
} else if (M <= 2.4e-98) {
tmp = exp(-l);
} else if (M <= 3e-9) {
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 = exp(m) ** (m * (-0.25d0))
t_1 = cos(m_1) * exp((m_1 * -m_1))
if (m_1 <= (-7.4d-32)) then
tmp = t_1
else if (m_1 <= 1.85d-196) then
tmp = t_0
else if (m_1 <= 2.4d-98) then
tmp = exp(-l)
else if (m_1 <= 3d-9) 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.pow(Math.exp(m), (m * -0.25));
double t_1 = Math.cos(M) * Math.exp((M * -M));
double tmp;
if (M <= -7.4e-32) {
tmp = t_1;
} else if (M <= 1.85e-196) {
tmp = t_0;
} else if (M <= 2.4e-98) {
tmp = Math.exp(-l);
} else if (M <= 3e-9) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.pow(math.exp(m), (m * -0.25)) t_1 = math.cos(M) * math.exp((M * -M)) tmp = 0 if M <= -7.4e-32: tmp = t_1 elif M <= 1.85e-196: tmp = t_0 elif M <= 2.4e-98: tmp = math.exp(-l) elif M <= 3e-9: tmp = t_0 else: tmp = t_1 return tmp
function code(K, m, n, M, l) t_0 = exp(m) ^ Float64(m * -0.25) t_1 = Float64(cos(M) * exp(Float64(M * Float64(-M)))) tmp = 0.0 if (M <= -7.4e-32) tmp = t_1; elseif (M <= 1.85e-196) tmp = t_0; elseif (M <= 2.4e-98) tmp = exp(Float64(-l)); elseif (M <= 3e-9) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(m) ^ (m * -0.25); t_1 = cos(M) * exp((M * -M)); tmp = 0.0; if (M <= -7.4e-32) tmp = t_1; elseif (M <= 1.85e-196) tmp = t_0; elseif (M <= 2.4e-98) tmp = exp(-l); elseif (M <= 3e-9) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Power[N[Exp[m], $MachinePrecision], N[(m * -0.25), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -7.4e-32], t$95$1, If[LessEqual[M, 1.85e-196], t$95$0, If[LessEqual[M, 2.4e-98], N[Exp[(-l)], $MachinePrecision], If[LessEqual[M, 3e-9], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(e^{m}\right)}^{\left(m \cdot -0.25\right)}\\
t_1 := \cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -7.4 \cdot 10^{-32}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;M \leq 1.85 \cdot 10^{-196}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;M \leq 2.4 \cdot 10^{-98}:\\
\;\;\;\;e^{-\ell}\\
\mathbf{elif}\;M \leq 3 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if M < -7.4e-32 or 2.99999999999999998e-9 < M Initial program 76.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 94.1%
mul-1-neg94.1%
unpow294.1%
distribute-rgt-neg-in94.1%
Simplified94.1%
if -7.4e-32 < M < 1.85000000000000005e-196 or 2.40000000000000005e-98 < M < 2.99999999999999998e-9Initial program 78.9%
Taylor expanded in m around inf 46.3%
*-commutative46.3%
unpow246.3%
Simplified46.3%
Taylor expanded in K around 0 55.6%
cos-neg55.6%
*-commutative55.6%
unpow255.6%
Simplified55.6%
Taylor expanded in M around 0 55.6%
*-commutative55.6%
unpow255.6%
associate-*r*55.6%
exp-prod55.6%
Simplified55.6%
if 1.85000000000000005e-196 < M < 2.40000000000000005e-98Initial program 88.2%
Taylor expanded in l around inf 48.1%
mul-1-neg48.1%
Simplified48.1%
Taylor expanded in K around 0 54.1%
cos-neg54.1%
Simplified54.1%
Taylor expanded in M around 0 54.1%
Final simplification75.3%
(FPCore (K m n M l)
:precision binary64
(if (<= m -195.0)
(pow (exp m) (* m -0.25))
(if (<= m -7e-241)
(* (cos M) (exp (* M (- M))))
(* (cos M) (exp (* -0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -195.0) {
tmp = pow(exp(m), (m * -0.25));
} else if (m <= -7e-241) {
tmp = cos(M) * exp((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 (m <= (-195.0d0)) then
tmp = exp(m) ** (m * (-0.25d0))
else if (m <= (-7d-241)) then
tmp = cos(m_1) * exp((m_1 * -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 (m <= -195.0) {
tmp = Math.pow(Math.exp(m), (m * -0.25));
} else if (m <= -7e-241) {
tmp = Math.cos(M) * Math.exp((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 m <= -195.0: tmp = math.pow(math.exp(m), (m * -0.25)) elif m <= -7e-241: tmp = math.cos(M) * math.exp((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 (m <= -195.0) tmp = exp(m) ^ Float64(m * -0.25); elseif (m <= -7e-241) tmp = Float64(cos(M) * exp(Float64(M * Float64(-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 (m <= -195.0) tmp = exp(m) ^ (m * -0.25); elseif (m <= -7e-241) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp((-0.25 * (n * n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -195.0], N[Power[N[Exp[m], $MachinePrecision], N[(m * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -7e-241], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-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}\;m \leq -195:\\
\;\;\;\;{\left(e^{m}\right)}^{\left(m \cdot -0.25\right)}\\
\mathbf{elif}\;m \leq -7 \cdot 10^{-241}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if m < -195Initial program 73.8%
Taylor expanded in m around inf 73.8%
*-commutative73.8%
unpow273.8%
Simplified73.8%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
*-commutative96.8%
unpow296.8%
Simplified96.8%
Taylor expanded in M around 0 96.8%
*-commutative96.8%
unpow296.8%
associate-*r*96.8%
exp-prod96.8%
Simplified96.8%
if -195 < m < -6.9999999999999998e-241Initial program 85.0%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in M around inf 53.4%
mul-1-neg53.4%
unpow253.4%
distribute-rgt-neg-in53.4%
Simplified53.4%
if -6.9999999999999998e-241 < m Initial program 77.8%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in n around inf 51.9%
*-commutative51.9%
unpow251.9%
Simplified51.9%
Final simplification62.9%
(FPCore (K m n M l) :precision binary64 (if (<= l -0.000155) (* (cos M) (exp l)) (if (<= l 720.0) (pow (exp m) (* m -0.25)) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -0.000155) {
tmp = cos(M) * exp(l);
} else if (l <= 720.0) {
tmp = pow(exp(m), (m * -0.25));
} else {
tmp = 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 (l <= (-0.000155d0)) then
tmp = cos(m_1) * exp(l)
else if (l <= 720.0d0) then
tmp = exp(m) ** (m * (-0.25d0))
else
tmp = 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 (l <= -0.000155) {
tmp = Math.cos(M) * Math.exp(l);
} else if (l <= 720.0) {
tmp = Math.pow(Math.exp(m), (m * -0.25));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -0.000155: tmp = math.cos(M) * math.exp(l) elif l <= 720.0: tmp = math.pow(math.exp(m), (m * -0.25)) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -0.000155) tmp = Float64(cos(M) * exp(l)); elseif (l <= 720.0) tmp = exp(m) ^ Float64(m * -0.25); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -0.000155) tmp = cos(M) * exp(l); elseif (l <= 720.0) tmp = exp(m) ^ (m * -0.25); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -0.000155], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 720.0], N[Power[N[Exp[m], $MachinePrecision], N[(m * -0.25), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -0.000155:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{elif}\;\ell \leq 720:\\
\;\;\;\;{\left(e^{m}\right)}^{\left(m \cdot -0.25\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < -1.55e-4Initial program 82.1%
Taylor expanded in l around inf 21.9%
mul-1-neg21.9%
Simplified21.9%
Taylor expanded in K around 0 22.1%
cos-neg22.1%
Simplified22.1%
expm1-log1p-u17.3%
expm1-udef17.3%
add-sqr-sqrt17.3%
sqrt-unprod17.3%
sqr-neg17.3%
sqrt-unprod0.0%
add-sqr-sqrt73.6%
Applied egg-rr73.6%
expm1-def73.6%
expm1-log1p73.6%
Simplified73.6%
if -1.55e-4 < l < 720Initial program 75.3%
Taylor expanded in m around inf 44.7%
*-commutative44.7%
unpow244.7%
Simplified44.7%
Taylor expanded in K around 0 58.0%
cos-neg58.0%
*-commutative58.0%
unpow258.0%
Simplified58.0%
Taylor expanded in M around 0 58.0%
*-commutative58.0%
unpow258.0%
associate-*r*58.0%
exp-prod58.0%
Simplified58.0%
if 720 < l Initial program 79.7%
Taylor expanded in l around inf 79.7%
mul-1-neg79.7%
Simplified79.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Final simplification73.4%
(FPCore (K m n M l) :precision binary64 (if (<= l 1.55e-12) (* (cos M) (exp l)) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 1.55e-12) {
tmp = cos(M) * exp(l);
} else {
tmp = 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 (l <= 1.55d-12) then
tmp = cos(m_1) * exp(l)
else
tmp = 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 (l <= 1.55e-12) {
tmp = Math.cos(M) * Math.exp(l);
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 1.55e-12: tmp = math.cos(M) * math.exp(l) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 1.55e-12) tmp = Float64(cos(M) * exp(l)); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 1.55e-12) tmp = cos(M) * exp(l); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 1.55e-12], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.55 \cdot 10^{-12}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < 1.5500000000000001e-12Initial program 77.6%
Taylor expanded in l around inf 14.3%
mul-1-neg14.3%
Simplified14.3%
Taylor expanded in K around 0 14.6%
cos-neg14.6%
Simplified14.6%
expm1-log1p-u12.9%
expm1-udef12.9%
add-sqr-sqrt10.4%
sqrt-unprod12.9%
sqr-neg12.9%
sqrt-unprod2.5%
add-sqr-sqrt33.2%
Applied egg-rr33.2%
expm1-def33.2%
expm1-log1p33.2%
Simplified33.2%
if 1.5500000000000001e-12 < l Initial program 80.0%
Taylor expanded in l around inf 78.6%
mul-1-neg78.6%
Simplified78.6%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in M around 0 98.6%
Final simplification51.1%
(FPCore (K m n M l) :precision binary64 (if (<= l -5e-266) (* (cos M) (exp l)) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -5e-266) {
tmp = cos(M) * exp(l);
} 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 (l <= (-5d-266)) then
tmp = cos(m_1) * exp(l)
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 (l <= -5e-266) {
tmp = Math.cos(M) * Math.exp(l);
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -5e-266: tmp = math.cos(M) * math.exp(l) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -5e-266) tmp = Float64(cos(M) * exp(l)); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -5e-266) tmp = cos(M) * exp(l); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -5e-266], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{-266}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if l < -4.99999999999999992e-266Initial program 78.3%
Taylor expanded in l around inf 17.6%
mul-1-neg17.6%
Simplified17.6%
Taylor expanded in K around 0 17.9%
cos-neg17.9%
Simplified17.9%
expm1-log1p-u15.2%
expm1-udef15.2%
add-sqr-sqrt15.2%
sqrt-unprod15.2%
sqr-neg15.2%
sqrt-unprod0.0%
add-sqr-sqrt46.9%
Applied egg-rr46.9%
expm1-def46.9%
expm1-log1p46.9%
Simplified46.9%
if -4.99999999999999992e-266 < l Initial program 78.2%
Taylor expanded in l around inf 44.3%
mul-1-neg44.3%
Simplified44.3%
Taylor expanded in K around 0 54.7%
cos-neg54.7%
Simplified54.7%
Taylor expanded in l around -inf 54.7%
neg-mul-154.7%
exp-neg54.7%
associate-*r/54.7%
*-rgt-identity54.7%
Simplified54.7%
Final simplification51.1%
(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 78.3%
Taylor expanded in l around inf 31.9%
mul-1-neg31.9%
Simplified31.9%
Taylor expanded in K around 0 37.6%
cos-neg37.6%
Simplified37.6%
Taylor expanded in M around 0 36.4%
Final simplification36.4%
herbie shell --seed 2023291
(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)))))))