Average Error: 3.7 → 0.6
Time: 19.0s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot 3 \le -650340682119.03857421875:\\ \;\;\;\;\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}, \frac{\frac{t}{z \cdot 3}}{y}\right)\\ \mathbf{elif}\;z \cdot 3 \le 5.531250664679463187888177829139671400627 \cdot 10^{-59}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\ \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}\;z \cdot 3 \le -650340682119.03857421875:\\
\;\;\;\;\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}, \frac{\frac{t}{z \cdot 3}}{y}\right)\\

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

\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 r438683 = x;
        double r438684 = y;
        double r438685 = z;
        double r438686 = 3.0;
        double r438687 = r438685 * r438686;
        double r438688 = r438684 / r438687;
        double r438689 = r438683 - r438688;
        double r438690 = t;
        double r438691 = r438687 * r438684;
        double r438692 = r438690 / r438691;
        double r438693 = r438689 + r438692;
        return r438693;
}

double f(double x, double y, double z, double t) {
        double r438694 = z;
        double r438695 = 3.0;
        double r438696 = r438694 * r438695;
        double r438697 = -650340682119.0386;
        bool r438698 = r438696 <= r438697;
        double r438699 = 1.0;
        double r438700 = x;
        double r438701 = y;
        double r438702 = r438701 / r438694;
        double r438703 = r438702 / r438695;
        double r438704 = -r438703;
        double r438705 = fma(r438699, r438700, r438704);
        double r438706 = r438699 / r438694;
        double r438707 = r438701 / r438695;
        double r438708 = -r438707;
        double r438709 = r438708 + r438707;
        double r438710 = t;
        double r438711 = r438710 / r438696;
        double r438712 = r438711 / r438701;
        double r438713 = fma(r438706, r438709, r438712);
        double r438714 = r438705 + r438713;
        double r438715 = 5.531250664679463e-59;
        bool r438716 = r438696 <= r438715;
        double r438717 = r438701 / r438696;
        double r438718 = r438700 - r438717;
        double r438719 = r438699 / r438696;
        double r438720 = r438710 / r438701;
        double r438721 = r438719 * r438720;
        double r438722 = r438718 + r438721;
        double r438723 = r438695 * r438701;
        double r438724 = r438694 * r438723;
        double r438725 = r438710 / r438724;
        double r438726 = r438718 + r438725;
        double r438727 = r438716 ? r438722 : r438726;
        double r438728 = r438698 ? r438714 : r438727;
        return r438728;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original3.7
Target1.8
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 (* z 3.0) < -650340682119.0386

    1. Initial program 0.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 *-un-lft-identity1.1

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

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

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

      \[\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{\frac{t}{z \cdot 3}}{y}\]
    9. Applied associate-+l+1.1

      \[\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{\frac{t}{z \cdot 3}}{y}\right)}\]
    10. Simplified1.1

      \[\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{\frac{t}{z \cdot 3}}{y}\right)}\]
    11. Using strategy rm
    12. Applied associate-*l/1.1

      \[\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}, \frac{\frac{t}{z \cdot 3}}{y}\right)\]
    13. Simplified1.1

      \[\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}, \frac{\frac{t}{z \cdot 3}}{y}\right)\]

    if -650340682119.0386 < (* z 3.0) < 5.531250664679463e-59

    1. Initial program 11.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-identity11.8

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

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

    if 5.531250664679463e-59 < (* z 3.0)

    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-*l*0.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3 \le -650340682119.03857421875:\\ \;\;\;\;\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}, \frac{\frac{t}{z \cdot 3}}{y}\right)\\ \mathbf{elif}\;z \cdot 3 \le 5.531250664679463187888177829139671400627 \cdot 10^{-59}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\ \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 2019212 +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))))