Average Error: 6.8 → 1.9
Time: 12.2s
Precision: 64
\[x + \frac{y \cdot \left(z - x\right)}{t}\]
\[\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)\]
x + \frac{y \cdot \left(z - x\right)}{t}
\mathsf{fma}\left(z - x, \frac{y}{t}, x\right)
double f(double x, double y, double z, double t) {
        double r207171 = x;
        double r207172 = y;
        double r207173 = z;
        double r207174 = r207173 - r207171;
        double r207175 = r207172 * r207174;
        double r207176 = t;
        double r207177 = r207175 / r207176;
        double r207178 = r207171 + r207177;
        return r207178;
}

double f(double x, double y, double z, double t) {
        double r207179 = z;
        double r207180 = x;
        double r207181 = r207179 - r207180;
        double r207182 = y;
        double r207183 = t;
        double r207184 = r207182 / r207183;
        double r207185 = fma(r207181, r207184, r207180);
        return r207185;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original6.8
Target1.9
Herbie1.9
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)\]

Derivation

  1. Initial program 6.8

    \[x + \frac{y \cdot \left(z - x\right)}{t}\]
  2. Simplified1.9

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"

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

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