Average Error: 10.7 → 1.5
Time: 20.6s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\mathsf{fma}\left(t, \left(y - z\right) \cdot \frac{1}{a - z}, x\right)\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\mathsf{fma}\left(t, \left(y - z\right) \cdot \frac{1}{a - z}, x\right)
double f(double x, double y, double z, double t, double a) {
        double r23262886 = x;
        double r23262887 = y;
        double r23262888 = z;
        double r23262889 = r23262887 - r23262888;
        double r23262890 = t;
        double r23262891 = r23262889 * r23262890;
        double r23262892 = a;
        double r23262893 = r23262892 - r23262888;
        double r23262894 = r23262891 / r23262893;
        double r23262895 = r23262886 + r23262894;
        return r23262895;
}

double f(double x, double y, double z, double t, double a) {
        double r23262896 = t;
        double r23262897 = y;
        double r23262898 = z;
        double r23262899 = r23262897 - r23262898;
        double r23262900 = 1.0;
        double r23262901 = a;
        double r23262902 = r23262901 - r23262898;
        double r23262903 = r23262900 / r23262902;
        double r23262904 = r23262899 * r23262903;
        double r23262905 = x;
        double r23262906 = fma(r23262896, r23262904, r23262905);
        return r23262906;
}

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.5
\[\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.5

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

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

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

Reproduce

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