Average Error: 3.4 → 0.4
Time: 22.7s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot 3.0 \le -1.359072682814032 \cdot 10^{+24}:\\ \;\;\;\;\frac{t}{\left(z \cdot y\right) \cdot 3.0} + \left(x - \frac{y}{z \cdot 3.0}\right)\\ \mathbf{elif}\;z \cdot 3.0 \le 3.1551391233930085 \cdot 10^{-79}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{y}{3.0} \cdot \frac{-1}{z}\right) + \left(\frac{\frac{t}{3.0}}{y} \cdot \frac{1}{z} + \mathsf{fma}\left(-\frac{y}{3.0}, \frac{1}{z}, \frac{1}{z} \cdot \frac{y}{3.0}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\left(z \cdot y\right) \cdot 3.0} + \left(x - \frac{y}{z \cdot 3.0}\right)\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;z \cdot 3.0 \le -1.359072682814032 \cdot 10^{+24}:\\
\;\;\;\;\frac{t}{\left(z \cdot y\right) \cdot 3.0} + \left(x - \frac{y}{z \cdot 3.0}\right)\\

\mathbf{elif}\;z \cdot 3.0 \le 3.1551391233930085 \cdot 10^{-79}:\\
\;\;\;\;\mathsf{fma}\left(1, x, \frac{y}{3.0} \cdot \frac{-1}{z}\right) + \left(\frac{\frac{t}{3.0}}{y} \cdot \frac{1}{z} + \mathsf{fma}\left(-\frac{y}{3.0}, \frac{1}{z}, \frac{1}{z} \cdot \frac{y}{3.0}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t}{\left(z \cdot y\right) \cdot 3.0} + \left(x - \frac{y}{z \cdot 3.0}\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r33553963 = x;
        double r33553964 = y;
        double r33553965 = z;
        double r33553966 = 3.0;
        double r33553967 = r33553965 * r33553966;
        double r33553968 = r33553964 / r33553967;
        double r33553969 = r33553963 - r33553968;
        double r33553970 = t;
        double r33553971 = r33553967 * r33553964;
        double r33553972 = r33553970 / r33553971;
        double r33553973 = r33553969 + r33553972;
        return r33553973;
}

double f(double x, double y, double z, double t) {
        double r33553974 = z;
        double r33553975 = 3.0;
        double r33553976 = r33553974 * r33553975;
        double r33553977 = -1.359072682814032e+24;
        bool r33553978 = r33553976 <= r33553977;
        double r33553979 = t;
        double r33553980 = y;
        double r33553981 = r33553974 * r33553980;
        double r33553982 = r33553981 * r33553975;
        double r33553983 = r33553979 / r33553982;
        double r33553984 = x;
        double r33553985 = r33553980 / r33553976;
        double r33553986 = r33553984 - r33553985;
        double r33553987 = r33553983 + r33553986;
        double r33553988 = 3.1551391233930085e-79;
        bool r33553989 = r33553976 <= r33553988;
        double r33553990 = 1.0;
        double r33553991 = r33553980 / r33553975;
        double r33553992 = -1.0;
        double r33553993 = r33553992 / r33553974;
        double r33553994 = r33553991 * r33553993;
        double r33553995 = fma(r33553990, r33553984, r33553994);
        double r33553996 = r33553979 / r33553975;
        double r33553997 = r33553996 / r33553980;
        double r33553998 = r33553990 / r33553974;
        double r33553999 = r33553997 * r33553998;
        double r33554000 = -r33553991;
        double r33554001 = r33553998 * r33553991;
        double r33554002 = fma(r33554000, r33553998, r33554001);
        double r33554003 = r33553999 + r33554002;
        double r33554004 = r33553995 + r33554003;
        double r33554005 = r33553989 ? r33554004 : r33553987;
        double r33554006 = r33553978 ? r33553987 : r33554005;
        return r33554006;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original3.4
Target1.7
Herbie0.4
\[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{\frac{t}{z \cdot 3.0}}{y}\]

Derivation

  1. Split input into 2 regimes
  2. if (* z 3.0) < -1.359072682814032e+24 or 3.1551391233930085e-79 < (* z 3.0)

    1. Initial program 0.5

      \[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
    2. Taylor expanded around 0 0.5

      \[\leadsto \left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\color{blue}{3.0 \cdot \left(z \cdot y\right)}}\]

    if -1.359072682814032e+24 < (* z 3.0) < 3.1551391233930085e-79

    1. Initial program 10.8

      \[\left(x - \frac{y}{z \cdot 3.0}\right) + \frac{t}{\left(z \cdot 3.0\right) \cdot y}\]
    2. Using strategy rm
    3. Applied associate-/r*3.3

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, x, -\frac{y}{3.0} \cdot \frac{1}{z}\right) + \left(\mathsf{fma}\left(-\frac{y}{3.0}, \frac{1}{z}, \frac{y}{3.0} \cdot \frac{1}{z}\right) + \frac{\frac{t}{z \cdot 3.0}}{y}\right)}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity3.3

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

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3.0} \cdot \frac{1}{z}\right) + \left(\mathsf{fma}\left(-\frac{y}{3.0}, \frac{1}{z}, \frac{y}{3.0} \cdot \frac{1}{z}\right) + \frac{\frac{\color{blue}{1 \cdot t}}{z \cdot 3.0}}{1 \cdot y}\right)\]
    13. Applied times-frac3.3

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3.0} \cdot \frac{1}{z}\right) + \left(\mathsf{fma}\left(-\frac{y}{3.0}, \frac{1}{z}, \frac{y}{3.0} \cdot \frac{1}{z}\right) + \frac{\color{blue}{\frac{1}{z} \cdot \frac{t}{3.0}}}{1 \cdot y}\right)\]
    14. Applied times-frac0.3

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

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3.0} \cdot \frac{1}{z}\right) + \left(\mathsf{fma}\left(-\frac{y}{3.0}, \frac{1}{z}, \frac{y}{3.0} \cdot \frac{1}{z}\right) + \color{blue}{\frac{1}{z}} \cdot \frac{\frac{t}{3.0}}{y}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3.0 \le -1.359072682814032 \cdot 10^{+24}:\\ \;\;\;\;\frac{t}{\left(z \cdot y\right) \cdot 3.0} + \left(x - \frac{y}{z \cdot 3.0}\right)\\ \mathbf{elif}\;z \cdot 3.0 \le 3.1551391233930085 \cdot 10^{-79}:\\ \;\;\;\;\mathsf{fma}\left(1, x, \frac{y}{3.0} \cdot \frac{-1}{z}\right) + \left(\frac{\frac{t}{3.0}}{y} \cdot \frac{1}{z} + \mathsf{fma}\left(-\frac{y}{3.0}, \frac{1}{z}, \frac{1}{z} \cdot \frac{y}{3.0}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\left(z \cdot y\right) \cdot 3.0} + \left(x - \frac{y}{z \cdot 3.0}\right)\\ \end{array}\]

Reproduce

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