Average Error: 10.9 → 1.3
Time: 18.8s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\mathsf{fma}\left(\mathsf{fma}\left(y, \frac{1}{a - z}, \frac{-z}{a - z}\right), t, x\right)\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\mathsf{fma}\left(\mathsf{fma}\left(y, \frac{1}{a - z}, \frac{-z}{a - z}\right), t, x\right)
double f(double x, double y, double z, double t, double a) {
        double r394157 = x;
        double r394158 = y;
        double r394159 = z;
        double r394160 = r394158 - r394159;
        double r394161 = t;
        double r394162 = r394160 * r394161;
        double r394163 = a;
        double r394164 = r394163 - r394159;
        double r394165 = r394162 / r394164;
        double r394166 = r394157 + r394165;
        return r394166;
}

double f(double x, double y, double z, double t, double a) {
        double r394167 = y;
        double r394168 = 1.0;
        double r394169 = a;
        double r394170 = z;
        double r394171 = r394169 - r394170;
        double r394172 = r394168 / r394171;
        double r394173 = -r394170;
        double r394174 = r394173 / r394171;
        double r394175 = fma(r394167, r394172, r394174);
        double r394176 = t;
        double r394177 = x;
        double r394178 = fma(r394175, r394176, r394177);
        return r394178;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

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

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

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{y \cdot \frac{1}{a - z}} - \frac{z}{a - z}, t, x\right)\]
  7. Applied fma-neg1.3

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

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

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

Reproduce

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