Average Error: 20.3 → 16.0
Time: 30.8s
Precision: binary64
Cost: 40392
\[ \begin{array}{c}[z, t] = \mathsf{sort}([z, t])\\ \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 \leq -5.5 \cdot 10^{+184}:\\ \;\;\;\;2 \cdot \sqrt{x} + \frac{a}{b} \cdot -0.3333333333333333\\ \mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+33}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, \sin \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right), \cos y \cdot \cos \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right)\right) \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({x}^{0.3333333333333333} \cdot \sqrt[3]{4}, \sqrt[3]{2 \cdot \left(\sqrt{x} \cdot \cos y\right)}, \frac{-0.3333333333333333}{\frac{b}{a}}\right)\\ \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
 (if (<= (* z t) -5.5e+184)
   (+ (* 2.0 (sqrt x)) (* (/ a b) -0.3333333333333333))
   (if (<= (* z t) 5e+33)
     (-
      (*
       (fma
        (sin y)
        (sin (* (* z t) 0.3333333333333333))
        (* (cos y) (cos (* z (* t -0.3333333333333333)))))
       (sqrt (* x 4.0)))
      (/ a (* b 3.0)))
     (fma
      (* (pow x 0.3333333333333333) (cbrt 4.0))
      (cbrt (* 2.0 (* (sqrt x) (cos y))))
      (/ -0.3333333333333333 (/ b a))))))
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 tmp;
	if ((z * t) <= -5.5e+184) {
		tmp = (2.0 * sqrt(x)) + ((a / b) * -0.3333333333333333);
	} else if ((z * t) <= 5e+33) {
		tmp = (fma(sin(y), sin(((z * t) * 0.3333333333333333)), (cos(y) * cos((z * (t * -0.3333333333333333))))) * sqrt((x * 4.0))) - (a / (b * 3.0));
	} else {
		tmp = fma((pow(x, 0.3333333333333333) * cbrt(4.0)), cbrt((2.0 * (sqrt(x) * cos(y)))), (-0.3333333333333333 / (b / a)));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(2.0 * sqrt(x)) * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - Float64(a / Float64(b * 3.0)))
end
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(z * t) <= -5.5e+184)
		tmp = Float64(Float64(2.0 * sqrt(x)) + Float64(Float64(a / b) * -0.3333333333333333));
	elseif (Float64(z * t) <= 5e+33)
		tmp = Float64(Float64(fma(sin(y), sin(Float64(Float64(z * t) * 0.3333333333333333)), Float64(cos(y) * cos(Float64(z * Float64(t * -0.3333333333333333))))) * sqrt(Float64(x * 4.0))) - Float64(a / Float64(b * 3.0)));
	else
		tmp = fma(Float64((x ^ 0.3333333333333333) * cbrt(4.0)), cbrt(Float64(2.0 * Float64(sqrt(x) * cos(y)))), Float64(-0.3333333333333333 / Float64(b / a)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(z * t), $MachinePrecision], -5.5e+184], N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(N[(a / b), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+33], N[(N[(N[(N[Sin[y], $MachinePrecision] * N[Sin[N[(N[(z * t), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[y], $MachinePrecision] * N[Cos[N[(z * N[(t * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(x * 4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[x, 0.3333333333333333], $MachinePrecision] * N[Power[4.0, 1/3], $MachinePrecision]), $MachinePrecision] * N[Power[N[(2.0 * N[(N[Sqrt[x], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] + N[(-0.3333333333333333 / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\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 \leq -5.5 \cdot 10^{+184}:\\
\;\;\;\;2 \cdot \sqrt{x} + \frac{a}{b} \cdot -0.3333333333333333\\

\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, \sin \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right), \cos y \cdot \cos \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right)\right) \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({x}^{0.3333333333333333} \cdot \sqrt[3]{4}, \sqrt[3]{2 \cdot \left(\sqrt{x} \cdot \cos y\right)}, \frac{-0.3333333333333333}{\frac{b}{a}}\right)\\


\end{array}

Error

Target

Original20.3
Target18.7
Herbie16.0
\[\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 3 regimes
  2. if (*.f64 z t) < -5.5000000000000002e184

    1. Initial program 49.0

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

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
    3. Taylor expanded in y around 0 33.1

      \[\leadsto \color{blue}{2 \cdot \sqrt{x} - 0.3333333333333333 \cdot \frac{a}{b}} \]

    if -5.5000000000000002e184 < (*.f64 z t) < 4.99999999999999973e33

    1. Initial program 7.9

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Applied egg-rr7.3

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

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

      [Start]7.3

      \[ \left(\sqrt{x \cdot 4} \cdot \left(\cos y \cdot \cos \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right)\right) + \sqrt{x \cdot 4} \cdot \left(\sin y \cdot \sin \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right)\right)\right) - \frac{a}{b \cdot 3} \]

      distribute-lft-out [=>]7.3

      \[ \color{blue}{\sqrt{x \cdot 4} \cdot \left(\cos y \cdot \cos \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right) + \sin y \cdot \sin \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right)\right)} - \frac{a}{b \cdot 3} \]

      *-commutative [=>]7.3

      \[ \color{blue}{\left(\cos y \cdot \cos \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right) + \sin y \cdot \sin \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right)\right) \cdot \sqrt{x \cdot 4}} - \frac{a}{b \cdot 3} \]

      +-commutative [=>]7.3

      \[ \color{blue}{\left(\sin y \cdot \sin \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right) + \cos y \cdot \cos \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right)\right)} \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3} \]

      fma-def [=>]7.3

      \[ \color{blue}{\mathsf{fma}\left(\sin y, \sin \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right), \cos y \cdot \cos \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right)\right)} \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3} \]

      *-commutative [<=]7.3

      \[ \mathsf{fma}\left(\sin y, \sin \color{blue}{\left(0.3333333333333333 \cdot \left(z \cdot t\right)\right)}, \cos y \cdot \cos \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right)\right) \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3} \]

      *-commutative [=>]7.3

      \[ \mathsf{fma}\left(\sin y, \sin \left(0.3333333333333333 \cdot \color{blue}{\left(t \cdot z\right)}\right), \cos y \cdot \cos \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right)\right) \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3} \]

      cos-neg [<=]7.3

      \[ \mathsf{fma}\left(\sin y, \sin \left(0.3333333333333333 \cdot \left(t \cdot z\right)\right), \cos y \cdot \color{blue}{\cos \left(-\left(z \cdot t\right) \cdot 0.3333333333333333\right)}\right) \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3} \]

      distribute-rgt-neg-in [=>]7.3

      \[ \mathsf{fma}\left(\sin y, \sin \left(0.3333333333333333 \cdot \left(t \cdot z\right)\right), \cos y \cdot \cos \color{blue}{\left(\left(z \cdot t\right) \cdot \left(-0.3333333333333333\right)\right)}\right) \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3} \]

      metadata-eval [=>]7.3

      \[ \mathsf{fma}\left(\sin y, \sin \left(0.3333333333333333 \cdot \left(t \cdot z\right)\right), \cos y \cdot \cos \left(\left(z \cdot t\right) \cdot \color{blue}{-0.3333333333333333}\right)\right) \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3} \]

      associate-*l* [=>]7.3

      \[ \mathsf{fma}\left(\sin y, \sin \left(0.3333333333333333 \cdot \left(t \cdot z\right)\right), \cos y \cdot \cos \color{blue}{\left(z \cdot \left(t \cdot -0.3333333333333333\right)\right)}\right) \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3} \]

    if 4.99999999999999973e33 < (*.f64 z t)

    1. Initial program 42.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 in z around 0 33.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{{\cos y}^{2} \cdot \left(x \cdot 4\right)}, \sqrt[3]{2 \cdot \left(\sqrt{x} \cdot \cos y\right)}, \frac{-0.3333333333333333}{\frac{b}{a}}\right)} \]
    4. Taylor expanded in y around 0 33.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -5.5 \cdot 10^{+184}:\\ \;\;\;\;2 \cdot \sqrt{x} + \frac{a}{b} \cdot -0.3333333333333333\\ \mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+33}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, \sin \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right), \cos y \cdot \cos \left(z \cdot \left(t \cdot -0.3333333333333333\right)\right)\right) \cdot \sqrt{x \cdot 4} - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({x}^{0.3333333333333333} \cdot \sqrt[3]{4}, \sqrt[3]{2 \cdot \left(\sqrt{x} \cdot \cos y\right)}, \frac{-0.3333333333333333}{\frac{b}{a}}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error16.0
Cost39816
\[\begin{array}{l} t_1 := \left(z \cdot t\right) \cdot -0.3333333333333333\\ t_2 := 2 \cdot \sqrt{x}\\ \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+180}:\\ \;\;\;\;t_2 + \frac{a}{b} \cdot -0.3333333333333333\\ \mathbf{elif}\;z \cdot t \leq 10^{+121}:\\ \;\;\;\;t_2 \cdot \left(\cos y \cdot \cos t_1 - \sin y \cdot \sin t_1\right) - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({x}^{0.3333333333333333} \cdot \sqrt[3]{4}, \sqrt[3]{2 \cdot \left(\sqrt{x} \cdot \cos y\right)}, \frac{-0.3333333333333333}{\frac{b}{a}}\right)\\ \end{array} \]
Alternative 2
Error16.0
Cost34120
\[\begin{array}{l} t_1 := z \cdot \left(t \cdot 0.3333333333333333\right)\\ \mathbf{if}\;z \cdot t \leq -5.5 \cdot 10^{+184}:\\ \;\;\;\;2 \cdot \sqrt{x} + \frac{a}{b} \cdot -0.3333333333333333\\ \mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+22}:\\ \;\;\;\;2 \cdot \left(\sqrt{x} \cdot \left(\sin y \cdot \sin t_1 + \cos y \cdot \cos t_1\right)\right) - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{x \cdot 4}, \sqrt[3]{2 \cdot \left(\sqrt{x} \cdot \cos y\right)}, \frac{-0.3333333333333333}{\frac{b}{a}}\right)\\ \end{array} \]
Alternative 3
Error16.1
Cost34120
\[\begin{array}{l} t_1 := \left(z \cdot t\right) \cdot -0.3333333333333333\\ t_2 := 2 \cdot \sqrt{x}\\ \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+180}:\\ \;\;\;\;t_2 + \frac{a}{b} \cdot -0.3333333333333333\\ \mathbf{elif}\;z \cdot t \leq 10^{+121}:\\ \;\;\;\;t_2 \cdot \left(\cos y \cdot \cos t_1 - \sin y \cdot \sin t_1\right) - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{x \cdot 4}, \sqrt[3]{2 \cdot \left(\sqrt{x} \cdot \cos y\right)}, \frac{-0.3333333333333333}{\frac{b}{a}}\right)\\ \end{array} \]
Alternative 4
Error16.4
Cost33352
\[\begin{array}{l} t_1 := 2 \cdot \sqrt{x}\\ \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+236}:\\ \;\;\;\;t_1 + \frac{a}{b} \cdot -0.3333333333333333\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+185}:\\ \;\;\;\;t_1 \cdot \cos \left(y - \frac{t}{\frac{3}{z}}\right) - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{x \cdot 4}, \sqrt[3]{2 \cdot \left(\sqrt{x} \cdot \cos y\right)}, \frac{-0.3333333333333333}{\frac{b}{a}}\right)\\ \end{array} \]
Alternative 5
Error16.4
Cost20296
\[\begin{array}{l} t_1 := 2 \cdot \sqrt{x}\\ \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+236}:\\ \;\;\;\;t_1 + \frac{a}{b} \cdot -0.3333333333333333\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+185}:\\ \;\;\;\;t_1 \cdot \cos \left(y - \frac{t}{\frac{3}{z}}\right) - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, \sqrt{x} \cdot \cos y, \frac{\frac{a}{-3}}{b}\right)\\ \end{array} \]
Alternative 6
Error16.5
Cost14408
\[\begin{array}{l} t_1 := \frac{a}{b \cdot 3}\\ t_2 := 2 \cdot \sqrt{x}\\ \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+236}:\\ \;\;\;\;t_2 + \frac{a}{b} \cdot -0.3333333333333333\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+185}:\\ \;\;\;\;t_2 \cdot \cos \left(y - \frac{t}{\frac{3}{z}}\right) - t_1\\ \mathbf{else}:\\ \;\;\;\;t_2 \cdot \cos y - t_1\\ \end{array} \]
Alternative 7
Error20.0
Cost13897
\[\begin{array}{l} t_1 := \frac{a}{b \cdot 3}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-96} \lor \neg \left(t_1 \leq 2 \cdot 10^{-134}\right):\\ \;\;\;\;2 \cdot \sqrt{x} - t_1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \left(2 \cdot \cos y\right)\\ \end{array} \]
Alternative 8
Error16.9
Cost13504
\[\left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{b \cdot 3} \]
Alternative 9
Error25.4
Cost6976
\[2 \cdot \sqrt{x} + \frac{a}{b} \cdot -0.3333333333333333 \]
Alternative 10
Error25.3
Cost6976
\[2 \cdot \sqrt{x} - \frac{a}{b \cdot 3} \]
Alternative 11
Error36.7
Cost320
\[\frac{a}{b} \cdot -0.3333333333333333 \]
Alternative 12
Error36.6
Cost320
\[\frac{-0.3333333333333333}{\frac{b}{a}} \]
Alternative 13
Error36.6
Cost320
\[\frac{a}{\frac{b}{-0.3333333333333333}} \]
Alternative 14
Error36.6
Cost320
\[\frac{a \cdot -0.3333333333333333}{b} \]
Alternative 15
Error36.5
Cost320
\[\frac{\frac{a}{-3}}{b} \]

Error

Reproduce

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