Average Error: 3.6 → 0.6
Time: 4.4s
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 -5.5803691484772728 \cdot 10^{94} \lor \neg \left(t \le 3.9085465340846999 \cdot 10^{-60}\right):\\ \;\;\;\;\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{t}{\left(z \cdot 3\right) \cdot y}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{\frac{\sqrt{1}}{\frac{z}{1}}}{y \cdot \frac{3}{t}}\\ \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 -5.5803691484772728 \cdot 10^{94} \lor \neg \left(t \le 3.9085465340846999 \cdot 10^{-60}\right):\\
\;\;\;\;\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{t}{\left(z \cdot 3\right) \cdot y}\right)\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r718060 = x;
        double r718061 = y;
        double r718062 = z;
        double r718063 = 3.0;
        double r718064 = r718062 * r718063;
        double r718065 = r718061 / r718064;
        double r718066 = r718060 - r718065;
        double r718067 = t;
        double r718068 = r718064 * r718061;
        double r718069 = r718067 / r718068;
        double r718070 = r718066 + r718069;
        return r718070;
}

double f(double x, double y, double z, double t) {
        double r718071 = t;
        double r718072 = -5.580369148477273e+94;
        bool r718073 = r718071 <= r718072;
        double r718074 = 3.9085465340847e-60;
        bool r718075 = r718071 <= r718074;
        double r718076 = !r718075;
        bool r718077 = r718073 || r718076;
        double r718078 = 1.0;
        double r718079 = x;
        double r718080 = y;
        double r718081 = 3.0;
        double r718082 = r718080 / r718081;
        double r718083 = z;
        double r718084 = r718078 / r718083;
        double r718085 = r718082 * r718084;
        double r718086 = -r718085;
        double r718087 = fma(r718078, r718079, r718086);
        double r718088 = -r718082;
        double r718089 = r718088 + r718082;
        double r718090 = r718083 * r718081;
        double r718091 = r718090 * r718080;
        double r718092 = r718071 / r718091;
        double r718093 = fma(r718084, r718089, r718092);
        double r718094 = r718087 + r718093;
        double r718095 = r718080 / r718083;
        double r718096 = r718095 / r718081;
        double r718097 = r718079 - r718096;
        double r718098 = sqrt(r718078);
        double r718099 = r718083 / r718078;
        double r718100 = r718098 / r718099;
        double r718101 = r718081 / r718071;
        double r718102 = r718080 * r718101;
        double r718103 = r718100 / r718102;
        double r718104 = r718097 + r718103;
        double r718105 = r718077 ? r718094 : r718104;
        return r718105;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original3.6
Target1.8
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 < -5.580369148477273e+94 or 3.9085465340847e-60 < 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)}\]

    if -5.580369148477273e+94 < t < 3.9085465340847e-60

    1. Initial program 5.4

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

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

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{\color{blue}{\frac{1}{\frac{z \cdot 3}{t}}}}{y}\]
    6. Using strategy rm
    7. Applied associate-/r*1.2

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

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

      \[\leadsto \left(x - \frac{\frac{y}{z}}{3}\right) + \frac{\frac{1}{\color{blue}{\frac{z}{1} \cdot \frac{3}{t}}}}{y}\]
    11. Applied add-sqr-sqrt1.2

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

      \[\leadsto \left(x - \frac{\frac{y}{z}}{3}\right) + \frac{\color{blue}{\frac{\sqrt{1}}{\frac{z}{1}} \cdot \frac{\sqrt{1}}{\frac{3}{t}}}}{y}\]
    13. Applied associate-/l*0.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -5.5803691484772728 \cdot 10^{94} \lor \neg \left(t \le 3.9085465340846999 \cdot 10^{-60}\right):\\ \;\;\;\;\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{t}{\left(z \cdot 3\right) \cdot y}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{\frac{\sqrt{1}}{\frac{z}{1}}}{y \cdot \frac{3}{t}}\\ \end{array}\]

Reproduce

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