Average Error: 22.2 → 0.1
Time: 25.5s
Precision: 64
Internal precision: 128
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;y \le -162969717.01587787:\\
\;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{1.0}{y} \cdot x\\
\mathbf{if}\;y \le 1815642973497.1892:\\
\;\;\;\;1.0 - \frac{y}{1.0 + y} \cdot \left(1.0 - x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{1.0}{y} \cdot x\\
\end{array}\]
Target
| Original | 22.2 |
| Comparison | 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 < -162969717.01587787 or 1815642973497.1892 < y
Initial program 45.6
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
Applied taylor 0.0
\[\leadsto \left(1.0 \cdot \frac{1}{y} + x\right) - 1.0 \cdot \frac{x}{y}\]
Taylor expanded around inf 0.0
\[\leadsto \color{blue}{\left(1.0 \cdot \frac{1}{y} + x\right) - 1.0 \cdot \frac{x}{y}}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\left(x + \frac{1.0}{y}\right) - \frac{1.0}{y} \cdot x}\]
if -162969717.01587787 < y < 1815642973497.1892
Initial program 0.3
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
Applied taylor 0.3
\[\leadsto 1.0 - \frac{1.0 \cdot y - y \cdot x}{y + 1.0}\]
Taylor expanded around 0 0.3
\[\leadsto 1.0 - \frac{\color{blue}{1.0 \cdot y - y \cdot x}}{y + 1.0}\]
Applied simplify 0.3
\[\leadsto \color{blue}{1.0 - \frac{y}{1.0 + y} \cdot \left(1.0 - x\right)}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(2531073256 3463518181 105702198 3258611823 3271702027 1468313738)'
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
: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))))