Average Error: 11.0 → 3.0
Time: 15.0s
Precision: 64
\[x + \frac{y \cdot \left(z - t\right)}{z - a}\]
\[\mathsf{fma}\left(\frac{y}{z - a}, z - t, x\right)\]
x + \frac{y \cdot \left(z - t\right)}{z - a}
\mathsf{fma}\left(\frac{y}{z - a}, z - t, x\right)
double f(double x, double y, double z, double t, double a) {
        double r335588 = x;
        double r335589 = y;
        double r335590 = z;
        double r335591 = t;
        double r335592 = r335590 - r335591;
        double r335593 = r335589 * r335592;
        double r335594 = a;
        double r335595 = r335590 - r335594;
        double r335596 = r335593 / r335595;
        double r335597 = r335588 + r335596;
        return r335597;
}

double f(double x, double y, double z, double t, double a) {
        double r335598 = y;
        double r335599 = z;
        double r335600 = a;
        double r335601 = r335599 - r335600;
        double r335602 = r335598 / r335601;
        double r335603 = t;
        double r335604 = r335599 - r335603;
        double r335605 = x;
        double r335606 = fma(r335602, r335604, r335605);
        return r335606;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original11.0
Target1.3
Herbie3.0
\[x + \frac{y}{\frac{z - a}{z - t}}\]

Derivation

  1. Initial program 11.0

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

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

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

Reproduce

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

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

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