Average Error: 12.0 → 3.0
Time: 47.7s
Precision: 64
Internal Precision: 384
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.3284959430696045 \cdot 10^{-37}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{if}\;y \le -7.040330047750738 \cdot 10^{-296}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original12.0
Target2.7
Herbie3.0
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{if}\;z \lt 1.6939766013828526 \cdot 10^{+213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.3284959430696045e-37 or -7.040330047750738e-296 < y

    1. Initial program 13.0

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied associate-/l*2.0

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]

    if -1.3284959430696045e-37 < y < -7.040330047750738e-296

    1. Initial program 7.1

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Taylor expanded around 0 7.1

      \[\leadsto \frac{\color{blue}{y \cdot x - z \cdot x}}{y}\]
    3. Applied simplify7.7

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

Runtime

Time bar (total: 47.7s)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

  (/ (* x (- y z)) y))