?

Average Accuracy: 58.3% → 66.8%
Time: 28.6s
Precision: binary64
Cost: 48840

?

\[\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 := z \cdot \left(t \cdot 0.3333333333333333\right)\\ t_2 := y - t_1\\ t_3 := \frac{a}{3 \cdot b}\\ t_4 := y - \frac{z \cdot t}{3}\\ t_5 := \mathsf{fma}\left(-t, z \cdot 0.3333333333333333, t_1\right)\\ \mathbf{if}\;t_4 \leq -5 \cdot 10^{+246}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos y - t_3\\ \mathbf{elif}\;t_4 \leq 10^{+306}:\\ \;\;\;\;2 \cdot \left(\sqrt{x} \cdot \left(\cos t_2 \cdot \cos t_5 - \sin t_2 \cdot \sin t_5\right)\right) - t_3\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\cos y}^{2} \cdot \left(x \cdot 4\right)} - t_3\\ \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 (* z (* t 0.3333333333333333)))
        (t_2 (- y t_1))
        (t_3 (/ a (* 3.0 b)))
        (t_4 (- y (/ (* z t) 3.0)))
        (t_5 (fma (- t) (* z 0.3333333333333333) t_1)))
   (if (<= t_4 -5e+246)
     (- (* (* 2.0 (sqrt x)) (cos y)) t_3)
     (if (<= t_4 1e+306)
       (-
        (*
         2.0
         (* (sqrt x) (- (* (cos t_2) (cos t_5)) (* (sin t_2) (sin t_5)))))
        t_3)
       (- (sqrt (* (pow (cos y) 2.0) (* x 4.0))) t_3)))))
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 = z * (t * 0.3333333333333333);
	double t_2 = y - t_1;
	double t_3 = a / (3.0 * b);
	double t_4 = y - ((z * t) / 3.0);
	double t_5 = fma(-t, (z * 0.3333333333333333), t_1);
	double tmp;
	if (t_4 <= -5e+246) {
		tmp = ((2.0 * sqrt(x)) * cos(y)) - t_3;
	} else if (t_4 <= 1e+306) {
		tmp = (2.0 * (sqrt(x) * ((cos(t_2) * cos(t_5)) - (sin(t_2) * sin(t_5))))) - t_3;
	} else {
		tmp = sqrt((pow(cos(y), 2.0) * (x * 4.0))) - t_3;
	}
	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)
	t_1 = Float64(z * Float64(t * 0.3333333333333333))
	t_2 = Float64(y - t_1)
	t_3 = Float64(a / Float64(3.0 * b))
	t_4 = Float64(y - Float64(Float64(z * t) / 3.0))
	t_5 = fma(Float64(-t), Float64(z * 0.3333333333333333), t_1)
	tmp = 0.0
	if (t_4 <= -5e+246)
		tmp = Float64(Float64(Float64(2.0 * sqrt(x)) * cos(y)) - t_3);
	elseif (t_4 <= 1e+306)
		tmp = Float64(Float64(2.0 * Float64(sqrt(x) * Float64(Float64(cos(t_2) * cos(t_5)) - Float64(sin(t_2) * sin(t_5))))) - t_3);
	else
		tmp = Float64(sqrt(Float64((cos(y) ^ 2.0) * Float64(x * 4.0))) - t_3);
	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_] := Block[{t$95$1 = N[(z * N[(t * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(a / N[(3.0 * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[((-t) * N[(z * 0.3333333333333333), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[t$95$4, -5e+246], N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision], If[LessEqual[t$95$4, 1e+306], N[(N[(2.0 * N[(N[Sqrt[x], $MachinePrecision] * N[(N[(N[Cos[t$95$2], $MachinePrecision] * N[Cos[t$95$5], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[t$95$2], $MachinePrecision] * N[Sin[t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision], N[(N[Sqrt[N[(N[Power[N[Cos[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(x * 4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - t$95$3), $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}
t_1 := z \cdot \left(t \cdot 0.3333333333333333\right)\\
t_2 := y - t_1\\
t_3 := \frac{a}{3 \cdot b}\\
t_4 := y - \frac{z \cdot t}{3}\\
t_5 := \mathsf{fma}\left(-t, z \cdot 0.3333333333333333, t_1\right)\\
\mathbf{if}\;t_4 \leq -5 \cdot 10^{+246}:\\
\;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos y - t_3\\

\mathbf{elif}\;t_4 \leq 10^{+306}:\\
\;\;\;\;2 \cdot \left(\sqrt{x} \cdot \left(\cos t_2 \cdot \cos t_5 - \sin t_2 \cdot \sin t_5\right)\right) - t_3\\

\mathbf{else}:\\
\;\;\;\;\sqrt{{\cos y}^{2} \cdot \left(x \cdot 4\right)} - t_3\\


\end{array}

Error?

Target

Original58.3%
Target61.9%
Herbie66.8%
\[\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 y (/.f64 (*.f64 z t) 3)) < -4.99999999999999976e246

    1. Initial program 39.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 in z around 0 57.2%

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

    if -4.99999999999999976e246 < (-.f64 y (/.f64 (*.f64 z t) 3)) < 1.00000000000000002e306

    1. Initial program 72.3%

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Simplified72.5%

      \[\leadsto \color{blue}{2 \cdot \left(\sqrt{x} \cdot \cos \left(y - \frac{z}{\frac{3}{t}}\right)\right) - \frac{a}{3 \cdot b}} \]
      Step-by-step derivation

      [Start]72.3

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

      associate-*l* [=>]72.3

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

      fma-neg [=>]72.3

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

      remove-double-neg [<=]72.3

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

      fma-neg [<=]72.3

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

      remove-double-neg [=>]72.3

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

      associate-/l* [=>]72.5

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

      *-commutative [=>]72.5

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

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

      [Start]72.5

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

      *-un-lft-identity [=>]72.5

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

      associate-/r/ [=>]72.5

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

      prod-diff [=>]72.5

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

      *-commutative [<=]72.5

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

      associate-/r/ [<=]72.5

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

      fma-neg [<=]72.5

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

      *-un-lft-identity [<=]72.5

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

      cos-sum [=>]74.5

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

    if 1.00000000000000002e306 < (-.f64 y (/.f64 (*.f64 z t) 3))

    1. Initial program 0.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 32.7%

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

      \[\leadsto \color{blue}{\sqrt{{\cos y}^{2} \cdot \left(x \cdot 4\right)}} - \frac{a}{b \cdot 3} \]
      Step-by-step derivation

      [Start]32.7

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

      add-sqr-sqrt [=>]31.0

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

      sqrt-unprod [=>]34.7

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

      *-commutative [=>]34.7

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

      *-commutative [=>]34.7

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

      swap-sqr [=>]34.7

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

      pow2 [=>]34.7

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

      *-commutative [=>]34.7

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

      *-commutative [=>]34.7

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

      swap-sqr [=>]34.7

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

      add-sqr-sqrt [<=]34.7

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

      metadata-eval [=>]34.7

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

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

Alternatives

Alternative 1
Accuracy58.7%
Cost13897
\[\begin{array}{l} t_1 := \frac{a}{3 \cdot b}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-101} \lor \neg \left(t_1 \leq 5 \cdot 10^{-11}\right):\\ \;\;\;\;2 \cdot \sqrt{x} - t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{x} \cdot \cos y\right)\\ \end{array} \]
Alternative 2
Accuracy63.8%
Cost13504
\[\left(2 \cdot \sqrt{x}\right) \cdot \cos y - a \cdot \frac{0.3333333333333333}{b} \]
Alternative 3
Accuracy63.8%
Cost13504
\[\left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{3 \cdot b} \]
Alternative 4
Accuracy53.4%
Cost6976
\[2 \cdot \sqrt{x} - \frac{a}{3 \cdot b} \]
Alternative 5
Accuracy38.7%
Cost320
\[-0.3333333333333333 \cdot \frac{a}{b} \]
Alternative 6
Accuracy38.8%
Cost320
\[a \cdot \frac{-0.3333333333333333}{b} \]
Alternative 7
Accuracy38.9%
Cost320
\[\frac{a}{b \cdot -3} \]

Error

Reproduce?

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