Average Error: 45.4 → 8.3
Time: 21.1s
Precision: 64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1}\right)\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1}\right)
double f(double x, double y, double z) {
        double r3751143 = x;
        double r3751144 = y;
        double r3751145 = z;
        double r3751146 = fma(r3751143, r3751144, r3751145);
        double r3751147 = 1.0;
        double r3751148 = r3751143 * r3751144;
        double r3751149 = r3751148 + r3751145;
        double r3751150 = r3751147 + r3751149;
        double r3751151 = r3751146 - r3751150;
        return r3751151;
}

double f(double x, double y, double z) {
        double r3751152 = x;
        double r3751153 = y;
        double r3751154 = z;
        double r3751155 = fma(r3751152, r3751153, r3751154);
        double r3751156 = r3751152 * r3751153;
        double r3751157 = r3751154 + r3751156;
        double r3751158 = r3751155 - r3751157;
        double r3751159 = 1.0;
        double r3751160 = r3751158 - r3751159;
        double r3751161 = exp(r3751160);
        double r3751162 = log(r3751161);
        return r3751162;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.4
Target0
Herbie8.3
\[-1\]

Derivation

  1. Initial program 45.4

    \[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
  2. Using strategy rm
  3. Applied add-log-exp47.0

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + \color{blue}{\log \left(e^{z}\right)}\right)\right)\]
  4. Applied add-log-exp48.0

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(1 + \left(\color{blue}{\log \left(e^{x \cdot y}\right)} + \log \left(e^{z}\right)\right)\right)\]
  5. Applied sum-log48.0

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(1 + \color{blue}{\log \left(e^{x \cdot y} \cdot e^{z}\right)}\right)\]
  6. Applied add-log-exp48.0

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(\color{blue}{\log \left(e^{1}\right)} + \log \left(e^{x \cdot y} \cdot e^{z}\right)\right)\]
  7. Applied sum-log48.0

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \color{blue}{\log \left(e^{1} \cdot \left(e^{x \cdot y} \cdot e^{z}\right)\right)}\]
  8. Applied add-log-exp48.0

    \[\leadsto \color{blue}{\log \left(e^{\mathsf{fma}\left(x, y, z\right)}\right)} - \log \left(e^{1} \cdot \left(e^{x \cdot y} \cdot e^{z}\right)\right)\]
  9. Applied diff-log48.0

    \[\leadsto \color{blue}{\log \left(\frac{e^{\mathsf{fma}\left(x, y, z\right)}}{e^{1} \cdot \left(e^{x \cdot y} \cdot e^{z}\right)}\right)}\]
  10. Simplified8.3

    \[\leadsto \log \color{blue}{\left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(x \cdot y + z\right)\right) - 1}\right)}\]
  11. Final simplification8.3

    \[\leadsto \log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1}\right)\]

Reproduce

herbie shell --seed 2019170 
(FPCore (x y z)
  :name "simple fma test"

  :herbie-target
  -1.0

  (- (fma x y z) (+ 1.0 (+ (* x y) z))))