Average Error: 20.6 → 18.3
Time: 24.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.9988949060685164971218341634084936231375:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \cos \left(0.3333333333333333148296162562473909929395 \cdot \left(t \cdot z\right)\right) + \sin y \cdot \mathsf{expm1}\left(\left(\sqrt[3]{\mathsf{log1p}\left(\sin \left(\frac{z \cdot t}{3}\right)\right)} \cdot \sqrt[3]{\mathsf{log1p}\left(\sin \left(\frac{z \cdot t}{3}\right)\right)}\right) \cdot \sqrt[3]{\mathsf{log1p}\left(\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 \mathsf{fma}\left(\frac{-1}{2}, {y}^{2}, 1\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.9988949060685164971218341634084936231375:\\
\;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \cos \left(0.3333333333333333148296162562473909929395 \cdot \left(t \cdot z\right)\right) + \sin y \cdot \mathsf{expm1}\left(\left(\sqrt[3]{\mathsf{log1p}\left(\sin \left(\frac{z \cdot t}{3}\right)\right)} \cdot \sqrt[3]{\mathsf{log1p}\left(\sin \left(\frac{z \cdot t}{3}\right)\right)}\right) \cdot \sqrt[3]{\mathsf{log1p}\left(\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 \mathsf{fma}\left(\frac{-1}{2}, {y}^{2}, 1\right) - \frac{a}{b \cdot 3}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r482678 = 2.0;
        double r482679 = x;
        double r482680 = sqrt(r482679);
        double r482681 = r482678 * r482680;
        double r482682 = y;
        double r482683 = z;
        double r482684 = t;
        double r482685 = r482683 * r482684;
        double r482686 = 3.0;
        double r482687 = r482685 / r482686;
        double r482688 = r482682 - r482687;
        double r482689 = cos(r482688);
        double r482690 = r482681 * r482689;
        double r482691 = a;
        double r482692 = b;
        double r482693 = r482692 * r482686;
        double r482694 = r482691 / r482693;
        double r482695 = r482690 - r482694;
        return r482695;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r482696 = y;
        double r482697 = z;
        double r482698 = t;
        double r482699 = r482697 * r482698;
        double r482700 = 3.0;
        double r482701 = r482699 / r482700;
        double r482702 = r482696 - r482701;
        double r482703 = cos(r482702);
        double r482704 = 0.9988949060685165;
        bool r482705 = r482703 <= r482704;
        double r482706 = 2.0;
        double r482707 = x;
        double r482708 = sqrt(r482707);
        double r482709 = r482706 * r482708;
        double r482710 = cos(r482696);
        double r482711 = 0.3333333333333333;
        double r482712 = r482698 * r482697;
        double r482713 = r482711 * r482712;
        double r482714 = cos(r482713);
        double r482715 = r482710 * r482714;
        double r482716 = sin(r482696);
        double r482717 = sin(r482701);
        double r482718 = log1p(r482717);
        double r482719 = cbrt(r482718);
        double r482720 = r482719 * r482719;
        double r482721 = r482720 * r482719;
        double r482722 = expm1(r482721);
        double r482723 = r482716 * r482722;
        double r482724 = r482715 + r482723;
        double r482725 = r482709 * r482724;
        double r482726 = a;
        double r482727 = b;
        double r482728 = r482727 * r482700;
        double r482729 = r482726 / r482728;
        double r482730 = r482725 - r482729;
        double r482731 = -0.5;
        double r482732 = 2.0;
        double r482733 = pow(r482696, r482732);
        double r482734 = 1.0;
        double r482735 = fma(r482731, r482733, r482734);
        double r482736 = r482709 * r482735;
        double r482737 = r482736 - r482729;
        double r482738 = r482705 ? r482730 : r482737;
        return r482738;
}

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.6
Target19.0
Herbie18.3
\[\begin{array}{l} \mathbf{if}\;z \lt -1.379333748723514136852843173740882251575 \cdot 10^{129}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(\frac{1}{y} - \frac{\frac{0.3333333333333333148296162562473909929395}{z}}{t}\right) - \frac{\frac{a}{3}}{b}\\ \mathbf{elif}\;z \lt 3.516290613555987147199887107423758623887 \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.3333333333333333148296162562473909929395}{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.9988949060685165

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

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

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \cos \left(0.3333333333333333148296162562473909929395 \cdot \left(t \cdot z\right)\right) + \sin y \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\frac{z \cdot t}{3}\right)\right)\right)}\right) - \frac{a}{b \cdot 3}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt19.7

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

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

    1. Initial program 21.1

      \[\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 16.1

      \[\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. Simplified16.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos \left(y - \frac{z \cdot t}{3}\right) \le 0.9988949060685164971218341634084936231375:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \cos \left(0.3333333333333333148296162562473909929395 \cdot \left(t \cdot z\right)\right) + \sin y \cdot \mathsf{expm1}\left(\left(\sqrt[3]{\mathsf{log1p}\left(\sin \left(\frac{z \cdot t}{3}\right)\right)} \cdot \sqrt[3]{\mathsf{log1p}\left(\sin \left(\frac{z \cdot t}{3}\right)\right)}\right) \cdot \sqrt[3]{\mathsf{log1p}\left(\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 \mathsf{fma}\left(\frac{-1}{2}, {y}^{2}, 1\right) - \frac{a}{b \cdot 3}\\ \end{array}\]

Reproduce

herbie shell --seed 2019235 +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.379333748723514e129) (- (* (* 2 (sqrt x)) (cos (- (/ 1 y) (/ (/ 0.333333333333333315 z) t)))) (/ (/ a 3) b)) (if (< z 3.51629061355598715e106) (- (* (* (sqrt x) 2) (cos (- y (* (/ t 3) z)))) (/ (/ a 3) b)) (- (* (cos (- y (/ (/ 0.333333333333333315 z) t))) (* 2 (sqrt x))) (/ (/ a b) 3))))

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