Average Error: 0.1 → 0.1
Time: 20.8s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(x, 0.5, y \cdot \left(\left(\log z + \left(1 - z\right)\right) - \mathsf{fma}\left(-\sqrt[3]{\log z}, \sqrt[3]{\log z} \cdot \sqrt[3]{\log z}, \sqrt[3]{\log z} \cdot \left(\sqrt[3]{\log z} \cdot \sqrt[3]{\log z}\right)\right)\right)\right)\]
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\mathsf{fma}\left(x, 0.5, y \cdot \left(\left(\log z + \left(1 - z\right)\right) - \mathsf{fma}\left(-\sqrt[3]{\log z}, \sqrt[3]{\log z} \cdot \sqrt[3]{\log z}, \sqrt[3]{\log z} \cdot \left(\sqrt[3]{\log z} \cdot \sqrt[3]{\log z}\right)\right)\right)\right)
double f(double x, double y, double z) {
        double r160643 = x;
        double r160644 = 0.5;
        double r160645 = r160643 * r160644;
        double r160646 = y;
        double r160647 = 1.0;
        double r160648 = z;
        double r160649 = r160647 - r160648;
        double r160650 = log(r160648);
        double r160651 = r160649 + r160650;
        double r160652 = r160646 * r160651;
        double r160653 = r160645 + r160652;
        return r160653;
}

double f(double x, double y, double z) {
        double r160654 = x;
        double r160655 = 0.5;
        double r160656 = y;
        double r160657 = z;
        double r160658 = log(r160657);
        double r160659 = 1.0;
        double r160660 = r160659 - r160657;
        double r160661 = r160658 + r160660;
        double r160662 = cbrt(r160658);
        double r160663 = -r160662;
        double r160664 = r160662 * r160662;
        double r160665 = r160662 * r160664;
        double r160666 = fma(r160663, r160664, r160665);
        double r160667 = r160661 - r160666;
        double r160668 = r160656 * r160667;
        double r160669 = fma(r160654, r160655, r160668);
        return r160669;
}

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. Using strategy rm
  3. Applied distribute-lft-in0.1

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

    \[\leadsto \color{blue}{\left(x \cdot 0.5 + y \cdot \left(1 - z\right)\right) + y \cdot \log z}\]
  5. Simplified0.1

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

    \[\leadsto \color{blue}{\left(\log z \cdot y + \left(1 \cdot y + 0.5 \cdot x\right)\right) - z \cdot y}\]
  7. Simplified0.1

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019322 +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)))))