Average Error: 22.1 → 0.1
Time: 1.5m
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:\\ \;\;\;\;\left(\frac{1.0}{y} + x\right) - \frac{x \cdot 1.0}{y}\\ \mathbf{if}\;y \le 92563423223.6119:\\ \;\;\;\;1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1.0}{y} + x\right) - \frac{x \cdot 1.0}{y}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Target

Original22.1
Target0.1
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 < -28.696850627339362 or 92563423223.6119 < y

    1. Initial program 44.7

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

      \[\leadsto \color{blue}{\left(1.0 \cdot \frac{1}{y} + x\right) - 1.0 \cdot \frac{x}{y}}\]
    3. Applied simplify0.0

      \[\leadsto \color{blue}{\left(\frac{1.0}{y} + x\right) - \frac{x \cdot 1.0}{y}}\]

    if -28.696850627339362 < y < 92563423223.6119

    1. Initial program 0.1

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

Runtime

Time bar (total: 1.5m)Debug log

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