Average Error: 3.9 → 0.4
Time: 14.5s
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 -3.1361300744902736 \cdot 10^{22}:\\ \;\;\;\;x + \left(t \cdot \frac{\frac{1}{z \cdot 3}}{y} - \frac{\frac{y}{z}}{3}\right)\\ \mathbf{elif}\;t \le 5.46097822804766331 \cdot 10^{49}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{z}, \frac{\frac{t}{3}}{y}, -\frac{\frac{y}{z}}{3}\right) + x\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{z \cdot \left(3 \cdot 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 -3.1361300744902736 \cdot 10^{22}:\\
\;\;\;\;x + \left(t \cdot \frac{\frac{1}{z \cdot 3}}{y} - \frac{\frac{y}{z}}{3}\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r684596 = x;
        double r684597 = y;
        double r684598 = z;
        double r684599 = 3.0;
        double r684600 = r684598 * r684599;
        double r684601 = r684597 / r684600;
        double r684602 = r684596 - r684601;
        double r684603 = t;
        double r684604 = r684600 * r684597;
        double r684605 = r684603 / r684604;
        double r684606 = r684602 + r684605;
        return r684606;
}

double f(double x, double y, double z, double t) {
        double r684607 = t;
        double r684608 = -3.1361300744902736e+22;
        bool r684609 = r684607 <= r684608;
        double r684610 = x;
        double r684611 = 1.0;
        double r684612 = z;
        double r684613 = 3.0;
        double r684614 = r684612 * r684613;
        double r684615 = r684611 / r684614;
        double r684616 = y;
        double r684617 = r684615 / r684616;
        double r684618 = r684607 * r684617;
        double r684619 = r684616 / r684612;
        double r684620 = r684619 / r684613;
        double r684621 = r684618 - r684620;
        double r684622 = r684610 + r684621;
        double r684623 = 5.460978228047663e+49;
        bool r684624 = r684607 <= r684623;
        double r684625 = r684611 / r684612;
        double r684626 = r684607 / r684613;
        double r684627 = r684626 / r684616;
        double r684628 = -r684620;
        double r684629 = fma(r684625, r684627, r684628);
        double r684630 = r684629 + r684610;
        double r684631 = r684616 / r684614;
        double r684632 = r684610 - r684631;
        double r684633 = r684613 * r684616;
        double r684634 = r684612 * r684633;
        double r684635 = r684607 / r684634;
        double r684636 = r684632 + r684635;
        double r684637 = r684624 ? r684630 : r684636;
        double r684638 = r684609 ? r684622 : r684637;
        return r684638;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original3.9
Target1.7
Herbie0.4
\[\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 < -3.1361300744902736e+22

    1. Initial program 0.5

      \[\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*2.7

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

      \[\leadsto \color{blue}{\left(x + \left(-\frac{y}{z \cdot 3}\right)\right)} + \frac{\frac{t}{z \cdot 3}}{y}\]
    6. Applied associate-+l+2.7

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

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

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

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

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

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

    if -3.1361300744902736e+22 < t < 5.460978228047663e+49

    1. Initial program 5.8

      \[\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 sub-neg1.1

      \[\leadsto \color{blue}{\left(x + \left(-\frac{y}{z \cdot 3}\right)\right)} + \frac{\frac{t}{z \cdot 3}}{y}\]
    6. Applied associate-+l+1.1

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

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

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

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

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

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

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

    if 5.460978228047663e+49 < t

    1. Initial program 0.6

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

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

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

Reproduce

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