Average Error: 3.9 → 0.4
Time: 13.8s
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 + \mathsf{fma}\left(t, \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 + \mathsf{fma}\left(t, \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 r732818 = x;
        double r732819 = y;
        double r732820 = z;
        double r732821 = 3.0;
        double r732822 = r732820 * r732821;
        double r732823 = r732819 / r732822;
        double r732824 = r732818 - r732823;
        double r732825 = t;
        double r732826 = r732822 * r732819;
        double r732827 = r732825 / r732826;
        double r732828 = r732824 + r732827;
        return r732828;
}

double f(double x, double y, double z, double t) {
        double r732829 = t;
        double r732830 = -3.1361300744902736e+22;
        bool r732831 = r732829 <= r732830;
        double r732832 = x;
        double r732833 = 1.0;
        double r732834 = z;
        double r732835 = 3.0;
        double r732836 = r732834 * r732835;
        double r732837 = r732833 / r732836;
        double r732838 = y;
        double r732839 = r732837 / r732838;
        double r732840 = r732838 / r732834;
        double r732841 = r732840 / r732835;
        double r732842 = -r732841;
        double r732843 = fma(r732829, r732839, r732842);
        double r732844 = r732832 + r732843;
        double r732845 = 5.460978228047663e+49;
        bool r732846 = r732829 <= r732845;
        double r732847 = r732833 / r732834;
        double r732848 = r732829 / r732835;
        double r732849 = r732848 / r732838;
        double r732850 = fma(r732847, r732849, r732842);
        double r732851 = r732850 + r732832;
        double r732852 = r732838 / r732836;
        double r732853 = r732832 - r732852;
        double r732854 = r732835 * r732838;
        double r732855 = r732834 * r732854;
        double r732856 = r732829 / r732855;
        double r732857 = r732853 + r732856;
        double r732858 = r732846 ? r732851 : r732857;
        double r732859 = r732831 ? r732844 : r732858;
        return r732859;
}

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. Applied fma-neg0.4

      \[\leadsto x + \color{blue}{\mathsf{fma}\left(\frac{t}{1}, \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 + \mathsf{fma}\left(t, \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))))