Average Error: 11.2 → 1.4
Time: 21.4s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)
double f(double x, double y, double z, double t, double a) {
        double r472478 = x;
        double r472479 = y;
        double r472480 = z;
        double r472481 = r472479 - r472480;
        double r472482 = t;
        double r472483 = r472481 * r472482;
        double r472484 = a;
        double r472485 = r472484 - r472480;
        double r472486 = r472483 / r472485;
        double r472487 = r472478 + r472486;
        return r472487;
}

double f(double x, double y, double z, double t, double a) {
        double r472488 = y;
        double r472489 = z;
        double r472490 = r472488 - r472489;
        double r472491 = a;
        double r472492 = r472491 - r472489;
        double r472493 = r472490 / r472492;
        double r472494 = t;
        double r472495 = x;
        double r472496 = fma(r472493, r472494, r472495);
        return r472496;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original11.2
Target0.5
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;t \lt -1.068297449017406694366747246993994850729 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.911094988758637497591020599238553861375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array}\]

Derivation

  1. Initial program 11.2

    \[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
  2. Simplified3.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, \frac{t}{a - z}, x\right)}\]
  3. Using strategy rm
  4. Applied clear-num3.2

    \[\leadsto \mathsf{fma}\left(y - z, \color{blue}{\frac{1}{\frac{a - z}{t}}}, x\right)\]
  5. Using strategy rm
  6. Applied add-cube-cbrt3.7

    \[\leadsto \mathsf{fma}\left(y - z, \frac{1}{\color{blue}{\left(\sqrt[3]{\frac{a - z}{t}} \cdot \sqrt[3]{\frac{a - z}{t}}\right) \cdot \sqrt[3]{\frac{a - z}{t}}}}, x\right)\]
  7. Applied associate-/r*3.6

    \[\leadsto \mathsf{fma}\left(y - z, \color{blue}{\frac{\frac{1}{\sqrt[3]{\frac{a - z}{t}} \cdot \sqrt[3]{\frac{a - z}{t}}}}{\sqrt[3]{\frac{a - z}{t}}}}, x\right)\]
  8. Using strategy rm
  9. Applied fma-udef3.6

    \[\leadsto \color{blue}{\left(y - z\right) \cdot \frac{\frac{1}{\sqrt[3]{\frac{a - z}{t}} \cdot \sqrt[3]{\frac{a - z}{t}}}}{\sqrt[3]{\frac{a - z}{t}}} + x}\]
  10. Simplified3.0

    \[\leadsto \color{blue}{\frac{y - z}{\frac{a - z}{t}}} + x\]
  11. Using strategy rm
  12. Applied *-un-lft-identity3.0

    \[\leadsto \frac{y - z}{\frac{a - z}{t}} + \color{blue}{1 \cdot x}\]
  13. Applied *-un-lft-identity3.0

    \[\leadsto \color{blue}{1 \cdot \frac{y - z}{\frac{a - z}{t}}} + 1 \cdot x\]
  14. Applied distribute-lft-out3.0

    \[\leadsto \color{blue}{1 \cdot \left(\frac{y - z}{\frac{a - z}{t}} + x\right)}\]
  15. Simplified1.4

    \[\leadsto 1 \cdot \color{blue}{\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)}\]
  16. Final simplification1.4

    \[\leadsto \mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\]

Reproduce

herbie shell --seed 2019196 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, A"

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

  (+ x (/ (* (- y z) t) (- a z))))