Average Error: 3.6 → 0.6
Time: 5.3s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;t \le -2.46496578386789013 \cdot 10^{-76} \lor \neg \left(t \le 0.308744324160906747\right):\\ \;\;\;\;\mathsf{fma}\left(1, x, -\frac{\frac{y}{z}}{3}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, 0.333333333333333315 \cdot \frac{t}{z \cdot y}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{0.333333333333333315}{z} \cdot \frac{t}{y}\right)\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;t \le -2.46496578386789013 \cdot 10^{-76} \lor \neg \left(t \le 0.308744324160906747\right):\\
\;\;\;\;\mathsf{fma}\left(1, x, -\frac{\frac{y}{z}}{3}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, 0.333333333333333315 \cdot \frac{t}{z \cdot y}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{0.333333333333333315}{z} \cdot \frac{t}{y}\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r599931 = x;
        double r599932 = y;
        double r599933 = z;
        double r599934 = 3.0;
        double r599935 = r599933 * r599934;
        double r599936 = r599932 / r599935;
        double r599937 = r599931 - r599936;
        double r599938 = t;
        double r599939 = r599935 * r599932;
        double r599940 = r599938 / r599939;
        double r599941 = r599937 + r599940;
        return r599941;
}

double f(double x, double y, double z, double t) {
        double r599942 = t;
        double r599943 = -2.46496578386789e-76;
        bool r599944 = r599942 <= r599943;
        double r599945 = 0.30874432416090675;
        bool r599946 = r599942 <= r599945;
        double r599947 = !r599946;
        bool r599948 = r599944 || r599947;
        double r599949 = 1.0;
        double r599950 = x;
        double r599951 = y;
        double r599952 = z;
        double r599953 = r599951 / r599952;
        double r599954 = 3.0;
        double r599955 = r599953 / r599954;
        double r599956 = -r599955;
        double r599957 = fma(r599949, r599950, r599956);
        double r599958 = r599949 / r599952;
        double r599959 = r599951 / r599954;
        double r599960 = -r599959;
        double r599961 = r599960 + r599959;
        double r599962 = 0.3333333333333333;
        double r599963 = r599952 * r599951;
        double r599964 = r599942 / r599963;
        double r599965 = r599962 * r599964;
        double r599966 = fma(r599958, r599961, r599965);
        double r599967 = r599957 + r599966;
        double r599968 = r599959 * r599958;
        double r599969 = -r599968;
        double r599970 = fma(r599949, r599950, r599969);
        double r599971 = r599962 / r599952;
        double r599972 = r599942 / r599951;
        double r599973 = r599971 * r599972;
        double r599974 = fma(r599958, r599961, r599973);
        double r599975 = r599970 + r599974;
        double r599976 = r599948 ? r599967 : r599975;
        return r599976;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Split input into 2 regimes
  2. if t < -2.46496578386789e-76 or 0.30874432416090675 < t

    1. Initial program 0.8

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.8

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \color{blue}{0.333333333333333315 \cdot \frac{t}{z \cdot y}}\right)\]
    10. Using strategy rm
    11. Applied associate-*l/0.9

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

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

    if -2.46496578386789e-76 < t < 0.30874432416090675

    1. Initial program 6.4

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity6.4

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, 0.333333333333333315 \cdot \color{blue}{\left(\frac{1}{z} \cdot \frac{t}{y}\right)}\right)\]
    13. Applied associate-*r*0.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -2.46496578386789013 \cdot 10^{-76} \lor \neg \left(t \le 0.308744324160906747\right):\\ \;\;\;\;\mathsf{fma}\left(1, x, -\frac{\frac{y}{z}}{3}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, 0.333333333333333315 \cdot \frac{t}{z \cdot y}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{0.333333333333333315}{z} \cdot \frac{t}{y}\right)\\ \end{array}\]

Reproduce

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

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

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