Average Error: 1.5 → 0.1
Time: 28.9s
Precision: 64
Internal Precision: 320
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.1755707145846646 \cdot 10^{+39} \lor \neg \left(x \le 4.381822776783964 \cdot 10^{-47}\right):\\ \;\;\;\;\left|(z \cdot \left(\frac{-x}{y}\right) + \left(\frac{x}{y} + \frac{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 x < -2.1755707145846646e+39 or 4.381822776783964e-47 < x

    1. Initial program 0.2

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

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

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

    if -2.1755707145846646e+39 < x < 4.381822776783964e-47

    1. Initial program 2.5

      \[\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.1

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

Runtime

Time bar (total: 28.9s)Debug logProfile

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