Average Error: 10.8 → 1.4
Time: 20.0s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\mathsf{fma}\left(\frac{y}{a - z} - \frac{1}{\frac{a}{z} + -1}, t, x\right)\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\mathsf{fma}\left(\frac{y}{a - z} - \frac{1}{\frac{a}{z} + -1}, t, x\right)
double f(double x, double y, double z, double t, double a) {
        double r410963 = x;
        double r410964 = y;
        double r410965 = z;
        double r410966 = r410964 - r410965;
        double r410967 = t;
        double r410968 = r410966 * r410967;
        double r410969 = a;
        double r410970 = r410969 - r410965;
        double r410971 = r410968 / r410970;
        double r410972 = r410963 + r410971;
        return r410972;
}

double f(double x, double y, double z, double t, double a) {
        double r410973 = y;
        double r410974 = a;
        double r410975 = z;
        double r410976 = r410974 - r410975;
        double r410977 = r410973 / r410976;
        double r410978 = 1.0;
        double r410979 = r410974 / r410975;
        double r410980 = -1.0;
        double r410981 = r410979 + r410980;
        double r410982 = r410978 / r410981;
        double r410983 = r410977 - r410982;
        double r410984 = t;
        double r410985 = x;
        double r410986 = fma(r410983, r410984, r410985);
        return r410986;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.8
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 10.8

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

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

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

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

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

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

Reproduce

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

  :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))))