Average Error: 10.4 → 1.3
Time: 6.3s
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 r740968 = x;
        double r740969 = y;
        double r740970 = z;
        double r740971 = r740969 - r740970;
        double r740972 = t;
        double r740973 = r740971 * r740972;
        double r740974 = a;
        double r740975 = r740974 - r740970;
        double r740976 = r740973 / r740975;
        double r740977 = r740968 + r740976;
        return r740977;
}

double f(double x, double y, double z, double t, double a) {
        double r740978 = y;
        double r740979 = z;
        double r740980 = r740978 - r740979;
        double r740981 = a;
        double r740982 = r740981 - r740979;
        double r740983 = r740980 / r740982;
        double r740984 = t;
        double r740985 = x;
        double r740986 = fma(r740983, r740984, r740985);
        return r740986;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.4
Target0.5
Herbie1.3
\[\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.4

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

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

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

Reproduce

herbie shell --seed 2019362 +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))))