Average Error: 1.7 → 0.3
Time: 18.2s
Precision: 64
Internal Precision: 576
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.7591150620371318 \cdot 10^{-23} \lor \neg \left(y \le 1.183901191363865 \cdot 10^{-83}\right):\\ \;\;\;\;\left|(\left(\frac{z}{y}\right) \cdot \left(-x\right) + \left(\frac{x + 4}{y}\right))_*\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - z \cdot x}{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 y < -1.7591150620371318e-23 or 1.183901191363865e-83 < y

    1. Initial program 2.5

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied *-un-lft-identity2.5

      \[\leadsto \left|\color{blue}{1 \cdot \frac{x + 4}{y}} - \frac{x}{y} \cdot z\right|\]
    4. Applied prod-diff2.5

      \[\leadsto \left|\color{blue}{(1 \cdot \left(\frac{x + 4}{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|\]
    5. Simplified0.4

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

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

    if -1.7591150620371318e-23 < y < 1.183901191363865e-83

    1. Initial program 0.1

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

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

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

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

Runtime

Time bar (total: 18.2s)Debug logProfile

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