Average Error: 10.7 → 1.3
Time: 5.1s
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 r556238 = x;
        double r556239 = y;
        double r556240 = z;
        double r556241 = r556239 - r556240;
        double r556242 = t;
        double r556243 = r556241 * r556242;
        double r556244 = a;
        double r556245 = r556244 - r556240;
        double r556246 = r556243 / r556245;
        double r556247 = r556238 + r556246;
        return r556247;
}

double f(double x, double y, double z, double t, double a) {
        double r556248 = y;
        double r556249 = z;
        double r556250 = r556248 - r556249;
        double r556251 = a;
        double r556252 = r556251 - r556249;
        double r556253 = r556250 / r556252;
        double r556254 = t;
        double r556255 = x;
        double r556256 = fma(r556253, r556254, r556255);
        return r556256;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.7
Target0.6
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.7

    \[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 2020001 +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))))