Average Error: 19.9 → 15.4
Time: 11.2s
Precision: binary64
\[ \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 := \frac{a}{b \cdot 3}\\ t_2 := z \cdot \left(t \cdot 0.3333333333333333\right)\\ t_3 := \sin y \cdot \sin t_2\\ t_4 := 2 \cdot \sqrt{x}\\ t_5 := \cos y \cdot \cos t_2\\ \mathbf{if}\;z \cdot t \leq -6 \cdot 10^{+104}:\\ \;\;\;\;t_4 - t_1\\ \mathbf{elif}\;z \cdot t \leq 1.5 \cdot 10^{+239}:\\ \;\;\;\;t_4 \cdot \frac{t_5 \cdot t_5 - t_3 \cdot t_3}{t_5 - t_3} - t_1\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{\sqrt{x} \cdot \left(2 \cdot \cos y\right)}\right)}^{3} - t_1\\ \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 (/ a (* b 3.0)))
        (t_2 (* z (* t 0.3333333333333333)))
        (t_3 (* (sin y) (sin t_2)))
        (t_4 (* 2.0 (sqrt x)))
        (t_5 (* (cos y) (cos t_2))))
   (if (<= (* z t) -6e+104)
     (- t_4 t_1)
     (if (<= (* z t) 1.5e+239)
       (- (* t_4 (/ (- (* t_5 t_5) (* t_3 t_3)) (- t_5 t_3))) t_1)
       (- (pow (cbrt (* (sqrt x) (* 2.0 (cos y)))) 3.0) t_1)))))
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 = a / (b * 3.0);
	double t_2 = z * (t * 0.3333333333333333);
	double t_3 = sin(y) * sin(t_2);
	double t_4 = 2.0 * sqrt(x);
	double t_5 = cos(y) * cos(t_2);
	double tmp;
	if ((z * t) <= -6e+104) {
		tmp = t_4 - t_1;
	} else if ((z * t) <= 1.5e+239) {
		tmp = (t_4 * (((t_5 * t_5) - (t_3 * t_3)) / (t_5 - t_3))) - t_1;
	} else {
		tmp = pow(cbrt((sqrt(x) * (2.0 * cos(y)))), 3.0) - t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((2.0 * Math.sqrt(x)) * Math.cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0));
}
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = a / (b * 3.0);
	double t_2 = z * (t * 0.3333333333333333);
	double t_3 = Math.sin(y) * Math.sin(t_2);
	double t_4 = 2.0 * Math.sqrt(x);
	double t_5 = Math.cos(y) * Math.cos(t_2);
	double tmp;
	if ((z * t) <= -6e+104) {
		tmp = t_4 - t_1;
	} else if ((z * t) <= 1.5e+239) {
		tmp = (t_4 * (((t_5 * t_5) - (t_3 * t_3)) / (t_5 - t_3))) - t_1;
	} else {
		tmp = Math.pow(Math.cbrt((Math.sqrt(x) * (2.0 * Math.cos(y)))), 3.0) - t_1;
	}
	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(a / Float64(b * 3.0))
	t_2 = Float64(z * Float64(t * 0.3333333333333333))
	t_3 = Float64(sin(y) * sin(t_2))
	t_4 = Float64(2.0 * sqrt(x))
	t_5 = Float64(cos(y) * cos(t_2))
	tmp = 0.0
	if (Float64(z * t) <= -6e+104)
		tmp = Float64(t_4 - t_1);
	elseif (Float64(z * t) <= 1.5e+239)
		tmp = Float64(Float64(t_4 * Float64(Float64(Float64(t_5 * t_5) - Float64(t_3 * t_3)) / Float64(t_5 - t_3))) - t_1);
	else
		tmp = Float64((cbrt(Float64(sqrt(x) * Float64(2.0 * cos(y)))) ^ 3.0) - t_1);
	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[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(t * 0.3333333333333333), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[y], $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[y], $MachinePrecision] * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -6e+104], N[(t$95$4 - t$95$1), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1.5e+239], N[(N[(t$95$4 * N[(N[(N[(t$95$5 * t$95$5), $MachinePrecision] - N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision] / N[(t$95$5 - t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(N[Power[N[Power[N[(N[Sqrt[x], $MachinePrecision] * N[(2.0 * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] - t$95$1), $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 := \frac{a}{b \cdot 3}\\
t_2 := z \cdot \left(t \cdot 0.3333333333333333\right)\\
t_3 := \sin y \cdot \sin t_2\\
t_4 := 2 \cdot \sqrt{x}\\
t_5 := \cos y \cdot \cos t_2\\
\mathbf{if}\;z \cdot t \leq -6 \cdot 10^{+104}:\\
\;\;\;\;t_4 - t_1\\

\mathbf{elif}\;z \cdot t \leq 1.5 \cdot 10^{+239}:\\
\;\;\;\;t_4 \cdot \frac{t_5 \cdot t_5 - t_3 \cdot t_3}{t_5 - t_3} - t_1\\

\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{\sqrt{x} \cdot \left(2 \cdot \cos y\right)}\right)}^{3} - t_1\\


\end{array}

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

Original19.9
Target17.8
Herbie15.4
\[\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.99999999999999937e104

    1. Initial program 44.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 32.8

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

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

    if -5.99999999999999937e104 < (*.f64 z t) < 1.4999999999999999e239

    1. Initial program 10.2

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

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

    if 1.4999999999999999e239 < (*.f64 z t)

    1. Initial program 53.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 31.4

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

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

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

Reproduce

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