Average Error: 6.8 → 1.9
Time: 12.9s
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 r13037026 = x;
        double r13037027 = y;
        double r13037028 = z;
        double r13037029 = r13037028 - r13037026;
        double r13037030 = r13037027 * r13037029;
        double r13037031 = t;
        double r13037032 = r13037030 / r13037031;
        double r13037033 = r13037026 + r13037032;
        return r13037033;
}

double f(double x, double y, double z, double t) {
        double r13037034 = z;
        double r13037035 = x;
        double r13037036 = r13037034 - r13037035;
        double r13037037 = y;
        double r13037038 = t;
        double r13037039 = r13037037 / r13037038;
        double r13037040 = fma(r13037036, r13037039, r13037035);
        return r13037040;
}

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