?

Average Accuracy: 67.9% → 77.0%
Time: 33.5s
Precision: binary64
Cost: 48840

?

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

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

\mathbf{else}:\\
\;\;\;\;t_1 - \frac{a \cdot 0.3333333333333333}{b}\\


\end{array}

Error?

Target

Original67.9%
Target71.5%
Herbie77.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 y (/.f64 (*.f64 z t) 3)) < -1.9999999999999999e247

    1. Initial program 34.2%

      \[\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 58.6%

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

    if -1.9999999999999999e247 < (-.f64 y (/.f64 (*.f64 z t) 3)) < 1.99999999999999991e271

    1. Initial program 79.2%

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

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

      [Start]79.2

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

      associate-*l* [=>]79.2

      \[ \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 [=>]79.2

      \[ \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 [<=]79.2

      \[ \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 [<=]79.2

      \[ \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 [=>]79.2

      \[ 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* [=>]79.2

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

      *-commutative [=>]79.2

      \[ 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-rr82.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 \cdot 0.3333333333333333, z, 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 \cdot 0.3333333333333333, z, z \cdot \left(t \cdot 0.3333333333333333\right)\right)\right)\right)}\right) - \frac{a}{3 \cdot b} \]
      Proof

      [Start]79.2

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

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

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

      div-inv [=>]79.2

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

      prod-diff [=>]79.2

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

      associate-/r/ [<=]79.2

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

      clear-num [<=]79.2

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

      fma-neg [<=]79.2

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

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

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

      cos-sum [=>]81.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(-\frac{1}{\frac{3}{t}}, z, \frac{1}{\frac{3}{t}} \cdot z\right)\right) - \sin \left(y - \frac{z}{\frac{3}{t}}\right) \cdot \sin \left(\mathsf{fma}\left(-\frac{1}{\frac{3}{t}}, z, \frac{1}{\frac{3}{t}} \cdot z\right)\right)\right)}\right) - \frac{a}{3 \cdot b} \]

    if 1.99999999999999991e271 < (-.f64 y (/.f64 (*.f64 z t) 3))

    1. Initial program 22.7%

      \[\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 56.4%

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

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos y - \color{blue}{0.3333333333333333 \cdot \frac{a}{b}} \]
    4. Simplified56.4%

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

      [Start]56.4

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

      associate-*r/ [=>]56.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y - \frac{z \cdot t}{3} \leq -2 \cdot 10^{+247}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{3 \cdot b}\\ \mathbf{elif}\;y - \frac{z \cdot t}{3} \leq 2 \cdot 10^{+271}:\\ \;\;\;\;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 \cdot \left(-0.3333333333333333\right), z, 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 \cdot \left(-0.3333333333333333\right), z, z \cdot \left(t \cdot 0.3333333333333333\right)\right)\right)\right)\right) - \frac{a}{3 \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a \cdot 0.3333333333333333}{b}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy76.8%
Cost48840
\[\begin{array}{l} t_1 := \left(2 \cdot \sqrt{x}\right) \cdot \cos y\\ t_2 := z \cdot \left(t \cdot 0.3333333333333333\right)\\ t_3 := y - t_2\\ t_4 := \frac{a}{3 \cdot b}\\ t_5 := y - \frac{z \cdot t}{3}\\ t_6 := \mathsf{fma}\left(-t, z \cdot 0.3333333333333333, t_2\right)\\ \mathbf{if}\;t_5 \leq -2 \cdot 10^{+181}:\\ \;\;\;\;t_1 - t_4\\ \mathbf{elif}\;t_5 \leq 2 \cdot 10^{+285}:\\ \;\;\;\;2 \cdot \left(\sqrt{x} \cdot \left(\cos t_3 \cdot \cos t_6 - \sin t_3 \cdot \sin t_6\right)\right) - t_4\\ \mathbf{else}:\\ \;\;\;\;t_1 - \frac{a \cdot 0.3333333333333333}{b}\\ \end{array} \]
Alternative 2
Accuracy75.1%
Cost40393
\[\begin{array}{l} t_1 := \frac{a}{3 \cdot b}\\ \mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+258} \lor \neg \left(z \cdot t \leq 5 \cdot 10^{+240}\right):\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos y - t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\sqrt{x} \cdot \mathsf{fma}\left(\sin y, \sin \left(\left(z \cdot t\right) \cdot 0.3333333333333333\right), \cos y \cdot \cos \left(t \cdot \left(z \cdot -0.3333333333333333\right)\right)\right)\right) - t_1\\ \end{array} \]
Alternative 3
Accuracy75.0%
Cost34632
\[\begin{array}{l} t_1 := 2 \cdot \sqrt{x}\\ t_2 := t_1 \cdot \cos y\\ t_3 := z \cdot \left(t \cdot 0.3333333333333333\right)\\ t_4 := \frac{a}{3 \cdot b}\\ t_5 := y - \frac{z \cdot t}{3}\\ \mathbf{if}\;t_5 \leq -2 \cdot 10^{+247}:\\ \;\;\;\;t_2 - t_4\\ \mathbf{elif}\;t_5 \leq 5 \cdot 10^{+295}:\\ \;\;\;\;t_1 \cdot \left(\sin y \cdot \sin t_3 + \cos y \cdot \cos t_3\right) - t_4\\ \mathbf{else}:\\ \;\;\;\;t_2 - \frac{a \cdot 0.3333333333333333}{b}\\ \end{array} \]
Alternative 4
Accuracy69.0%
Cost13896
\[\begin{array}{l} t_1 := \frac{a}{3 \cdot b}\\ t_2 := 2 \cdot \sqrt{x}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{-115}:\\ \;\;\;\;t_2 - t_1\\ \mathbf{elif}\;t_1 \leq 4 \cdot 10^{-115}:\\ \;\;\;\;t_2 \cdot \cos y\\ \mathbf{else}:\\ \;\;\;\;t_2 - \frac{\frac{a}{b}}{3}\\ \end{array} \]
Alternative 5
Accuracy73.8%
Cost13504
\[\left(2 \cdot \sqrt{x}\right) \cdot \cos y - a \cdot \frac{0.3333333333333333}{b} \]
Alternative 6
Accuracy73.9%
Cost13504
\[\left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{3 \cdot b} \]
Alternative 7
Accuracy61.0%
Cost6976
\[2 \cdot \sqrt{x} - \frac{a}{3 \cdot b} \]
Alternative 8
Accuracy44.4%
Cost320
\[-0.3333333333333333 \cdot \frac{a}{b} \]
Alternative 9
Accuracy44.4%
Cost320
\[a \cdot \frac{-0.3333333333333333}{b} \]
Alternative 10
Accuracy44.4%
Cost320
\[\frac{a}{\frac{b}{-0.3333333333333333}} \]

Error

Reproduce?

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