Average Error: 25.9 → 7.9
Time: 1.0m
Precision: 64
Internal Precision: 1408
\[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1.0 - y} \le 0.9996997279733931:\\
\;\;\;\;\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)\\
\mathbf{else}:\\
\;\;\;\;1.0 - \log \left(\frac{x \cdot 1.0}{y \cdot y} + \left(\frac{x}{y} - \frac{1.0}{y}\right)\right)\\
\end{array}\]
Target
| Original | 25.9 |
|---|
| Target | 10.8 |
|---|
| Herbie | 7.9 |
|---|
\[\begin{array}{l}
\mathbf{if}\;y \lt -81284752.61947241:\\
\;\;\;\;1.0 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1.0}{y} - \frac{x}{y}\right)\right)\\
\mathbf{if}\;y \lt 3.0094271212461764 \cdot 10^{+25}:\\
\;\;\;\;\log \left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)\\
\mathbf{else}:\\
\;\;\;\;1.0 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1.0}{y} - \frac{x}{y}\right)\right)\\
\end{array}\]
Derivation
- Split input into 2 regimes
if (/ (- x y) (- 1.0 y)) < 0.9996997279733931
Initial program 0.0
\[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
- Using strategy
rm Applied add-log-exp0.0
\[\leadsto \color{blue}{\log \left(e^{1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)}\right)}\]
Applied simplify0.0
\[\leadsto \log \color{blue}{\left(\frac{e^{1.0}}{1.0 - \frac{x - y}{1.0 - y}}\right)}\]
if 0.9996997279733931 < (/ (- x y) (- 1.0 y))
Initial program 61.7
\[1.0 - \log \left(1.0 - \frac{x - y}{1.0 - y}\right)\]
Taylor expanded around inf 18.8
\[\leadsto 1.0 - \log \color{blue}{\left(\left(1.0 \cdot \frac{x}{{y}^{2}} + \frac{x}{y}\right) - 1.0 \cdot \frac{1}{y}\right)}\]
Applied simplify18.8
\[\leadsto \color{blue}{1.0 - \log \left(\frac{x \cdot 1.0}{y \cdot y} + \left(\frac{x}{y} - \frac{1.0}{y}\right)\right)}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
:herbie-target
(if (< y -81284752.61947241) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y))))) (if (< y 3.0094271212461764e+25) (log (/ (exp 1.0) (- 1.0 (/ (- x y) (- 1.0 y))))) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y)))))))
(- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))