Average Error: 1.7 → 0.1
Time: 24.3s
Precision: 64
Internal Precision: 320
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{4 + x}}{\frac{y}{\sqrt{4 + x}}} - \frac{x}{y} \cdot z \le -102048080.2371222:\\ \;\;\;\;\left|(\left(4 + x\right) \cdot \left(\frac{1}{y}\right) + \left(\left(-z\right) \cdot \frac{x}{y}\right))_*\right|\\ \mathbf{elif}\;\frac{\sqrt{4 + x}}{\frac{y}{\sqrt{4 + x}}} - \frac{x}{y} \cdot z \le 1.6142054979419516 \cdot 10^{-39}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{z}{\frac{y}{x}}\right|\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Split input into 3 regimes
  2. if (- (/ (sqrt (+ x 4)) (/ y (sqrt (+ x 4)))) (* (/ x y) z)) < -102048080.2371222

    1. Initial program 0.1

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

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

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

    if -102048080.2371222 < (- (/ (sqrt (+ x 4)) (/ y (sqrt (+ x 4)))) (* (/ x y) z)) < 1.6142054979419516e-39

    1. Initial program 4.9

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Initial simplification0.1

      \[\leadsto \left|\frac{4 + x}{y} - \frac{x}{\frac{y}{z}}\right|\]

    if 1.6142054979419516e-39 < (- (/ (sqrt (+ x 4)) (/ y (sqrt (+ x 4)))) (* (/ x y) z))

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt18.7

      \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} - \frac{x}{y} \cdot z\right|\]
    4. Applied prod-diff18.7

      \[\leadsto \left|\color{blue}{(\left(\sqrt{\frac{x + 4}{y}}\right) \cdot \left(\sqrt{\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.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{4 + x}}{\frac{y}{\sqrt{4 + x}}} - \frac{x}{y} \cdot z \le -102048080.2371222:\\ \;\;\;\;\left|(\left(4 + x\right) \cdot \left(\frac{1}{y}\right) + \left(\left(-z\right) \cdot \frac{x}{y}\right))_*\right|\\ \mathbf{elif}\;\frac{\sqrt{4 + x}}{\frac{y}{\sqrt{4 + x}}} - \frac{x}{y} \cdot z \le 1.6142054979419516 \cdot 10^{-39}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4 + x}{y} - \frac{z}{\frac{y}{x}}\right|\\ \end{array}\]

Runtime

Time bar (total: 24.3s)Debug logProfile

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