Average Error: 10.7 → 1.5
Time: 21.2s
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 r24110854 = x;
        double r24110855 = y;
        double r24110856 = z;
        double r24110857 = r24110855 - r24110856;
        double r24110858 = t;
        double r24110859 = r24110857 * r24110858;
        double r24110860 = a;
        double r24110861 = r24110860 - r24110856;
        double r24110862 = r24110859 / r24110861;
        double r24110863 = r24110854 + r24110862;
        return r24110863;
}

double f(double x, double y, double z, double t, double a) {
        double r24110864 = t;
        double r24110865 = y;
        double r24110866 = z;
        double r24110867 = r24110865 - r24110866;
        double r24110868 = 1.0;
        double r24110869 = a;
        double r24110870 = r24110869 - r24110866;
        double r24110871 = r24110868 / r24110870;
        double r24110872 = r24110867 * r24110871;
        double r24110873 = x;
        double r24110874 = fma(r24110864, r24110872, r24110873);
        return r24110874;
}

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