| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 7044 |
\[\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot \frac{\frac{a}{k}}{k}\\
\end{array}
\]
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* a (pow k m))) (t_1 (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k)))))
(if (<= t_1 -4e-320)
(* a (/ (pow k m) (fma k (+ k 10.0) 1.0)))
(if (<= t_1 0.0) (/ 1.0 (* k (/ k t_0))) t_1))))double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double t_1 = t_0 / ((1.0 + (k * 10.0)) + (k * k));
double tmp;
if (t_1 <= -4e-320) {
tmp = a * (pow(k, m) / fma(k, (k + 10.0), 1.0));
} else if (t_1 <= 0.0) {
tmp = 1.0 / (k * (k / t_0));
} else {
tmp = t_1;
}
return tmp;
}
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function code(a, k, m) t_0 = Float64(a * (k ^ m)) t_1 = Float64(t_0 / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))) tmp = 0.0 if (t_1 <= -4e-320) tmp = Float64(a * Float64((k ^ m) / fma(k, Float64(k + 10.0), 1.0))); elseif (t_1 <= 0.0) tmp = Float64(1.0 / Float64(k * Float64(k / t_0))); else tmp = t_1; end return tmp end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-320], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(k * N[(k + 10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(1.0 / N[(k * N[(k / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
t_1 := \frac{t_0}{\left(1 + k \cdot 10\right) + k \cdot k}\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{-320}:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{\mathsf{fma}\left(k, k + 10, 1\right)}\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{1}{k \cdot \frac{k}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) < -3.99996e-320Initial program 0.2
Simplified0.1
if -3.99996e-320 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) < 0.0Initial program 2.9
Simplified2.9
Applied egg-rr2.9
Taylor expanded in k around inf 32.5
Simplified0.2
if 0.0 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) Initial program 0.3
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.8 |
| Cost | 7044 |
| Alternative 2 | |
|---|---|
| Error | 15.6 |
| Cost | 1096 |
| Alternative 3 | |
|---|---|
| Error | 23.2 |
| Cost | 712 |
| Alternative 4 | |
|---|---|
| Error | 46.4 |
| Cost | 64 |

herbie shell --seed 2022291
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))