Average Error: 9.5 → 0.6
Time: 16.8s
Precision: 64
Internal precision: 128
\[\frac{x \cdot \left(\left(y - z\right) + 1.0\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.62875581368641 \cdot 10^{-69}:\\ \;\;\;\;\frac{x}{\frac{z}{\left(y - z\right) + 1.0}}\\ \mathbf{if}\;z \le 5.986002856393549 \cdot 10^{-144}:\\ \;\;\;\;\frac{1}{\frac{z}{x \cdot \left(\left(y - z\right) + 1.0\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{\left(y - z\right) + 1.0}}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original9.5
Comparison0.4
Herbie0.6
\[ \begin{array}{l} \mathbf{if}\;x \lt -2.71483106713436 \cdot 10^{-162}:\\ \;\;\;\;\left(1 + y\right) \cdot \frac{x}{z} - x\\ \mathbf{if}\;x \lt 3.874108816439546 \cdot 10^{-197}:\\ \;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1.0\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + y\right) \cdot \frac{x}{z} - x\\ \end{array} \]

Derivation

  1. Split input into 3 regimes.
  2. if z < -3.62875581368641e-69

    1. Initial program 12.8

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

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

    if -3.62875581368641e-69 < z < 5.986002856393549e-144

    1. Initial program 0.1

      \[\frac{x \cdot \left(\left(y - z\right) + 1.0\right)}{z}\]
    2. Using strategy rm
    3. Applied clear-num 0.3

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

    if 5.986002856393549e-144 < z

    1. Initial program 11.8

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

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

Runtime

Time bar (total: 16.8s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(2291329373 895333375 785996309 1272821181 117580814 530127385)'
(FPCore (x y z)
  :name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"

  :target
  (if (< x -2.71483106713436e-162) (- (* (+ 1 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x)))

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