Average Error: 3.5 → 1.7
Time: 16.2s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\mathsf{fma}\left(1, x, y \cdot \frac{-1}{z \cdot 3}\right) + \mathsf{fma}\left(y, \frac{-1}{z \cdot 3} + \frac{1}{z \cdot 3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\mathsf{fma}\left(1, x, y \cdot \frac{-1}{z \cdot 3}\right) + \mathsf{fma}\left(y, \frac{-1}{z \cdot 3} + \frac{1}{z \cdot 3}, \frac{\frac{t}{z \cdot 3}}{y}\right)
double f(double x, double y, double z, double t) {
        double r571678 = x;
        double r571679 = y;
        double r571680 = z;
        double r571681 = 3.0;
        double r571682 = r571680 * r571681;
        double r571683 = r571679 / r571682;
        double r571684 = r571678 - r571683;
        double r571685 = t;
        double r571686 = r571682 * r571679;
        double r571687 = r571685 / r571686;
        double r571688 = r571684 + r571687;
        return r571688;
}

double f(double x, double y, double z, double t) {
        double r571689 = 1.0;
        double r571690 = x;
        double r571691 = y;
        double r571692 = -1.0;
        double r571693 = z;
        double r571694 = 3.0;
        double r571695 = r571693 * r571694;
        double r571696 = r571692 / r571695;
        double r571697 = r571691 * r571696;
        double r571698 = fma(r571689, r571690, r571697);
        double r571699 = r571689 / r571695;
        double r571700 = r571696 + r571699;
        double r571701 = t;
        double r571702 = r571701 / r571695;
        double r571703 = r571702 / r571691;
        double r571704 = fma(r571691, r571700, r571703);
        double r571705 = r571698 + r571704;
        return r571705;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original3.5
Target1.7
Herbie1.7
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Initial program 3.5

    \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
  2. Simplified3.5

    \[\leadsto \color{blue}{\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}}\]
  3. Using strategy rm
  4. Applied div-inv3.5

    \[\leadsto \left(x - \color{blue}{y \cdot \frac{1}{z \cdot 3}}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\]
  5. Applied *-un-lft-identity3.5

    \[\leadsto \left(\color{blue}{1 \cdot x} - y \cdot \frac{1}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\]
  6. Applied prod-diff3.5

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(1, x, -\frac{1}{z \cdot 3} \cdot y\right) + \mathsf{fma}\left(-\frac{1}{z \cdot 3}, y, \frac{1}{z \cdot 3} \cdot y\right)\right)} + \frac{t}{y \cdot \left(z \cdot 3\right)}\]
  7. Applied associate-+l+3.5

    \[\leadsto \color{blue}{\mathsf{fma}\left(1, x, -\frac{1}{z \cdot 3} \cdot y\right) + \left(\mathsf{fma}\left(-\frac{1}{z \cdot 3}, y, \frac{1}{z \cdot 3} \cdot y\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\right)}\]
  8. Simplified1.7

    \[\leadsto \mathsf{fma}\left(1, x, -\frac{1}{z \cdot 3} \cdot y\right) + \color{blue}{\mathsf{fma}\left(y, \frac{-1}{z \cdot 3} + \frac{1}{z \cdot 3}, \frac{\frac{t}{z \cdot 3}}{y}\right)}\]
  9. Final simplification1.7

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

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, H"

  :herbie-target
  (+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))

  (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))