Average Error: 20.7 → 19.2
Time: 17.9s
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}\;y - \frac{z \cdot t}{3} = -\infty \lor \neg \left(y - \frac{z \cdot t}{3} \le 1.009936411466954 \cdot 10^{275}\right):\\ \;\;\;\;\log \left({\left(e^{2 \cdot \sqrt{x}}\right)}^{\left(\mathsf{fma}\left(\cos \left(\frac{z \cdot t}{3}\right), \cos y, \sin y \cdot \sin \left(\frac{z \cdot t}{3}\right)\right)\right)}\right) - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \mathsf{log1p}\left(\sqrt[3]{{\left(\mathsf{expm1}\left(\cos \left(\frac{z \cdot t}{3}\right)\right)\right)}^{3}}\right) - \sin y \cdot \sin \left(-0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right) - \frac{a}{b \cdot 3}\\ \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}\;y - \frac{z \cdot t}{3} = -\infty \lor \neg \left(y - \frac{z \cdot t}{3} \le 1.009936411466954 \cdot 10^{275}\right):\\
\;\;\;\;\log \left({\left(e^{2 \cdot \sqrt{x}}\right)}^{\left(\mathsf{fma}\left(\cos \left(\frac{z \cdot t}{3}\right), \cos y, \sin y \cdot \sin \left(\frac{z \cdot t}{3}\right)\right)\right)}\right) - \frac{a}{b \cdot 3}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r806278 = 2.0;
        double r806279 = x;
        double r806280 = sqrt(r806279);
        double r806281 = r806278 * r806280;
        double r806282 = y;
        double r806283 = z;
        double r806284 = t;
        double r806285 = r806283 * r806284;
        double r806286 = 3.0;
        double r806287 = r806285 / r806286;
        double r806288 = r806282 - r806287;
        double r806289 = cos(r806288);
        double r806290 = r806281 * r806289;
        double r806291 = a;
        double r806292 = b;
        double r806293 = r806292 * r806286;
        double r806294 = r806291 / r806293;
        double r806295 = r806290 - r806294;
        return r806295;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r806296 = y;
        double r806297 = z;
        double r806298 = t;
        double r806299 = r806297 * r806298;
        double r806300 = 3.0;
        double r806301 = r806299 / r806300;
        double r806302 = r806296 - r806301;
        double r806303 = -inf.0;
        bool r806304 = r806302 <= r806303;
        double r806305 = 1.009936411466954e+275;
        bool r806306 = r806302 <= r806305;
        double r806307 = !r806306;
        bool r806308 = r806304 || r806307;
        double r806309 = 2.0;
        double r806310 = x;
        double r806311 = sqrt(r806310);
        double r806312 = r806309 * r806311;
        double r806313 = exp(r806312);
        double r806314 = cos(r806301);
        double r806315 = cos(r806296);
        double r806316 = sin(r806296);
        double r806317 = sin(r806301);
        double r806318 = r806316 * r806317;
        double r806319 = fma(r806314, r806315, r806318);
        double r806320 = pow(r806313, r806319);
        double r806321 = log(r806320);
        double r806322 = a;
        double r806323 = b;
        double r806324 = r806323 * r806300;
        double r806325 = r806322 / r806324;
        double r806326 = r806321 - r806325;
        double r806327 = expm1(r806314);
        double r806328 = 3.0;
        double r806329 = pow(r806327, r806328);
        double r806330 = cbrt(r806329);
        double r806331 = log1p(r806330);
        double r806332 = r806315 * r806331;
        double r806333 = 0.3333333333333333;
        double r806334 = r806298 * r806297;
        double r806335 = r806333 * r806334;
        double r806336 = -r806335;
        double r806337 = sin(r806336);
        double r806338 = r806316 * r806337;
        double r806339 = r806332 - r806338;
        double r806340 = r806312 * r806339;
        double r806341 = r806340 - r806325;
        double r806342 = r806308 ? r806326 : r806341;
        return r806342;
}

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
Herbie19.2
\[\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 (- y (/ (* z t) 3.0)) < -inf.0 or 1.009936411466954e+275 < (- y (/ (* z t) 3.0))

    1. Initial program 53.9

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}\]
    2. Using strategy rm
    3. Applied sub-neg53.9

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos \color{blue}{\left(y + \left(-\frac{z \cdot t}{3}\right)\right)} - \frac{a}{b \cdot 3}\]
    4. Applied cos-sum53.7

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\left(\cos y \cdot \cos \left(-\frac{z \cdot t}{3}\right) - \sin y \cdot \sin \left(-\frac{z \cdot t}{3}\right)\right)} - \frac{a}{b \cdot 3}\]
    5. Simplified53.7

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\color{blue}{\cos y \cdot \cos \left(\frac{z \cdot t}{3}\right)} - \sin y \cdot \sin \left(-\frac{z \cdot t}{3}\right)\right) - \frac{a}{b \cdot 3}\]
    6. Using strategy rm
    7. Applied add-log-exp60.3

      \[\leadsto \color{blue}{\log \left(e^{\left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \cos \left(\frac{z \cdot t}{3}\right) - \sin y \cdot \sin \left(-\frac{z \cdot t}{3}\right)\right)}\right)} - \frac{a}{b \cdot 3}\]
    8. Simplified46.7

      \[\leadsto \log \color{blue}{\left({\left(e^{2 \cdot \sqrt{x}}\right)}^{\left(\mathsf{fma}\left(\cos \left(\frac{z \cdot t}{3}\right), \cos y, \sin y \cdot \sin \left(\frac{z \cdot t}{3}\right)\right)\right)}\right)} - \frac{a}{b \cdot 3}\]

    if -inf.0 < (- y (/ (* z t) 3.0)) < 1.009936411466954e+275

    1. Initial program 14.4

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}\]
    2. Using strategy rm
    3. Applied sub-neg14.4

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos \color{blue}{\left(y + \left(-\frac{z \cdot t}{3}\right)\right)} - \frac{a}{b \cdot 3}\]
    4. Applied cos-sum13.9

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\left(\cos y \cdot \cos \left(-\frac{z \cdot t}{3}\right) - \sin y \cdot \sin \left(-\frac{z \cdot t}{3}\right)\right)} - \frac{a}{b \cdot 3}\]
    5. Simplified13.9

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\color{blue}{\cos y \cdot \cos \left(\frac{z \cdot t}{3}\right)} - \sin y \cdot \sin \left(-\frac{z \cdot t}{3}\right)\right) - \frac{a}{b \cdot 3}\]
    6. Taylor expanded around inf 13.9

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

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(\frac{z \cdot t}{3}\right)\right)\right)} - \sin y \cdot \sin \left(-0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right) - \frac{a}{b \cdot 3}\]
    9. Using strategy rm
    10. Applied add-cbrt-cube13.9

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \mathsf{log1p}\left(\color{blue}{\sqrt[3]{\left(\mathsf{expm1}\left(\cos \left(\frac{z \cdot t}{3}\right)\right) \cdot \mathsf{expm1}\left(\cos \left(\frac{z \cdot t}{3}\right)\right)\right) \cdot \mathsf{expm1}\left(\cos \left(\frac{z \cdot t}{3}\right)\right)}}\right) - \sin y \cdot \sin \left(-0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right) - \frac{a}{b \cdot 3}\]
    11. Simplified13.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y - \frac{z \cdot t}{3} = -\infty \lor \neg \left(y - \frac{z \cdot t}{3} \le 1.009936411466954 \cdot 10^{275}\right):\\ \;\;\;\;\log \left({\left(e^{2 \cdot \sqrt{x}}\right)}^{\left(\mathsf{fma}\left(\cos \left(\frac{z \cdot t}{3}\right), \cos y, \sin y \cdot \sin \left(\frac{z \cdot t}{3}\right)\right)\right)}\right) - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \mathsf{log1p}\left(\sqrt[3]{{\left(\mathsf{expm1}\left(\cos \left(\frac{z \cdot t}{3}\right)\right)\right)}^{3}}\right) - \sin y \cdot \sin \left(-0.333333333333333315 \cdot \left(t \cdot z\right)\right)\right) - \frac{a}{b \cdot 3}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< z -1.379333748723514e+129) (- (* (* 2 (sqrt x)) (cos (- (/ 1 y) (/ (/ 0.3333333333333333 z) t)))) (/ (/ a 3) b)) (if (< z 3.516290613555987e+106) (- (* (* (sqrt x) 2) (cos (- y (* (/ t 3) z)))) (/ (/ a 3) b)) (- (* (cos (- y (/ (/ 0.3333333333333333 z) t))) (* 2 (sqrt x))) (/ (/ a b) 3))))

  (- (* (* 2 (sqrt x)) (cos (- y (/ (* z t) 3)))) (/ a (* b 3))))