Average Error: 1.5 → 0.5
Time: 26.7s
Precision: 64
Internal Precision: 576
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.541710155343367 \cdot 10^{-27} \lor \neg \left(x \le 4.5340664755752406 \cdot 10^{-173}\right):\\ \;\;\;\;\left|(\left(\frac{x}{y}\right) \cdot \left(-z\right) + \left(\frac{x}{y} + \frac{4}{y}\right))_*\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{z \cdot x}{y}\right|\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

  1. Inputs

  2. Original Output:

    Herbie Output:

Derivation

  1. Split input into 2 regimes
  2. if x < -4.541710155343367e-27 or 4.5340664755752406e-173 < x

    1. Initial program 0.8

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Taylor expanded around 0 5.8

      \[\leadsto \left|\color{blue}{\left(4 \cdot \frac{1}{y} + \frac{x}{y}\right) - \frac{z \cdot x}{y}}\right|\]
    3. Applied simplify0.8

      \[\leadsto \color{blue}{\left|(\left(\frac{x}{y}\right) \cdot \left(-z\right) + \left(\frac{4}{y} + \frac{x}{y}\right))_*\right|}\]

    if -4.541710155343367e-27 < x < 4.5340664755752406e-173

    1. Initial program 2.6

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied associate-*l/0.0

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify0.5

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;x \le -4.541710155343367 \cdot 10^{-27} \lor \neg \left(x \le 4.5340664755752406 \cdot 10^{-173}\right):\\ \;\;\;\;\left|(\left(\frac{x}{y}\right) \cdot \left(-z\right) + \left(\frac{x}{y} + \frac{4}{y}\right))_*\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{z \cdot x}{y}\right|\\ \end{array}}\]

Runtime

Time bar (total: 26.7s)Debug logProfile

herbie shell --seed '#(1072361757 3390613284 2339397988 1175251238 145061547 3101881848)' +o rules:numerics
(FPCore (x y z)
  :name "fabs fraction 1"
  (fabs (- (/ (+ x 4) y) (* (/ x y) z))))