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}\]

Error

Bits error versus x

Bits error versus y

Target

Original22.2
Comparison0.2
Herbie0.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

  1. Split input into 2 regimes.
  2. if y < -162969717.01587787 or 1815642973497.1892 < y

    1. Initial program 45.6

      \[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
    2. Applied taylor 0.0

      \[\leadsto \left(1.0 \cdot \frac{1}{y} + x\right) - 1.0 \cdot \frac{x}{y}\]
    3. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{\left(1.0 \cdot \frac{1}{y} + x\right) - 1.0 \cdot \frac{x}{y}}\]
    4. 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

    1. Initial program 0.3

      \[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
    2. Applied taylor 0.3

      \[\leadsto 1.0 - \frac{1.0 \cdot y - y \cdot x}{y + 1.0}\]
    3. Taylor expanded around 0 0.3

      \[\leadsto 1.0 - \frac{\color{blue}{1.0 \cdot y - y \cdot x}}{y + 1.0}\]
    4. Applied simplify 0.3

      \[\leadsto \color{blue}{1.0 - \frac{y}{1.0 + y} \cdot \left(1.0 - x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 25.5s) Debug log

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))))