Average Error: 0.1 → 0.1
Time: 13.1s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(x, 0.5, \log \left(\sqrt[3]{z}\right) \cdot y + \mathsf{fma}\left(2, \log \left(\sqrt[3]{z}\right), 1 - z\right) \cdot y\right)\]
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\mathsf{fma}\left(x, 0.5, \log \left(\sqrt[3]{z}\right) \cdot y + \mathsf{fma}\left(2, \log \left(\sqrt[3]{z}\right), 1 - z\right) \cdot y\right)
double f(double x, double y, double z) {
        double r302981 = x;
        double r302982 = 0.5;
        double r302983 = r302981 * r302982;
        double r302984 = y;
        double r302985 = 1.0;
        double r302986 = z;
        double r302987 = r302985 - r302986;
        double r302988 = log(r302986);
        double r302989 = r302987 + r302988;
        double r302990 = r302984 * r302989;
        double r302991 = r302983 + r302990;
        return r302991;
}

double f(double x, double y, double z) {
        double r302992 = x;
        double r302993 = 0.5;
        double r302994 = z;
        double r302995 = cbrt(r302994);
        double r302996 = log(r302995);
        double r302997 = y;
        double r302998 = r302996 * r302997;
        double r302999 = 2.0;
        double r303000 = 1.0;
        double r303001 = r303000 - r302994;
        double r303002 = fma(r302999, r302996, r303001);
        double r303003 = r303002 * r302997;
        double r303004 = r302998 + r303003;
        double r303005 = fma(r302992, r302993, r303004);
        return r303005;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 0.1

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

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

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{y \cdot \left(1 - z\right) + y \cdot \log z}\right)\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, y \cdot \left(1 - z\right) + y \cdot \log \color{blue}{\left(\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}\right)}\right)\]
  7. Applied log-prod0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, y \cdot \left(1 - z\right) + y \cdot \color{blue}{\left(\log \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) + \log \left(\sqrt[3]{z}\right)\right)}\right)\]
  8. Applied distribute-rgt-in0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, y \cdot \left(1 - z\right) + \color{blue}{\left(\log \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot y + \log \left(\sqrt[3]{z}\right) \cdot y\right)}\right)\]
  9. Applied associate-+r+0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{\left(y \cdot \left(1 - z\right) + \log \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot y\right) + \log \left(\sqrt[3]{z}\right) \cdot y}\right)\]
  10. Simplified0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{y \cdot \left(2 \cdot \log \left(\sqrt[3]{z}\right) + \left(1 - z\right)\right)} + \log \left(\sqrt[3]{z}\right) \cdot y\right)\]
  11. Taylor expanded around inf 0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, y \cdot \left(2 \cdot \log \color{blue}{\left({\left(\frac{1}{z}\right)}^{\frac{-1}{3}}\right)} + \left(1 - z\right)\right) + \log \left(\sqrt[3]{z}\right) \cdot y\right)\]
  12. Using strategy rm
  13. Applied pow10.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, y \cdot \color{blue}{{\left(2 \cdot \log \left({\left(\frac{1}{z}\right)}^{\frac{-1}{3}}\right) + \left(1 - z\right)\right)}^{1}} + \log \left(\sqrt[3]{z}\right) \cdot y\right)\]
  14. Applied pow10.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{{y}^{1}} \cdot {\left(2 \cdot \log \left({\left(\frac{1}{z}\right)}^{\frac{-1}{3}}\right) + \left(1 - z\right)\right)}^{1} + \log \left(\sqrt[3]{z}\right) \cdot y\right)\]
  15. Applied pow-prod-down0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{{\left(y \cdot \left(2 \cdot \log \left({\left(\frac{1}{z}\right)}^{\frac{-1}{3}}\right) + \left(1 - z\right)\right)\right)}^{1}} + \log \left(\sqrt[3]{z}\right) \cdot y\right)\]
  16. Simplified0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, {\color{blue}{\left(y \cdot \mathsf{fma}\left(2, \log \left(\sqrt[3]{z}\right), 1 - z\right)\right)}}^{1} + \log \left(\sqrt[3]{z}\right) \cdot y\right)\]
  17. Final simplification0.1

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

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(FPCore (x y z)
  :name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
  :precision binary64

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

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