Average Error: 10.3 → 1.4
Time: 12.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 r451479 = x;
        double r451480 = y;
        double r451481 = z;
        double r451482 = r451480 - r451481;
        double r451483 = t;
        double r451484 = r451482 * r451483;
        double r451485 = a;
        double r451486 = r451485 - r451481;
        double r451487 = r451484 / r451486;
        double r451488 = r451479 + r451487;
        return r451488;
}

double f(double x, double y, double z, double t, double a) {
        double r451489 = y;
        double r451490 = z;
        double r451491 = r451489 - r451490;
        double r451492 = a;
        double r451493 = r451492 - r451490;
        double r451494 = r451491 / r451493;
        double r451495 = t;
        double r451496 = x;
        double r451497 = fma(r451494, r451495, r451496);
        return r451497;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.3
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.3

    \[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. Final simplification1.4

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

Reproduce

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