Average Error: 20.7 → 16.8
Time: 29.2s
Precision: 64
\[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot t \le -7.66846435699271048 \cdot 10^{88} \lor \neg \left(z \cdot t \le 6.44411915734533473 \cdot 10^{114}\right):\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{fma}\left({y}^{2}, \frac{-1}{4}, \log 2\right)\right) - \frac{\frac{a}{b}}{3}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right)\right) - \frac{1}{\frac{3}{\frac{a}{b}}}\\ \end{array}\]
\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}
\begin{array}{l}
\mathbf{if}\;z \cdot t \le -7.66846435699271048 \cdot 10^{88} \lor \neg \left(z \cdot t \le 6.44411915734533473 \cdot 10^{114}\right):\\
\;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{fma}\left({y}^{2}, \frac{-1}{4}, \log 2\right)\right) - \frac{\frac{a}{b}}{3}\\

\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right)\right) - \frac{1}{\frac{3}{\frac{a}{b}}}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r528891 = 2.0;
        double r528892 = x;
        double r528893 = sqrt(r528892);
        double r528894 = r528891 * r528893;
        double r528895 = y;
        double r528896 = z;
        double r528897 = t;
        double r528898 = r528896 * r528897;
        double r528899 = 3.0;
        double r528900 = r528898 / r528899;
        double r528901 = r528895 - r528900;
        double r528902 = cos(r528901);
        double r528903 = r528894 * r528902;
        double r528904 = a;
        double r528905 = b;
        double r528906 = r528905 * r528899;
        double r528907 = r528904 / r528906;
        double r528908 = r528903 - r528907;
        return r528908;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r528909 = z;
        double r528910 = t;
        double r528911 = r528909 * r528910;
        double r528912 = -7.66846435699271e+88;
        bool r528913 = r528911 <= r528912;
        double r528914 = 6.444119157345335e+114;
        bool r528915 = r528911 <= r528914;
        double r528916 = !r528915;
        bool r528917 = r528913 || r528916;
        double r528918 = 2.0;
        double r528919 = x;
        double r528920 = sqrt(r528919);
        double r528921 = r528918 * r528920;
        double r528922 = y;
        double r528923 = 2.0;
        double r528924 = pow(r528922, r528923);
        double r528925 = -0.25;
        double r528926 = log(r528923);
        double r528927 = fma(r528924, r528925, r528926);
        double r528928 = expm1(r528927);
        double r528929 = r528921 * r528928;
        double r528930 = a;
        double r528931 = b;
        double r528932 = r528930 / r528931;
        double r528933 = 3.0;
        double r528934 = r528932 / r528933;
        double r528935 = r528929 - r528934;
        double r528936 = 0.3333333333333333;
        double r528937 = r528910 * r528909;
        double r528938 = r528936 * r528937;
        double r528939 = r528922 - r528938;
        double r528940 = cos(r528939);
        double r528941 = log1p(r528940);
        double r528942 = expm1(r528941);
        double r528943 = r528921 * r528942;
        double r528944 = 1.0;
        double r528945 = r528933 / r528932;
        double r528946 = r528944 / r528945;
        double r528947 = r528943 - r528946;
        double r528948 = r528917 ? r528935 : r528947;
        return r528948;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Target

Original20.7
Target18.7
Herbie16.8
\[\begin{array}{l} \mathbf{if}\;z \lt -1.379333748723514 \cdot 10^{129}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(\frac{1}{y} - \frac{\frac{0.333333333333333315}{z}}{t}\right) - \frac{\frac{a}{3}}{b}\\ \mathbf{elif}\;z \lt 3.51629061355598715 \cdot 10^{106}:\\ \;\;\;\;\left(\sqrt{x} \cdot 2\right) \cdot \cos \left(y - \frac{t}{3} \cdot z\right) - \frac{\frac{a}{3}}{b}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y - \frac{\frac{0.333333333333333315}{z}}{t}\right) \cdot \left(2 \cdot \sqrt{x}\right) - \frac{\frac{a}{b}}{3}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (* z t) < -7.66846435699271e+88 or 6.444119157345335e+114 < (* z t)

    1. Initial program 44.7

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}\]
    2. Taylor expanded around inf 44.7

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)} - \frac{a}{b \cdot 3}\]
    3. Using strategy rm
    4. Applied associate-/r*44.8

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right) - \color{blue}{\frac{\frac{a}{b}}{3}}\]
    5. Using strategy rm
    6. Applied expm1-log1p-u44.8

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right)\right)} - \frac{\frac{a}{b}}{3}\]
    7. Taylor expanded around 0 33.5

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\color{blue}{\log 2 - \frac{1}{4} \cdot {y}^{2}}\right) - \frac{\frac{a}{b}}{3}\]
    8. Simplified33.5

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\color{blue}{\mathsf{fma}\left({y}^{2}, \frac{-1}{4}, \log 2\right)}\right) - \frac{\frac{a}{b}}{3}\]

    if -7.66846435699271e+88 < (* z t) < 6.444119157345335e+114

    1. Initial program 7.4

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}\]
    2. Taylor expanded around inf 7.4

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)} - \frac{a}{b \cdot 3}\]
    3. Using strategy rm
    4. Applied associate-/r*7.4

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right) - \color{blue}{\frac{\frac{a}{b}}{3}}\]
    5. Using strategy rm
    6. Applied expm1-log1p-u7.4

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right)\right)} - \frac{\frac{a}{b}}{3}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity7.4

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right)\right) - \frac{\frac{a}{\color{blue}{1 \cdot b}}}{3}\]
    9. Applied *-un-lft-identity7.4

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right)\right) - \frac{\frac{\color{blue}{1 \cdot a}}{1 \cdot b}}{3}\]
    10. Applied times-frac7.4

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right)\right) - \frac{\color{blue}{\frac{1}{1} \cdot \frac{a}{b}}}{3}\]
    11. Applied associate-/l*7.5

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right)\right) - \color{blue}{\frac{\frac{1}{1}}{\frac{3}{\frac{a}{b}}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification16.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \le -7.66846435699271048 \cdot 10^{88} \lor \neg \left(z \cdot t \le 6.44411915734533473 \cdot 10^{114}\right):\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{fma}\left({y}^{2}, \frac{-1}{4}, \log 2\right)\right) - \frac{\frac{a}{b}}{3}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(y - 0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right)\right) - \frac{1}{\frac{3}{\frac{a}{b}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019198 +o rules:numerics
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, K"

  :herbie-target
  (if (< z -1.3793337487235141e+129) (- (* (* 2.0 (sqrt x)) (cos (- (/ 1.0 y) (/ (/ 0.3333333333333333 z) t)))) (/ (/ a 3.0) b)) (if (< z 3.516290613555987e+106) (- (* (* (sqrt x) 2.0) (cos (- y (* (/ t 3.0) z)))) (/ (/ a 3.0) b)) (- (* (cos (- y (/ (/ 0.3333333333333333 z) t))) (* 2.0 (sqrt x))) (/ (/ a b) 3.0))))

  (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))