Average Error: 1.4 → 1.4
Time: 13.9s
Precision: 64
\[x + y \cdot \frac{z - t}{z - a}\]
\[\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)\]
x + y \cdot \frac{z - t}{z - a}
\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)
double f(double x, double y, double z, double t, double a) {
        double r639337 = x;
        double r639338 = y;
        double r639339 = z;
        double r639340 = t;
        double r639341 = r639339 - r639340;
        double r639342 = a;
        double r639343 = r639339 - r639342;
        double r639344 = r639341 / r639343;
        double r639345 = r639338 * r639344;
        double r639346 = r639337 + r639345;
        return r639346;
}

double f(double x, double y, double z, double t, double a) {
        double r639347 = z;
        double r639348 = t;
        double r639349 = r639347 - r639348;
        double r639350 = a;
        double r639351 = r639347 - r639350;
        double r639352 = r639349 / r639351;
        double r639353 = y;
        double r639354 = x;
        double r639355 = fma(r639352, r639353, r639354);
        return r639355;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original1.4
Target1.2
Herbie1.4
\[x + \frac{y}{\frac{z - a}{z - t}}\]

Derivation

  1. Initial program 1.4

    \[x + y \cdot \frac{z - t}{z - a}\]
  2. Simplified1.4

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

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

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

    \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(z - t\right)}^{1}} \cdot {\left(\frac{1}{z - a}\right)}^{1}, y, x\right)\]
  8. Applied pow-prod-down1.4

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

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

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

Reproduce

herbie shell --seed 2020042 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, A"
  :precision binary64

  :herbie-target
  (+ x (/ y (/ (- z a) (- z t))))

  (+ x (* y (/ (- z t) (- z a)))))