Average Error: 1.4 → 1.4
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 r657821 = x;
        double r657822 = y;
        double r657823 = z;
        double r657824 = t;
        double r657825 = r657823 - r657824;
        double r657826 = a;
        double r657827 = r657823 - r657826;
        double r657828 = r657825 / r657827;
        double r657829 = r657822 * r657828;
        double r657830 = r657821 + r657829;
        return r657830;
}

double f(double x, double y, double z, double t, double a) {
        double r657831 = y;
        double r657832 = z;
        double r657833 = t;
        double r657834 = r657832 - r657833;
        double r657835 = a;
        double r657836 = r657832 - r657835;
        double r657837 = r657834 / r657836;
        double r657838 = x;
        double r657839 = fma(r657831, r657837, r657838);
        return r657839;
}

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(y, \frac{z - t}{z - a}, x\right)}\]
  3. Final simplification1.4

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

Reproduce

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