Average Error: 12.0 → 2.9
Time: 31.5s
Precision: 64
Internal Precision: 384
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -5.751058404072405 \cdot 10^{-38}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{if}\;y \le -4.4149063663654 \cdot 10^{-296}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{1}{y - z}}\\ \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.8
Herbie2.9
\[\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 < -5.751058404072405e-38 or -4.4149063663654e-296 < y

    1. Initial program 13.0

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

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

    if -5.751058404072405e-38 < y < -4.4149063663654e-296

    1. Initial program 7.3

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied div-inv8.4

      \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{1}{y - z}}}\]
    6. Applied associate-/r*7.5

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

Runtime

Time bar (total: 31.5s)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))