Average Error: 9.2 → 0.1
Time: 4.9s
Precision: 64
\[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}\]
\[\mathsf{fma}\left(2, \frac{1}{t \cdot z}, 2 \cdot \frac{1}{t} - 2\right) + \frac{x}{y}\]
\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}
\mathsf{fma}\left(2, \frac{1}{t \cdot z}, 2 \cdot \frac{1}{t} - 2\right) + \frac{x}{y}
double f(double x, double y, double z, double t) {
        double r856066 = x;
        double r856067 = y;
        double r856068 = r856066 / r856067;
        double r856069 = 2.0;
        double r856070 = z;
        double r856071 = r856070 * r856069;
        double r856072 = 1.0;
        double r856073 = t;
        double r856074 = r856072 - r856073;
        double r856075 = r856071 * r856074;
        double r856076 = r856069 + r856075;
        double r856077 = r856073 * r856070;
        double r856078 = r856076 / r856077;
        double r856079 = r856068 + r856078;
        return r856079;
}

double f(double x, double y, double z, double t) {
        double r856080 = 2.0;
        double r856081 = 1.0;
        double r856082 = t;
        double r856083 = z;
        double r856084 = r856082 * r856083;
        double r856085 = r856081 / r856084;
        double r856086 = r856081 / r856082;
        double r856087 = r856080 * r856086;
        double r856088 = r856087 - r856080;
        double r856089 = fma(r856080, r856085, r856088);
        double r856090 = x;
        double r856091 = y;
        double r856092 = r856090 / r856091;
        double r856093 = r856089 + r856092;
        return r856093;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original9.2
Target0.1
Herbie0.1
\[\frac{\frac{2}{z} + 2}{t} - \left(2 - \frac{x}{y}\right)\]

Derivation

  1. Initial program 9.2

    \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}\]
  2. Simplified9.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{fma}\left(z, 1 - t, 1\right)}{z}, \frac{2}{t}, \frac{x}{y}\right)}\]
  3. Taylor expanded around 0 0.1

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{1}{z} + 1\right) - t}, \frac{2}{t}, \frac{x}{y}\right)\]
  4. Using strategy rm
  5. Applied add-cube-cbrt0.4

    \[\leadsto \mathsf{fma}\left(\left(\frac{1}{z} + 1\right) - \color{blue}{\left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}}, \frac{2}{t}, \frac{x}{y}\right)\]
  6. Applied add-cube-cbrt0.6

    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\sqrt[3]{\frac{1}{z} + 1} \cdot \sqrt[3]{\frac{1}{z} + 1}\right) \cdot \sqrt[3]{\frac{1}{z} + 1}} - \left(\sqrt[3]{t} \cdot \sqrt[3]{t}\right) \cdot \sqrt[3]{t}, \frac{2}{t}, \frac{x}{y}\right)\]
  7. Applied prod-diff0.6

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

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

    \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(-1, t, {\left(\sqrt[3]{\frac{1}{z} + 1}\right)}^{3}\right) + \color{blue}{\left(t - t\right)}, \frac{2}{t}, \frac{x}{y}\right)\]
  10. Using strategy rm
  11. Applied fma-udef0.4

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

    \[\leadsto \color{blue}{\left(\left(\frac{1}{z} + 1\right) - t\right) \cdot \frac{2}{t}} + \frac{x}{y}\]
  13. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{\left(\left(2 \cdot \frac{1}{t \cdot z} + 2 \cdot \frac{1}{t}\right) - 2\right)} + \frac{x}{y}\]
  14. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, \frac{1}{t \cdot z}, 2 \cdot \frac{1}{t} - 2\right)} + \frac{x}{y}\]
  15. Final simplification0.1

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

Reproduce

herbie shell --seed 2020035 +o rules:numerics
(FPCore (x y z t)
  :name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
  :precision binary64

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

  (+ (/ x y) (/ (+ 2 (* (* z 2) (- 1 t))) (* t z))))