Average Error: 0.1 → 0.1
Time: 4.2s
Precision: 64
\[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\]
\[x - \mathsf{fma}\left(\log y, y + 0.5, z - y\right)\]
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
x - \mathsf{fma}\left(\log y, y + 0.5, z - y\right)
double f(double x, double y, double z) {
        double r395139 = x;
        double r395140 = y;
        double r395141 = 0.5;
        double r395142 = r395140 + r395141;
        double r395143 = log(r395140);
        double r395144 = r395142 * r395143;
        double r395145 = r395139 - r395144;
        double r395146 = r395145 + r395140;
        double r395147 = z;
        double r395148 = r395146 - r395147;
        return r395148;
}

double f(double x, double y, double z) {
        double r395149 = x;
        double r395150 = y;
        double r395151 = log(r395150);
        double r395152 = 0.5;
        double r395153 = r395150 + r395152;
        double r395154 = z;
        double r395155 = r395154 - r395150;
        double r395156 = fma(r395151, r395153, r395155);
        double r395157 = r395149 - r395156;
        return r395157;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y\]

Derivation

  1. Initial program 0.1

    \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\]
  2. Simplified0.1

    \[\leadsto \color{blue}{x - \left(\mathsf{fma}\left(\log y, y + 0.5, z\right) - y\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.1

    \[\leadsto x - \left(\color{blue}{\left(\log y \cdot \left(y + 0.5\right) + z\right)} - y\right)\]
  5. Applied associate--l+0.1

    \[\leadsto x - \color{blue}{\left(\log y \cdot \left(y + 0.5\right) + \left(z - y\right)\right)}\]
  6. Using strategy rm
  7. Applied fma-def0.1

    \[\leadsto x - \color{blue}{\mathsf{fma}\left(\log y, y + 0.5, z - y\right)}\]
  8. Final simplification0.1

    \[\leadsto x - \mathsf{fma}\left(\log y, y + 0.5, z - y\right)\]

Reproduce

herbie shell --seed 2020060 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (- (- (+ y x) z) (* (+ y 0.5) (log y)))

  (- (+ (- x (* (+ y 0.5) (log y))) y) z))