Average Error: 1.4 → 0.1
Time: 13.1s
Precision: 64
Internal Precision: 128
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.5967477339310275 \cdot 10^{-31} \lor \neg \left(x \le 9.785142538371274 \cdot 10^{-13}\right):\\ \;\;\;\;\left|\frac{4 + x}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x - (x \cdot z + -4)_*}{y}\right|\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Split input into 2 regimes
  2. if x < -2.5967477339310275e-31 or 9.785142538371274e-13 < x

    1. Initial program 0.2

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied div-inv0.3

      \[\leadsto \left|\color{blue}{\left(x + 4\right) \cdot \frac{1}{y}} - \frac{x}{y} \cdot z\right|\]
    4. Using strategy rm
    5. Applied prod-diff0.3

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

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

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

    if -2.5967477339310275e-31 < x < 9.785142538371274e-13

    1. Initial program 2.4

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied div-inv2.4

      \[\leadsto \left|\color{blue}{\left(x + 4\right) \cdot \frac{1}{y}} - \frac{x}{y} \cdot z\right|\]
    4. Using strategy rm
    5. Applied associate-*l/0.1

      \[\leadsto \left|\left(x + 4\right) \cdot \frac{1}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    6. Applied associate-*r/0.1

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

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

      \[\leadsto \left|\frac{\color{blue}{x - (x \cdot z + -4)_*}}{y}\right|\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.5967477339310275 \cdot 10^{-31} \lor \neg \left(x \le 9.785142538371274 \cdot 10^{-13}\right):\\ \;\;\;\;\left|\frac{4 + x}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x - (x \cdot z + -4)_*}{y}\right|\\ \end{array}\]

Reproduce

herbie shell --seed 2019030 +o rules:numerics
(FPCore (x y z)
  :name "fabs fraction 1"
  (fabs (- (/ (+ x 4) y) (* (/ x y) z))))