Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, A

Percentage Accurate: 94.7% → 94.7%
Time: 1.9s
Alternatives: 6
Speedup: 1.0×

Specification

?
\[\mathsf{TRUE}\left(\right)\]
\[\begin{array}{l} \\ \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* 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) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
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
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);
}
def code(x, y, z, t, a, b):
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
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 tmp = code(x, y, z, t, a, b)
	tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
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]
\begin{array}{l}

\\
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 94.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* 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) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
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
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);
}
def code(x, y, z, t, a, b):
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
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 tmp = code(x, y, z, t, a, b)
	tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
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]
\begin{array}{l}

\\
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\end{array}

Alternative 1: 94.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* 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) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
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
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);
}
def code(x, y, z, t, a, b):
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
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 tmp = code(x, y, z, t, a, b)
	tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
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]
\begin{array}{l}

\\
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\end{array}
Derivation
  1. Initial program 95.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. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 83.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\ t_2 := x \cdot 2 - t\_1\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+201}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-42}:\\ \;\;\;\;x \cdot 2 + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* (* y 9.0) z) t)) (t_2 (- (* x 2.0) t_1)))
   (if (<= t_1 -1e+201)
     t_2
     (if (<= t_1 5e-42) (+ (* x 2.0) (* (* a 27.0) b)) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = ((y * 9.0) * z) * t;
	double t_2 = (x * 2.0) - t_1;
	double tmp;
	if (t_1 <= -1e+201) {
		tmp = t_2;
	} else if (t_1 <= 5e-42) {
		tmp = (x * 2.0) + ((a * 27.0) * b);
	} else {
		tmp = t_2;
	}
	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
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = ((y * 9.0d0) * z) * t
    t_2 = (x * 2.0d0) - t_1
    if (t_1 <= (-1d+201)) then
        tmp = t_2
    else if (t_1 <= 5d-42) then
        tmp = (x * 2.0d0) + ((a * 27.0d0) * b)
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = ((y * 9.0) * z) * t;
	double t_2 = (x * 2.0) - t_1;
	double tmp;
	if (t_1 <= -1e+201) {
		tmp = t_2;
	} else if (t_1 <= 5e-42) {
		tmp = (x * 2.0) + ((a * 27.0) * b);
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = ((y * 9.0) * z) * t
	t_2 = (x * 2.0) - t_1
	tmp = 0
	if t_1 <= -1e+201:
		tmp = t_2
	elif t_1 <= 5e-42:
		tmp = (x * 2.0) + ((a * 27.0) * b)
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(Float64(y * 9.0) * z) * t)
	t_2 = Float64(Float64(x * 2.0) - t_1)
	tmp = 0.0
	if (t_1 <= -1e+201)
		tmp = t_2;
	elseif (t_1 <= 5e-42)
		tmp = Float64(Float64(x * 2.0) + Float64(Float64(a * 27.0) * b));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = ((y * 9.0) * z) * t;
	t_2 = (x * 2.0) - t_1;
	tmp = 0.0;
	if (t_1 <= -1e+201)
		tmp = t_2;
	elseif (t_1 <= 5e-42)
		tmp = (x * 2.0) + ((a * 27.0) * b);
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 2.0), $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+201], t$95$2, If[LessEqual[t$95$1, 5e-42], N[(N[(x * 2.0), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\
t_2 := x \cdot 2 - t\_1\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+201}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-42}:\\
\;\;\;\;x \cdot 2 + \left(a \cdot 27\right) \cdot b\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -1.00000000000000004e201 or 5.00000000000000003e-42 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t)

    1. Initial program 91.5%

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

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

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

    if -1.00000000000000004e201 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 5.00000000000000003e-42

    1. Initial program 98.0%

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

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    4. Applied rewrites88.2%

      \[\leadsto \color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 47.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot 2 \leq -2 \cdot 10^{+44}:\\ \;\;\;\;x \cdot 2\\ \mathbf{elif}\;x \cdot 2 \leq 2.2 \cdot 10^{-22}:\\ \;\;\;\;\left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (* x 2.0) -2e+44)
   (* x 2.0)
   (if (<= (* x 2.0) 2.2e-22) (* (* a 27.0) b) (* x 2.0))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * 2.0) <= -2e+44) {
		tmp = x * 2.0;
	} else if ((x * 2.0) <= 2.2e-22) {
		tmp = (a * 27.0) * b;
	} else {
		tmp = x * 2.0;
	}
	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
    real(8) :: tmp
    if ((x * 2.0d0) <= (-2d+44)) then
        tmp = x * 2.0d0
    else if ((x * 2.0d0) <= 2.2d-22) then
        tmp = (a * 27.0d0) * b
    else
        tmp = x * 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * 2.0) <= -2e+44) {
		tmp = x * 2.0;
	} else if ((x * 2.0) <= 2.2e-22) {
		tmp = (a * 27.0) * b;
	} else {
		tmp = x * 2.0;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if (x * 2.0) <= -2e+44:
		tmp = x * 2.0
	elif (x * 2.0) <= 2.2e-22:
		tmp = (a * 27.0) * b
	else:
		tmp = x * 2.0
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(x * 2.0) <= -2e+44)
		tmp = Float64(x * 2.0);
	elseif (Float64(x * 2.0) <= 2.2e-22)
		tmp = Float64(Float64(a * 27.0) * b);
	else
		tmp = Float64(x * 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if ((x * 2.0) <= -2e+44)
		tmp = x * 2.0;
	elseif ((x * 2.0) <= 2.2e-22)
		tmp = (a * 27.0) * b;
	else
		tmp = x * 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * 2.0), $MachinePrecision], -2e+44], N[(x * 2.0), $MachinePrecision], If[LessEqual[N[(x * 2.0), $MachinePrecision], 2.2e-22], N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision], N[(x * 2.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \leq -2 \cdot 10^{+44}:\\
\;\;\;\;x \cdot 2\\

\mathbf{elif}\;x \cdot 2 \leq 2.2 \cdot 10^{-22}:\\
\;\;\;\;\left(a \cdot 27\right) \cdot b\\

\mathbf{else}:\\
\;\;\;\;x \cdot 2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x #s(literal 2 binary64)) < -2.0000000000000002e44 or 2.2000000000000001e-22 < (*.f64 x #s(literal 2 binary64))

    1. Initial program 93.5%

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

      \[\leadsto \color{blue}{x \cdot \left(\left(2 + 27 \cdot \frac{a \cdot b}{x}\right) - 9 \cdot \frac{t \cdot \left(y \cdot z\right)}{x}\right)} \]
    4. Applied rewrites18.1%

      \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} \]
    5. Taylor expanded in x around inf

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

      \[\leadsto \color{blue}{x \cdot 2} \]

    if -2.0000000000000002e44 < (*.f64 x #s(literal 2 binary64)) < 2.2000000000000001e-22

    1. Initial program 96.5%

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

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

      \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 64.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ x \cdot 2 + \left(a \cdot 27\right) \cdot b \end{array} \]
(FPCore (x y z t a b) :precision binary64 (+ (* x 2.0) (* (* a 27.0) b)))
double code(double x, double y, double z, double t, double a, double b) {
	return (x * 2.0) + ((a * 27.0) * b);
}
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) + ((a * 27.0d0) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return (x * 2.0) + ((a * 27.0) * b);
}
def code(x, y, z, t, a, b):
	return (x * 2.0) + ((a * 27.0) * b)
function code(x, y, z, t, a, b)
	return Float64(Float64(x * 2.0) + Float64(Float64(a * 27.0) * b))
end
function tmp = code(x, y, z, t, a, b)
	tmp = (x * 2.0) + ((a * 27.0) * b);
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * 2.0), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot 2 + \left(a \cdot 27\right) \cdot b
\end{array}
Derivation
  1. Initial program 95.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. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
  4. Applied rewrites62.5%

    \[\leadsto \color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b \]
  5. Add Preprocessing

Alternative 5: 30.3% accurate, 6.2× speedup?

\[\begin{array}{l} \\ x \cdot 2 \end{array} \]
(FPCore (x y z t a b) :precision binary64 (* x 2.0))
double code(double x, double y, double z, double t, double a, double b) {
	return x * 2.0;
}
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
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return x * 2.0;
}
def code(x, y, z, t, a, b):
	return x * 2.0
function code(x, y, z, t, a, b)
	return Float64(x * 2.0)
end
function tmp = code(x, y, z, t, a, b)
	tmp = x * 2.0;
end
code[x_, y_, z_, t_, a_, b_] := N[(x * 2.0), $MachinePrecision]
\begin{array}{l}

\\
x \cdot 2
\end{array}
Derivation
  1. Initial program 95.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. Add Preprocessing
  3. Taylor expanded in x around inf

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

    \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} \]
  5. Taylor expanded in x around inf

    \[\leadsto \color{blue}{x \cdot \left(\left(2 + 27 \cdot \frac{a \cdot b}{x}\right) - 9 \cdot \frac{t \cdot \left(y \cdot z\right)}{x}\right)} \]
  6. Applied rewrites30.5%

    \[\leadsto \color{blue}{x \cdot 2} \]
  7. Add Preprocessing

Alternative 6: 3.2% accurate, 6.2× speedup?

\[\begin{array}{l} \\ a \cdot 27 \end{array} \]
(FPCore (x y z t a b) :precision binary64 (* a 27.0))
double code(double x, double y, double z, double t, double a, double b) {
	return a * 27.0;
}
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 = a * 27.0d0
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return a * 27.0;
}
def code(x, y, z, t, a, b):
	return a * 27.0
function code(x, y, z, t, a, b)
	return Float64(a * 27.0)
end
function tmp = code(x, y, z, t, a, b)
	tmp = a * 27.0;
end
code[x_, y_, z_, t_, a_, b_] := N[(a * 27.0), $MachinePrecision]
\begin{array}{l}

\\
a \cdot 27
\end{array}
Derivation
  1. Initial program 95.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. Add Preprocessing
  3. Taylor expanded in x around 0

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

    \[\leadsto \color{blue}{x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t} \]
  5. Taylor expanded in x around 0

    \[\leadsto -9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)} \]
  6. Applied rewrites3.2%

    \[\leadsto a \cdot \color{blue}{27} \]
  7. Add Preprocessing

Developer Target 1: 95.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (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))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (y < 7.590524218811189e-161) {
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b));
	} else {
		tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * 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
    real(8) :: tmp
    if (y < 7.590524218811189d-161) then
        tmp = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + (a * (27.0d0 * b))
    else
        tmp = ((x * 2.0d0) - (9.0d0 * (y * (t * z)))) + ((a * 27.0d0) * b)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (y < 7.590524218811189e-161) {
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b));
	} else {
		tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if y < 7.590524218811189e-161:
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b))
	else:
		tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b)
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (y < 7.590524218811189e-161)
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(a * Float64(27.0 * b)));
	else
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(9.0 * Float64(y * Float64(t * z)))) + Float64(Float64(a * 27.0) * b));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (y < 7.590524218811189e-161)
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b));
	else
		tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[Less[y, 7.590524218811189e-161], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(9.0 * N[(y * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\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}
\end{array}

Reproduce

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

  :alt
  (! :herbie-platform default (if (< y 7590524218811189/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (- (* x 2) (* (* (* y 9) z) t)) (* a (* 27 b))) (+ (- (* x 2) (* 9 (* y (* t z)))) (* (* a 27) b))))

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