?

Average Error: 32.35% → 25.83%
Time: 29.6s
Precision: binary64
Cost: 93640

?

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

\mathbf{elif}\;z \cdot t \leq 10^{+75}:\\
\;\;\;\;t_1 \cdot \frac{\mathsf{fma}\left(\cos y, t_3, t_5\right) \cdot t_6}{t_6} - t_4\\

\mathbf{else}:\\
\;\;\;\;\cos y \cdot t_1 + \frac{\frac{a}{b}}{-3}\\


\end{array}

Error?

Target

Original32.35%
Target29.51%
Herbie25.83%
\[\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) < -1.99999999999999981e215

    1. Initial program 81.14

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

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

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

    if -1.99999999999999981e215 < (*.f64 z t) < 9.99999999999999927e74

    1. Initial program 15.43

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

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

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

      [Start]14.61

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

    if 9.99999999999999927e74 < (*.f64 z t)

    1. Initial program 68.18

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

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

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

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

Alternatives

Alternative 1
Error26.22%
Cost47172
\[\begin{array}{l} t_1 := \frac{a}{3 \cdot b}\\ t_2 := t \cdot \frac{z}{-3}\\ \mathbf{if}\;\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) \leq 5 \cdot 10^{+25}:\\ \;\;\;\;2 \cdot \left(\sqrt{x} \cdot \left(\cos y \cdot \cos t_2 - \sin y \cdot \sin t_2\right)\right) - t_1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\cos y}^{2} \cdot \left(x \cdot 4\right)} - t_1\\ \end{array} \]
Alternative 2
Error25.85%
Cost40776
\[\begin{array}{l} t_1 := 2 \cdot \sqrt{x}\\ t_2 := z \cdot \left(t \cdot 0.3333333333333333\right)\\ t_3 := \frac{a}{3 \cdot b}\\ \mathbf{if}\;z \cdot t \leq -4 \cdot 10^{+219}:\\ \;\;\;\;{\left(\sqrt[3]{2 \cdot \left(\sqrt{x} \cdot \cos y\right)}\right)}^{3} - t_3\\ \mathbf{elif}\;z \cdot t \leq 10^{+75}:\\ \;\;\;\;\left(t_1 \cdot \left(\sin y \cdot \sin t_2\right) + t_1 \cdot \left(\cos y \cdot \cos t_2\right)\right) - t_3\\ \mathbf{else}:\\ \;\;\;\;\cos y \cdot t_1 + \frac{\frac{a}{b}}{-3}\\ \end{array} \]
Alternative 3
Error26.92%
Cost19776
\[\mathsf{fma}\left(2, \sqrt{x} \cdot \cos y, \frac{\frac{a}{-3}}{b}\right) \]
Alternative 4
Error31.37%
Cost14025
\[\begin{array}{l} t_1 := \frac{a}{3 \cdot b}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{-104} \lor \neg \left(t_1 \leq 10^{-80}\right):\\ \;\;\;\;\mathsf{fma}\left(2, \sqrt{x}, \frac{\frac{a}{-3}}{b}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \left(2 \cdot \cos y\right)\\ \end{array} \]
Alternative 5
Error31.39%
Cost13897
\[\begin{array}{l} t_1 := \frac{a}{3 \cdot b}\\ \mathbf{if}\;t_1 \leq -5 \cdot 10^{-104} \lor \neg \left(t_1 \leq 10^{-80}\right):\\ \;\;\;\;2 \cdot \sqrt{x} - t_1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \left(2 \cdot \cos y\right)\\ \end{array} \]
Alternative 6
Error27.02%
Cost13504
\[2 \cdot \left(\sqrt{x} \cdot \cos y\right) + \frac{-0.3333333333333333}{\frac{b}{a}} \]
Alternative 7
Error27.03%
Cost13504
\[\cos y \cdot \left(2 \cdot \sqrt{x}\right) + a \cdot \frac{-0.3333333333333333}{b} \]
Alternative 8
Error26.94%
Cost13504
\[\cos y \cdot \left(2 \cdot \sqrt{x}\right) - \frac{a}{3 \cdot b} \]
Alternative 9
Error39.59%
Cost6976
\[2 \cdot \sqrt{x} - \frac{a}{3 \cdot b} \]
Alternative 10
Error56.5%
Cost320
\[\frac{a}{b} \cdot -0.3333333333333333 \]
Alternative 11
Error56.47%
Cost320
\[a \cdot \frac{-0.3333333333333333}{b} \]
Alternative 12
Error56.37%
Cost320
\[\frac{a}{b \cdot -3} \]
Alternative 13
Error56.36%
Cost320
\[\frac{\frac{a}{-3}}{b} \]

Error

Reproduce?

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