Average Error: 0.1 → 0.1
Time: 22.9s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1.0 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(x, 0.5, y \cdot \left(1.0 - z\right) + \left(\left(y + y\right) \cdot \log \left(\sqrt[3]{z}\right) + \log \left(\sqrt[3]{z}\right) \cdot y\right)\right)\]
x \cdot 0.5 + y \cdot \left(\left(1.0 - z\right) + \log z\right)
\mathsf{fma}\left(x, 0.5, y \cdot \left(1.0 - z\right) + \left(\left(y + y\right) \cdot \log \left(\sqrt[3]{z}\right) + \log \left(\sqrt[3]{z}\right) \cdot y\right)\right)
double f(double x, double y, double z) {
        double r10505645 = x;
        double r10505646 = 0.5;
        double r10505647 = r10505645 * r10505646;
        double r10505648 = y;
        double r10505649 = 1.0;
        double r10505650 = z;
        double r10505651 = r10505649 - r10505650;
        double r10505652 = log(r10505650);
        double r10505653 = r10505651 + r10505652;
        double r10505654 = r10505648 * r10505653;
        double r10505655 = r10505647 + r10505654;
        return r10505655;
}

double f(double x, double y, double z) {
        double r10505656 = x;
        double r10505657 = 0.5;
        double r10505658 = y;
        double r10505659 = 1.0;
        double r10505660 = z;
        double r10505661 = r10505659 - r10505660;
        double r10505662 = r10505658 * r10505661;
        double r10505663 = r10505658 + r10505658;
        double r10505664 = cbrt(r10505660);
        double r10505665 = log(r10505664);
        double r10505666 = r10505663 * r10505665;
        double r10505667 = r10505665 * r10505658;
        double r10505668 = r10505666 + r10505667;
        double r10505669 = r10505662 + r10505668;
        double r10505670 = fma(r10505656, r10505657, r10505669);
        return r10505670;
}

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.0 - z\right) + \log z\right)\]
  2. Simplified0.1

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

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

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

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

    \[\leadsto \mathsf{fma}\left(x, 0.5, \left(1.0 - \left(\color{blue}{\mathsf{fma}\left(-2, \log \left(\sqrt[3]{z}\right), z\right)} - \log \left(\sqrt[3]{z}\right)\right)\right) \cdot y\right)\]
  8. Taylor expanded around 0 0.2

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

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

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

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

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

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

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

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

Reproduce

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

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

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