Average Error: 3.8 → 0.6
Time: 5.7s
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.217051937980127926982818674661840685718 \cdot 10^{48}:\\ \;\;\;\;\mathsf{fma}\left(0.3333333333333333148296162562473909929395, \frac{t}{z \cdot y}, x - 0.3333333333333333148296162562473909929395 \cdot \frac{y}{z}\right)\\ \mathbf{elif}\;t \le 1.374392757043330110386267311148160852221 \cdot 10^{-73}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{{\left(3 \cdot \left(z \cdot y\right)\right)}^{1}}\\ \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.217051937980127926982818674661840685718 \cdot 10^{48}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333148296162562473909929395, \frac{t}{z \cdot y}, x - 0.3333333333333333148296162562473909929395 \cdot \frac{y}{z}\right)\\

\mathbf{elif}\;t \le 1.374392757043330110386267311148160852221 \cdot 10^{-73}:\\
\;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r790976 = x;
        double r790977 = y;
        double r790978 = z;
        double r790979 = 3.0;
        double r790980 = r790978 * r790979;
        double r790981 = r790977 / r790980;
        double r790982 = r790976 - r790981;
        double r790983 = t;
        double r790984 = r790980 * r790977;
        double r790985 = r790983 / r790984;
        double r790986 = r790982 + r790985;
        return r790986;
}

double f(double x, double y, double z, double t) {
        double r790987 = t;
        double r790988 = -2.217051937980128e+48;
        bool r790989 = r790987 <= r790988;
        double r790990 = 0.3333333333333333;
        double r790991 = z;
        double r790992 = y;
        double r790993 = r790991 * r790992;
        double r790994 = r790987 / r790993;
        double r790995 = x;
        double r790996 = r790992 / r790991;
        double r790997 = r790990 * r790996;
        double r790998 = r790995 - r790997;
        double r790999 = fma(r790990, r790994, r790998);
        double r791000 = 1.3743927570433301e-73;
        bool r791001 = r790987 <= r791000;
        double r791002 = 3.0;
        double r791003 = r790996 / r791002;
        double r791004 = r790995 - r791003;
        double r791005 = 1.0;
        double r791006 = r791005 / r790991;
        double r791007 = r790987 / r791002;
        double r791008 = r791007 / r790992;
        double r791009 = r791006 * r791008;
        double r791010 = r791004 + r791009;
        double r791011 = r790991 * r791002;
        double r791012 = r790992 / r791011;
        double r791013 = r790995 - r791012;
        double r791014 = r791002 * r790993;
        double r791015 = pow(r791014, r791005);
        double r791016 = r790987 / r791015;
        double r791017 = r791013 + r791016;
        double r791018 = r791001 ? r791010 : r791017;
        double r791019 = r790989 ? r790999 : r791018;
        return r791019;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Split input into 3 regimes
  2. if t < -2.217051937980128e+48

    1. Initial program 0.6

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

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

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

    if -2.217051937980128e+48 < t < 1.3743927570433301e-73

    1. Initial program 6.3

      \[\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.3

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

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

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

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

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

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

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

    if 1.3743927570433301e-73 < t

    1. Initial program 1.0

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied pow11.0

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

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

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

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\color{blue}{{\left(z \cdot 3\right)}^{1}} \cdot {y}^{1}}\]
    7. Applied pow-prod-down1.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -2.217051937980127926982818674661840685718 \cdot 10^{48}:\\ \;\;\;\;\mathsf{fma}\left(0.3333333333333333148296162562473909929395, \frac{t}{z \cdot y}, x - 0.3333333333333333148296162562473909929395 \cdot \frac{y}{z}\right)\\ \mathbf{elif}\;t \le 1.374392757043330110386267311148160852221 \cdot 10^{-73}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{{\left(3 \cdot \left(z \cdot y\right)\right)}^{1}}\\ \end{array}\]

Reproduce

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