| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 7428 |
\[\begin{array}{l}
\mathbf{if}\;k \leq 10^{+145}:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{\left(1 + k \cdot 10\right) + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{k} \cdot \frac{{k}^{m}}{k + 10}\\
\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 (if (<= k 2e+144) (/ (* a (pow k m)) (+ (+ 1.0 (* k 10.0)) (* k k))) (* (/ (exp (* m (log k))) k) (/ a k))))
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 tmp;
if (k <= 2e+144) {
tmp = (a * pow(k, m)) / ((1.0 + (k * 10.0)) + (k * k));
} else {
tmp = (exp((m * log(k))) / k) * (a / k);
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (k <= 2d+144) then
tmp = (a * (k ** m)) / ((1.0d0 + (k * 10.0d0)) + (k * k))
else
tmp = (exp((m * log(k))) / k) * (a / k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
public static double code(double a, double k, double m) {
double tmp;
if (k <= 2e+144) {
tmp = (a * Math.pow(k, m)) / ((1.0 + (k * 10.0)) + (k * k));
} else {
tmp = (Math.exp((m * Math.log(k))) / k) * (a / k);
}
return tmp;
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
def code(a, k, m): tmp = 0 if k <= 2e+144: tmp = (a * math.pow(k, m)) / ((1.0 + (k * 10.0)) + (k * k)) else: tmp = (math.exp((m * math.log(k))) / k) * (a / k) 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) tmp = 0.0 if (k <= 2e+144) tmp = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))); else tmp = Float64(Float64(exp(Float64(m * log(k))) / k) * Float64(a / k)); end return tmp end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 2e+144) tmp = (a * (k ^ m)) / ((1.0 + (k * 10.0)) + (k * k)); else tmp = (exp((m * log(k))) / k) * (a / k); end tmp_2 = 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_] := If[LessEqual[k, 2e+144], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[N[(m * N[Log[k], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision] * N[(a / k), $MachinePrecision]), $MachinePrecision]]
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\begin{array}{l}
\mathbf{if}\;k \leq 2 \cdot 10^{+144}:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{\left(1 + k \cdot 10\right) + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{m \cdot \log k}}{k} \cdot \frac{a}{k}\\
\end{array}
Results
if k < 2.00000000000000005e144Initial program 0.1
if 2.00000000000000005e144 < k Initial program 8.9
Taylor expanded in k around inf 8.9
Simplified0.1
[Start]8.9 | \[ \frac{a \cdot e^{-1 \cdot \left(\log \left(\frac{1}{k}\right) \cdot m\right)}}{{k}^{2}}
\] |
|---|---|
*-commutative [=>]8.9 | \[ \frac{\color{blue}{e^{-1 \cdot \left(\log \left(\frac{1}{k}\right) \cdot m\right)} \cdot a}}{{k}^{2}}
\] |
unpow2 [=>]8.9 | \[ \frac{e^{-1 \cdot \left(\log \left(\frac{1}{k}\right) \cdot m\right)} \cdot a}{\color{blue}{k \cdot k}}
\] |
times-frac [=>]0.1 | \[ \color{blue}{\frac{e^{-1 \cdot \left(\log \left(\frac{1}{k}\right) \cdot m\right)}}{k} \cdot \frac{a}{k}}
\] |
mul-1-neg [=>]0.1 | \[ \frac{e^{\color{blue}{-\log \left(\frac{1}{k}\right) \cdot m}}}{k} \cdot \frac{a}{k}
\] |
distribute-rgt-neg-in [=>]0.1 | \[ \frac{e^{\color{blue}{\log \left(\frac{1}{k}\right) \cdot \left(-m\right)}}}{k} \cdot \frac{a}{k}
\] |
log-rec [=>]0.1 | \[ \frac{e^{\color{blue}{\left(-\log k\right)} \cdot \left(-m\right)}}{k} \cdot \frac{a}{k}
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 7428 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 7300 |
| Alternative 3 | |
|---|---|
| Error | 2.1 |
| Cost | 7176 |
| Alternative 4 | |
|---|---|
| Error | 1.0 |
| Cost | 7172 |
| Alternative 5 | |
|---|---|
| Error | 0.5 |
| Cost | 7172 |
| Alternative 6 | |
|---|---|
| Error | 1.0 |
| Cost | 7044 |
| Alternative 7 | |
|---|---|
| Error | 4.9 |
| Cost | 6788 |
| Alternative 8 | |
|---|---|
| Error | 16.1 |
| Cost | 1096 |
| Alternative 9 | |
|---|---|
| Error | 21.5 |
| Cost | 844 |
| Alternative 10 | |
|---|---|
| Error | 21.6 |
| Cost | 844 |
| Alternative 11 | |
|---|---|
| Error | 16.1 |
| Cost | 840 |
| Alternative 12 | |
|---|---|
| Error | 22.4 |
| Cost | 716 |
| Alternative 13 | |
|---|---|
| Error | 21.7 |
| Cost | 716 |
| Alternative 14 | |
|---|---|
| Error | 16.7 |
| Cost | 712 |
| Alternative 15 | |
|---|---|
| Error | 20.4 |
| Cost | 580 |
| Alternative 16 | |
|---|---|
| Error | 43.0 |
| Cost | 452 |
| Alternative 17 | |
|---|---|
| Error | 46.7 |
| Cost | 64 |
herbie shell --seed 2022354
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))