| Alternative 1 | |
|---|---|
| Accuracy | 96.6% |
| Cost | 7296 |
\[\frac{a}{\frac{1 + \left(k \cdot 10 + k \cdot k\right)}{{k}^{m}}}
\]
(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 1e+142) (/ a (/ (+ 1.0 (+ (* k 10.0) (* k k))) (pow k m))) (* (/ a k) (/ (pow (- (pow (/ -1.0 k) -1.0)) m) 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 <= 1e+142) {
tmp = a / ((1.0 + ((k * 10.0) + (k * k))) / pow(k, m));
} else {
tmp = (a / k) * (pow(-pow((-1.0 / k), -1.0), m) / 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 <= 1d+142) then
tmp = a / ((1.0d0 + ((k * 10.0d0) + (k * k))) / (k ** m))
else
tmp = (a / k) * ((-(((-1.0d0) / k) ** (-1.0d0)) ** m) / 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 <= 1e+142) {
tmp = a / ((1.0 + ((k * 10.0) + (k * k))) / Math.pow(k, m));
} else {
tmp = (a / k) * (Math.pow(-Math.pow((-1.0 / k), -1.0), m) / 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 <= 1e+142: tmp = a / ((1.0 + ((k * 10.0) + (k * k))) / math.pow(k, m)) else: tmp = (a / k) * (math.pow(-math.pow((-1.0 / k), -1.0), m) / 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 <= 1e+142) tmp = Float64(a / Float64(Float64(1.0 + Float64(Float64(k * 10.0) + Float64(k * k))) / (k ^ m))); else tmp = Float64(Float64(a / k) * Float64((Float64(-(Float64(-1.0 / k) ^ -1.0)) ^ m) / 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 <= 1e+142) tmp = a / ((1.0 + ((k * 10.0) + (k * k))) / (k ^ m)); else tmp = (a / k) * ((-((-1.0 / k) ^ -1.0) ^ m) / 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, 1e+142], N[(a / N[(N[(1.0 + N[(N[(k * 10.0), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[k, m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / k), $MachinePrecision] * N[(N[Power[(-N[Power[N[(-1.0 / k), $MachinePrecision], -1.0], $MachinePrecision]), m], $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]]
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\begin{array}{l}
\mathbf{if}\;k \leq 10^{+142}:\\
\;\;\;\;\frac{a}{\frac{1 + \left(k \cdot 10 + k \cdot k\right)}{{k}^{m}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{k} \cdot \frac{{\left(-{\left(\frac{-1}{k}\right)}^{-1}\right)}^{m}}{k}\\
\end{array}
Results
if k < 1.00000000000000005e142Initial program 99.9%
Simplified99.9%
[Start]99.9 | \[ \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\] |
|---|---|
associate-/l* [=>]99.9 | \[ \color{blue}{\frac{a}{\frac{\left(1 + 10 \cdot k\right) + k \cdot k}{{k}^{m}}}}
\] |
associate-+l+ [=>]99.9 | \[ \frac{a}{\frac{\color{blue}{1 + \left(10 \cdot k + k \cdot k\right)}}{{k}^{m}}}
\] |
*-commutative [=>]99.9 | \[ \frac{a}{\frac{1 + \left(\color{blue}{k \cdot 10} + k \cdot k\right)}{{k}^{m}}}
\] |
if 1.00000000000000005e142 < k Initial program 84.1%
Taylor expanded in k around -inf 0.0%
Simplified99.7%
[Start]0.0 | \[ \frac{a \cdot e^{\left(\log -1 + -1 \cdot \log \left(\frac{-1}{k}\right)\right) \cdot m}}{{k}^{2}}
\] |
|---|---|
unpow2 [=>]0.0 | \[ \frac{a \cdot e^{\left(\log -1 + -1 \cdot \log \left(\frac{-1}{k}\right)\right) \cdot m}}{\color{blue}{k \cdot k}}
\] |
times-frac [=>]0.0 | \[ \color{blue}{\frac{a}{k} \cdot \frac{e^{\left(\log -1 + -1 \cdot \log \left(\frac{-1}{k}\right)\right) \cdot m}}{k}}
\] |
exp-prod [=>]0.0 | \[ \frac{a}{k} \cdot \frac{\color{blue}{{\left(e^{\log -1 + -1 \cdot \log \left(\frac{-1}{k}\right)}\right)}^{m}}}{k}
\] |
exp-sum [=>]0.0 | \[ \frac{a}{k} \cdot \frac{{\color{blue}{\left(e^{\log -1} \cdot e^{-1 \cdot \log \left(\frac{-1}{k}\right)}\right)}}^{m}}{k}
\] |
rem-exp-log [=>]0.0 | \[ \frac{a}{k} \cdot \frac{{\left(\color{blue}{-1} \cdot e^{-1 \cdot \log \left(\frac{-1}{k}\right)}\right)}^{m}}{k}
\] |
*-commutative [=>]0.0 | \[ \frac{a}{k} \cdot \frac{{\left(-1 \cdot e^{\color{blue}{\log \left(\frac{-1}{k}\right) \cdot -1}}\right)}^{m}}{k}
\] |
exp-to-pow [=>]99.7 | \[ \frac{a}{k} \cdot \frac{{\left(-1 \cdot \color{blue}{{\left(\frac{-1}{k}\right)}^{-1}}\right)}^{m}}{k}
\] |
Final simplification99.9%
| Alternative 1 | |
|---|---|
| Accuracy | 96.6% |
| Cost | 7296 |
| Alternative 2 | |
|---|---|
| Accuracy | 95.7% |
| Cost | 7240 |
| Alternative 3 | |
|---|---|
| Accuracy | 95.7% |
| Cost | 7044 |
| Alternative 4 | |
|---|---|
| Accuracy | 95.3% |
| Cost | 6984 |
| Alternative 5 | |
|---|---|
| Accuracy | 95.3% |
| Cost | 6921 |
| Alternative 6 | |
|---|---|
| Accuracy | 68.2% |
| Cost | 841 |
| Alternative 7 | |
|---|---|
| Accuracy | 69.2% |
| Cost | 841 |
| Alternative 8 | |
|---|---|
| Accuracy | 61.6% |
| Cost | 713 |
| Alternative 9 | |
|---|---|
| Accuracy | 61.9% |
| Cost | 712 |
| Alternative 10 | |
|---|---|
| Accuracy | 62.0% |
| Cost | 712 |
| Alternative 11 | |
|---|---|
| Accuracy | 61.4% |
| Cost | 585 |
| Alternative 12 | |
|---|---|
| Accuracy | 61.4% |
| Cost | 448 |
| Alternative 13 | |
|---|---|
| Accuracy | 27.0% |
| Cost | 64 |
herbie shell --seed 2023151
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))