Average Error: 22.0 → 0.1
Time: 1.1m
Precision: 64
Internal Precision: 1152
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
↓
\[\begin{array}{l}
\mathbf{if}\;y \le -28.696850627339362:\\
\;\;\;\;x - \frac{x}{\frac{y}{1.0}}\\
\mathbf{if}\;y \le 12558354769362.566:\\
\;\;\;\;1.0 - \frac{\left(1.0 - x\right) \cdot y}{y \cdot y - 1.0 \cdot 1.0} \cdot \left(y - 1.0\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{\frac{y}{1.0}}\\
\end{array}\]
Target
| Original | 22.0 |
|---|
| Target | 7.7 |
|---|
| 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 < -28.696850627339362 or 12558354769362.566 < y
Initial program 44.4
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
Taylor expanded around inf 29.1
\[\leadsto 1.0 - \color{blue}{\left(\left(1.0 + 1.0 \cdot \frac{x}{y}\right) - x\right)}\]
Applied simplify0
\[\leadsto \color{blue}{x - \frac{x}{\frac{y}{1.0}}}\]
if -28.696850627339362 < y < 12558354769362.566
Initial program 0.2
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
- Using strategy
rm Applied flip-+0.2
\[\leadsto 1.0 - \frac{\left(1.0 - x\right) \cdot y}{\color{blue}{\frac{y \cdot y - 1.0 \cdot 1.0}{y - 1.0}}}\]
Applied associate-/r/0.2
\[\leadsto 1.0 - \color{blue}{\frac{\left(1.0 - x\right) \cdot y}{y \cdot y - 1.0 \cdot 1.0} \cdot \left(y - 1.0\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 "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))))