Average Error: 20.7 → 17.9
Time: 15.4s
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}\;\cos \left(y - \frac{z \cdot t}{3}\right) \le 0.99999999987750376:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(1 - \frac{1}{2} \cdot {y}^{2}\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}\;\cos \left(y - \frac{z \cdot t}{3}\right) \le 0.99999999987750376:\\
\;\;\;\;\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}\\

\mathbf{else}:\\
\;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(1 - \frac{1}{2} \cdot {y}^{2}\right) - \frac{a}{b \cdot 3}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r914667 = 2.0;
        double r914668 = x;
        double r914669 = sqrt(r914668);
        double r914670 = r914667 * r914669;
        double r914671 = y;
        double r914672 = z;
        double r914673 = t;
        double r914674 = r914672 * r914673;
        double r914675 = 3.0;
        double r914676 = r914674 / r914675;
        double r914677 = r914671 - r914676;
        double r914678 = cos(r914677);
        double r914679 = r914670 * r914678;
        double r914680 = a;
        double r914681 = b;
        double r914682 = r914681 * r914675;
        double r914683 = r914680 / r914682;
        double r914684 = r914679 - r914683;
        return r914684;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r914685 = y;
        double r914686 = z;
        double r914687 = t;
        double r914688 = r914686 * r914687;
        double r914689 = 3.0;
        double r914690 = r914688 / r914689;
        double r914691 = r914685 - r914690;
        double r914692 = cos(r914691);
        double r914693 = 0.9999999998775038;
        bool r914694 = r914692 <= r914693;
        double r914695 = 2.0;
        double r914696 = x;
        double r914697 = sqrt(r914696);
        double r914698 = r914695 * r914697;
        double r914699 = cos(r914685);
        double r914700 = cos(r914690);
        double r914701 = expm1(r914700);
        double r914702 = 3.0;
        double r914703 = pow(r914701, r914702);
        double r914704 = cbrt(r914703);
        double r914705 = log1p(r914704);
        double r914706 = r914699 * r914705;
        double r914707 = sin(r914685);
        double r914708 = 0.3333333333333333;
        double r914709 = r914687 * r914686;
        double r914710 = r914708 * r914709;
        double r914711 = sin(r914710);
        double r914712 = r914707 * r914711;
        double r914713 = r914706 + r914712;
        double r914714 = r914698 * r914713;
        double r914715 = a;
        double r914716 = b;
        double r914717 = r914716 * r914689;
        double r914718 = r914715 / r914717;
        double r914719 = r914714 - r914718;
        double r914720 = 1.0;
        double r914721 = 0.5;
        double r914722 = 2.0;
        double r914723 = pow(r914685, r914722);
        double r914724 = r914721 * r914723;
        double r914725 = r914720 - r914724;
        double r914726 = r914698 * r914725;
        double r914727 = r914726 - r914718;
        double r914728 = r914694 ? r914719 : r914727;
        return r914728;
}

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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.7
Target18.7
Herbie17.9
\[\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 (cos (- y (/ (* z t) 3.0))) < 0.9999999998775038

    1. Initial program 20.3

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

      \[\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}\]
    4. Taylor expanded around inf 19.6

      \[\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}\]
    5. Using strategy rm
    6. Applied log1p-expm1-u19.6

      \[\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}\]
    7. Using strategy rm
    8. Applied add-cbrt-cube19.6

      \[\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}\]
    9. Simplified19.6

      \[\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}\]

    if 0.9999999998775038 < (cos (- y (/ (* z t) 3.0)))

    1. Initial program 21.5

      \[\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 0 15.0

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\left(1 - \frac{1}{2} \cdot {y}^{2}\right)} - \frac{a}{b \cdot 3}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(y - \frac{z \cdot t}{3}\right) \le 0.99999999987750376:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(1 - \frac{1}{2} \cdot {y}^{2}\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))))