Average Error: 1.5 → 1.5
Time: 4.1s
Precision: 64
\[x + y \cdot \frac{z - t}{z - a}\]
\[\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)\]
x + y \cdot \frac{z - t}{z - a}
\mathsf{fma}\left(y, \frac{z - t}{z - a}, x\right)
double f(double x, double y, double z, double t, double a) {
        double r533539 = x;
        double r533540 = y;
        double r533541 = z;
        double r533542 = t;
        double r533543 = r533541 - r533542;
        double r533544 = a;
        double r533545 = r533541 - r533544;
        double r533546 = r533543 / r533545;
        double r533547 = r533540 * r533546;
        double r533548 = r533539 + r533547;
        return r533548;
}

double f(double x, double y, double z, double t, double a) {
        double r533549 = y;
        double r533550 = z;
        double r533551 = t;
        double r533552 = r533550 - r533551;
        double r533553 = a;
        double r533554 = r533550 - r533553;
        double r533555 = r533552 / r533554;
        double r533556 = x;
        double r533557 = fma(r533549, r533555, r533556);
        return r533557;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

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

Derivation

  1. Initial program 1.5

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

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

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

Reproduce

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