Average Error: 21.1 → 16.9
Time: 15.3s
Precision: binary64
\[[z, t]=\mathsf{sort}([z, t])\]
\[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
\[\begin{array}{l} t_1 := 2 \cdot \sqrt{x}\\ t_2 := \frac{a}{3 \cdot b}\\ \mathbf{if}\;\begin{array}{l} t_3 := y - \frac{z \cdot t}{3}\\ t_3 \leq -1.5911678706912745 \cdot 10^{+252} \lor \neg \left(t_3 \leq 8.139337473696087 \cdot 10^{+243}\right) \end{array}:\\ \;\;\;\;t_1 \cdot \cos y - t_2\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(\cos y \cdot \cos \left(\sqrt{\sqrt[3]{0.3333333333333333} \cdot \sqrt[3]{0.3333333333333333}} \cdot \left(\left(\left(z \cdot t\right) \cdot \sqrt{0.3333333333333333}\right) \cdot \sqrt{\sqrt[3]{0.3333333333333333}}\right)\right) - \sin \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right) \cdot \sin y\right) - t_2\\ \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}
t_1 := 2 \cdot \sqrt{x}\\
t_2 := \frac{a}{3 \cdot b}\\
\mathbf{if}\;\begin{array}{l}
t_3 := y - \frac{z \cdot t}{3}\\
t_3 \leq -1.5911678706912745 \cdot 10^{+252} \lor \neg \left(t_3 \leq 8.139337473696087 \cdot 10^{+243}\right)
\end{array}:\\
\;\;\;\;t_1 \cdot \cos y - t_2\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(\cos y \cdot \cos \left(\sqrt{\sqrt[3]{0.3333333333333333} \cdot \sqrt[3]{0.3333333333333333}} \cdot \left(\left(\left(z \cdot t\right) \cdot \sqrt{0.3333333333333333}\right) \cdot \sqrt{\sqrt[3]{0.3333333333333333}}\right)\right) - \sin \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right) \cdot \sin y\right) - t_2\\


\end{array}
(FPCore (x y z t a b)
 :precision binary64
 (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* 2.0 (sqrt x))) (t_2 (/ a (* 3.0 b))))
   (if (let* ((t_3 (- y (/ (* z t) 3.0))))
         (or (<= t_3 -1.5911678706912745e+252)
             (not (<= t_3 8.139337473696087e+243))))
     (- (* t_1 (cos y)) t_2)
     (-
      (*
       t_1
       (-
        (*
         (cos y)
         (cos
          (*
           (sqrt (* (cbrt 0.3333333333333333) (cbrt 0.3333333333333333)))
           (*
            (* (* z t) (sqrt 0.3333333333333333))
            (sqrt (cbrt 0.3333333333333333))))))
        (* (sin (* z (* t -0.3333333333333333))) (sin y))))
      t_2))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((2.0 * sqrt(x)) * cos(y - ((z * t) / 3.0))) - (a / (b * 3.0));
}
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = 2.0 * sqrt(x);
	double t_2 = a / (3.0 * b);
	double t_3 = y - ((z * t) / 3.0);
	double tmp;
	if ((t_3 <= -1.5911678706912745e+252) || !(t_3 <= 8.139337473696087e+243)) {
		tmp = (t_1 * cos(y)) - t_2;
	} else {
		tmp = (t_1 * ((cos(y) * cos(sqrt(cbrt(0.3333333333333333) * cbrt(0.3333333333333333)) * (((z * t) * sqrt(0.3333333333333333)) * sqrt(cbrt(0.3333333333333333))))) - (sin(z * (t * -0.3333333333333333)) * sin(y)))) - t_2;
	}
	return tmp;
}

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

Original21.1
Target19.2
Herbie16.9
\[\begin{array}{l} \mathbf{if}\;z < -1.3793337487235141 \cdot 10^{+129}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(\frac{1}{y} - \frac{\frac{0.3333333333333333}{z}}{t}\right) - \frac{\frac{a}{3}}{b}\\ \mathbf{elif}\;z < 3.516290613555987 \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.3333333333333333}{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 (-.f64 y (/.f64 (*.f64 z t) 3)) < -1.59116787069127455e252 or 8.13933747369608677e243 < (-.f64 y (/.f64 (*.f64 z t) 3))

    1. Initial program 41.9

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

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]

    if -1.59116787069127455e252 < (-.f64 y (/.f64 (*.f64 z t) 3)) < 8.13933747369608677e243

    1. Initial program 13.6

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

      \[\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-sum_binary6413.2

      \[\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.2

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

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

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\cos \left(\color{blue}{\left(\sqrt{0.3333333333333333} \cdot \sqrt{0.3333333333333333}\right)} \cdot \left(t \cdot z\right)\right) \cdot \cos y - \sin \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right) \cdot \sin y\right) - \frac{a}{b \cdot 3} \]
    9. Applied associate-*l*_binary6413.3

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

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\cos \left(\sqrt{0.3333333333333333} \cdot \color{blue}{\left(\left(t \cdot z\right) \cdot \sqrt{0.3333333333333333}\right)}\right) \cdot \cos y - \sin \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right) \cdot \sin y\right) - \frac{a}{b \cdot 3} \]
    11. Using strategy rm
    12. Applied add-cube-cbrt_binary6413.3

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\cos \left(\sqrt{\color{blue}{\left(\sqrt[3]{0.3333333333333333} \cdot \sqrt[3]{0.3333333333333333}\right) \cdot \sqrt[3]{0.3333333333333333}}} \cdot \left(\left(t \cdot z\right) \cdot \sqrt{0.3333333333333333}\right)\right) \cdot \cos y - \sin \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right) \cdot \sin y\right) - \frac{a}{b \cdot 3} \]
    13. Applied sqrt-prod_binary6413.3

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\cos \left(\color{blue}{\left(\sqrt{\sqrt[3]{0.3333333333333333} \cdot \sqrt[3]{0.3333333333333333}} \cdot \sqrt{\sqrt[3]{0.3333333333333333}}\right)} \cdot \left(\left(t \cdot z\right) \cdot \sqrt{0.3333333333333333}\right)\right) \cdot \cos y - \sin \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right) \cdot \sin y\right) - \frac{a}{b \cdot 3} \]
    14. Applied associate-*l*_binary6413.3

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

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \left(\cos \left(\sqrt{\sqrt[3]{0.3333333333333333} \cdot \sqrt[3]{0.3333333333333333}} \cdot \color{blue}{\left(\left(\sqrt{0.3333333333333333} \cdot \left(t \cdot z\right)\right) \cdot \sqrt{\sqrt[3]{0.3333333333333333}}\right)}\right) \cdot \cos y - \sin \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right) \cdot \sin y\right) - \frac{a}{b \cdot 3} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification16.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;y - \frac{z \cdot t}{3} \leq -1.5911678706912745 \cdot 10^{+252} \lor \neg \left(y - \frac{z \cdot t}{3} \leq 8.139337473696087 \cdot 10^{+243}\right):\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{3 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \left(\cos y \cdot \cos \left(\sqrt{\sqrt[3]{0.3333333333333333} \cdot \sqrt[3]{0.3333333333333333}} \cdot \left(\left(\left(z \cdot t\right) \cdot \sqrt{0.3333333333333333}\right) \cdot \sqrt{\sqrt[3]{0.3333333333333333}}\right)\right) - \sin \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right) \cdot \sin y\right) - \frac{a}{3 \cdot b}\\ \end{array} \]

Reproduce

herbie shell --seed 2021204 
(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.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))))