Average Error: 3.1 → 0.7
Time: 9.9s
Precision: binary64
\[[y, z, t] = \mathsf{sort}([y, z, t]) \[a, b] = \mathsf{sort}([a, b]) \\]
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
\[\begin{array}{l} \mathbf{if}\;t \leq 2.1378191698666908 \cdot 10^{-69}:\\ \;\;\;\;\left(x \cdot 2 - \left(t \cdot y\right) \cdot \left(9 \cdot z\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - t \cdot \left(z \cdot \left(y \cdot 9\right)\right)\right) + 27 \cdot \left(a \cdot b\right)\\ \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
(FPCore (x y z t a b)
 :precision binary64
 (if (<= t 2.1378191698666908e-69)
   (+ (- (* x 2.0) (* (* t y) (* 9.0 z))) (* (* a 27.0) b))
   (+ (- (* x 2.0) (* t (* z (* y 9.0)))) (* 27.0 (* a b)))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (t <= 2.1378191698666908e-69) {
		tmp = ((x * 2.0) - ((t * y) * (9.0 * z))) + ((a * 27.0) * b);
	} else {
		tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (27.0 * (a * b));
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
end function
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (t <= 2.1378191698666908d-69) then
        tmp = ((x * 2.0d0) - ((t * y) * (9.0d0 * z))) + ((a * 27.0d0) * b)
    else
        tmp = ((x * 2.0d0) - (t * (z * (y * 9.0d0)))) + (27.0d0 * (a * b))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (t <= 2.1378191698666908e-69) {
		tmp = ((x * 2.0) - ((t * y) * (9.0 * z))) + ((a * 27.0) * b);
	} else {
		tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (27.0 * (a * b));
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
def code(x, y, z, t, a, b):
	tmp = 0
	if t <= 2.1378191698666908e-69:
		tmp = ((x * 2.0) - ((t * y) * (9.0 * z))) + ((a * 27.0) * b)
	else:
		tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (27.0 * (a * b))
	return tmp
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b))
end
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (t <= 2.1378191698666908e-69)
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(Float64(t * y) * Float64(9.0 * z))) + Float64(Float64(a * 27.0) * b));
	else
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(t * Float64(z * Float64(y * 9.0)))) + Float64(27.0 * Float64(a * b)));
	end
	return tmp
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (t <= 2.1378191698666908e-69)
		tmp = ((x * 2.0) - ((t * y) * (9.0 * z))) + ((a * 27.0) * b);
	else
		tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (27.0 * (a * b));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 2.1378191698666908e-69], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(t * y), $MachinePrecision] * N[(9.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(t * N[(z * N[(y * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
\mathbf{if}\;t \leq 2.1378191698666908 \cdot 10^{-69}:\\
\;\;\;\;\left(x \cdot 2 - \left(t \cdot y\right) \cdot \left(9 \cdot z\right)\right) + \left(a \cdot 27\right) \cdot b\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2 - t \cdot \left(z \cdot \left(y \cdot 9\right)\right)\right) + 27 \cdot \left(a \cdot b\right)\\


\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

Original3.1
Target3.6
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;y < 7.590524218811189 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if t < 2.1378191698666908e-69

    1. Initial program 6.6

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Applied egg-rr6.7

      \[\leadsto \left(x \cdot 2 - \color{blue}{{\left(\sqrt[3]{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right)}^{3}}\right) + \left(a \cdot 27\right) \cdot b \]
    3. Applied egg-rr0.2

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(t \cdot y\right) \cdot \left(9 \cdot z\right)}\right) + \left(a \cdot 27\right) \cdot b \]

    if 2.1378191698666908e-69 < t

    1. Initial program 1.1

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Taylor expanded in a around 0 1.0

      \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 2.1378191698666908 \cdot 10^{-69}:\\ \;\;\;\;\left(x \cdot 2 - \left(t \cdot y\right) \cdot \left(9 \cdot z\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - t \cdot \left(z \cdot \left(y \cdot 9\right)\right)\right) + 27 \cdot \left(a \cdot b\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022134 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))

  (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))