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

    1. Initial program 7.2

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

      \[\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: 27.4s)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit
(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))