Average Error: 1.5 → 1.5
Time: 4.5s
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 r551180 = x;
        double r551181 = y;
        double r551182 = z;
        double r551183 = t;
        double r551184 = r551182 - r551183;
        double r551185 = a;
        double r551186 = r551182 - r551185;
        double r551187 = r551184 / r551186;
        double r551188 = r551181 * r551187;
        double r551189 = r551180 + r551188;
        return r551189;
}

double f(double x, double y, double z, double t, double a) {
        double r551190 = y;
        double r551191 = z;
        double r551192 = t;
        double r551193 = r551191 - r551192;
        double r551194 = a;
        double r551195 = r551191 - r551194;
        double r551196 = r551193 / r551195;
        double r551197 = x;
        double r551198 = fma(r551190, r551196, r551197);
        return r551198;
}

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