Average Error: 21.9 → 0.1
Time: 1.7m
Precision: 64
Internal Precision: 1408
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \le -105446982.68410039:\\
\;\;\;\;x - \frac{1.0 - x}{\frac{y}{\frac{1.0}{y} - 1.0}}\\
\mathbf{if}\;y \le 232001311.40530783:\\
\;\;\;\;1.0 - \frac{y}{y + 1.0} \cdot \left(1.0 - x\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{1.0 - x}{\frac{y}{\frac{1.0}{y} - 1.0}}\\
\end{array}\]
Target
| Original | 21.9 |
|---|
| Target | 0.2 |
|---|
| Herbie | 0.1 |
|---|
\[\begin{array}{l}
\mathbf{if}\;y \lt -3693.8482788297247:\\
\;\;\;\;\frac{1.0}{y} - \left(\frac{x}{y} - x\right)\\
\mathbf{if}\;y \lt 6799310503.41891:\\
\;\;\;\;1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1.0}{y} - \left(\frac{x}{y} - x\right)\\
\end{array}\]
Derivation
- Split input into 2 regimes
if y < -105446982.68410039 or 232001311.40530783 < y
Initial program 44.7
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
Taylor expanded around 0 44.7
\[\leadsto 1.0 - \frac{\color{blue}{1.0 \cdot y - y \cdot x}}{y + 1.0}\]
Applied simplify29.4
\[\leadsto \color{blue}{1.0 - \frac{y}{y + 1.0} \cdot \left(1.0 - x\right)}\]
Taylor expanded around inf 29.4
\[\leadsto 1.0 - \color{blue}{\left(\left(1 + 1.0 \cdot \frac{1}{{y}^{2}}\right) - 1.0 \cdot \frac{1}{y}\right)} \cdot \left(1.0 - x\right)\]
Applied simplify15.3
\[\leadsto \color{blue}{\left(1.0 - \left(1.0 - x\right)\right) - \frac{1.0 - x}{\frac{y}{\frac{1.0}{y} - 1.0}}}\]
Applied simplify0.0
\[\leadsto \color{blue}{x} - \frac{1.0 - x}{\frac{y}{\frac{1.0}{y} - 1.0}}\]
if -105446982.68410039 < y < 232001311.40530783
Initial program 0.1
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
Taylor expanded around 0 0.1
\[\leadsto 1.0 - \frac{\color{blue}{1.0 \cdot y - y \cdot x}}{y + 1.0}\]
Applied simplify0.1
\[\leadsto \color{blue}{1.0 - \frac{y}{y + 1.0} \cdot \left(1.0 - x\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 +o reduce:binary-search
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:herbie-target
(if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))