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

Percentage Accurate: 95.0% → 98.3%
Time: 14.6s
Alternatives: 11
Speedup: 0.9×

Specification

?
\[\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 11 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: 95.0% 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: 98.3% accurate, 0.1× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-137}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - t \cdot \left(z \cdot \left(y \cdot 9\right)\right)\right) + b \cdot \left(a \cdot 27\right)\\ \end{array} \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (<= z -5e-137)
   (fma a (* 27.0 b) (fma x 2.0 (* y (* t (* z -9.0)))))
   (+ (- (* x 2.0) (* t (* z (* y 9.0)))) (* b (* a 27.0)))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (z <= -5e-137) {
		tmp = fma(a, (27.0 * b), fma(x, 2.0, (y * (t * (z * -9.0)))));
	} else {
		tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0));
	}
	return tmp;
}
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (z <= -5e-137)
		tmp = fma(a, Float64(27.0 * b), fma(x, 2.0, Float64(y * Float64(t * Float64(z * -9.0)))));
	else
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(t * Float64(z * Float64(y * 9.0)))) + Float64(b * Float64(a * 27.0)));
	end
	return tmp
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -5e-137], N[(a * N[(27.0 * b), $MachinePrecision] + N[(x * 2.0 + N[(y * N[(t * N[(z * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(t * N[(z * N[(y * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-137}:\\
\;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.00000000000000001e-137

    1. Initial program 95.9%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. +-commutative95.9%

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

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t} \]
      3. cancel-sign-sub-inv95.9%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{t \cdot \left(-\left(y \cdot 9\right) \cdot z\right)} \]
      5. distribute-rgt-neg-out95.9%

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(-z\right)\right)} \]
      6. associate-*r*97.8%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{\left(\left(y \cdot 9\right) \cdot t\right)} \cdot \left(-z\right) \]
      8. distribute-rgt-neg-in97.8%

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

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

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
      11. associate-*l*97.8%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
      13. fma-neg97.8%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \color{blue}{\mathsf{fma}\left(x, 2, -\left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)}\right) \]
      14. associate-*l*97.8%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{\left(y \cdot \left(9 \cdot t\right)\right)} \cdot z\right)\right) \]
      15. *-commutative97.8%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\left(y \cdot \color{blue}{\left(t \cdot 9\right)}\right) \cdot z\right)\right) \]
      16. associate-*r*95.8%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{y \cdot \left(\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
      17. distribute-rgt-neg-in95.8%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, \color{blue}{y \cdot \left(-\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
    3. Simplified95.9%

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

    if -5.00000000000000001e-137 < z

    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 \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.2%

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

Alternative 2: 82.0% accurate, 0.5× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} t_1 := b \cdot \left(a \cdot 27\right)\\ t_2 := t \cdot \left(z \cdot y\right)\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+101} \lor \neg \left(t_1 \leq 7 \cdot 10^{-80} \lor \neg \left(t_1 \leq 5 \cdot 10^{-46}\right) \land t_1 \leq 4 \cdot 10^{+98}\right):\\ \;\;\;\;t_1 + -9 \cdot t_2\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 - 9 \cdot t_2\\ \end{array} \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* b (* a 27.0))) (t_2 (* t (* z y))))
   (if (or (<= t_1 -2e+101)
           (not (or (<= t_1 7e-80) (and (not (<= t_1 5e-46)) (<= t_1 4e+98)))))
     (+ t_1 (* -9.0 t_2))
     (- (* x 2.0) (* 9.0 t_2)))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = b * (a * 27.0);
	double t_2 = t * (z * y);
	double tmp;
	if ((t_1 <= -2e+101) || !((t_1 <= 7e-80) || (!(t_1 <= 5e-46) && (t_1 <= 4e+98)))) {
		tmp = t_1 + (-9.0 * t_2);
	} else {
		tmp = (x * 2.0) - (9.0 * t_2);
	}
	return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = b * (a * 27.0d0)
    t_2 = t * (z * y)
    if ((t_1 <= (-2d+101)) .or. (.not. (t_1 <= 7d-80) .or. (.not. (t_1 <= 5d-46)) .and. (t_1 <= 4d+98))) then
        tmp = t_1 + ((-9.0d0) * t_2)
    else
        tmp = (x * 2.0d0) - (9.0d0 * t_2)
    end if
    code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = b * (a * 27.0);
	double t_2 = t * (z * y);
	double tmp;
	if ((t_1 <= -2e+101) || !((t_1 <= 7e-80) || (!(t_1 <= 5e-46) && (t_1 <= 4e+98)))) {
		tmp = t_1 + (-9.0 * t_2);
	} else {
		tmp = (x * 2.0) - (9.0 * t_2);
	}
	return tmp;
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	t_1 = b * (a * 27.0)
	t_2 = t * (z * y)
	tmp = 0
	if (t_1 <= -2e+101) or not ((t_1 <= 7e-80) or (not (t_1 <= 5e-46) and (t_1 <= 4e+98))):
		tmp = t_1 + (-9.0 * t_2)
	else:
		tmp = (x * 2.0) - (9.0 * t_2)
	return tmp
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(b * Float64(a * 27.0))
	t_2 = Float64(t * Float64(z * y))
	tmp = 0.0
	if ((t_1 <= -2e+101) || !((t_1 <= 7e-80) || (!(t_1 <= 5e-46) && (t_1 <= 4e+98))))
		tmp = Float64(t_1 + Float64(-9.0 * t_2));
	else
		tmp = Float64(Float64(x * 2.0) - Float64(9.0 * t_2));
	end
	return tmp
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = b * (a * 27.0);
	t_2 = t * (z * y);
	tmp = 0.0;
	if ((t_1 <= -2e+101) || ~(((t_1 <= 7e-80) || (~((t_1 <= 5e-46)) && (t_1 <= 4e+98)))))
		tmp = t_1 + (-9.0 * t_2);
	else
		tmp = (x * 2.0) - (9.0 * t_2);
	end
	tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+101], N[Not[Or[LessEqual[t$95$1, 7e-80], And[N[Not[LessEqual[t$95$1, 5e-46]], $MachinePrecision], LessEqual[t$95$1, 4e+98]]]], $MachinePrecision]], N[(t$95$1 + N[(-9.0 * t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(x * 2.0), $MachinePrecision] - N[(9.0 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := b \cdot \left(a \cdot 27\right)\\
t_2 := t \cdot \left(z \cdot y\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+101} \lor \neg \left(t_1 \leq 7 \cdot 10^{-80} \lor \neg \left(t_1 \leq 5 \cdot 10^{-46}\right) \land t_1 \leq 4 \cdot 10^{+98}\right):\\
\;\;\;\;t_1 + -9 \cdot t_2\\

\mathbf{else}:\\
\;\;\;\;x \cdot 2 - 9 \cdot t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 a 27) b) < -2e101 or 7.00000000000000029e-80 < (*.f64 (*.f64 a 27) b) < 4.99999999999999992e-46 or 3.99999999999999999e98 < (*.f64 (*.f64 a 27) b)

    1. Initial program 97.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. Step-by-step derivation
      1. pow197.6%

        \[\leadsto \left(x \cdot 2 - \color{blue}{{\left(\left(y \cdot 9\right) \cdot z\right)}^{1}} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      2. associate-*l*97.6%

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

      \[\leadsto \left(x \cdot 2 - \color{blue}{{\left(y \cdot \left(9 \cdot z\right)\right)}^{1}} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    4. Taylor expanded in x around 0 92.2%

      \[\leadsto \color{blue}{-9 \cdot \left(y \cdot \left(t \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    5. Step-by-step derivation
      1. associate-*r*92.1%

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

        \[\leadsto -9 \cdot \left(\color{blue}{\left(t \cdot y\right)} \cdot z\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*93.2%

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

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

    if -2e101 < (*.f64 (*.f64 a 27) b) < 7.00000000000000029e-80 or 4.99999999999999992e-46 < (*.f64 (*.f64 a 27) b) < 3.99999999999999999e98

    1. Initial program 96.9%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. sub-neg96.9%

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

        \[\leadsto \left(x \cdot 2 + \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*97.0%

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

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

        \[\leadsto \left(x \cdot 2 + \left(-\color{blue}{\left(z \cdot 9\right)} \cdot y\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      6. cancel-sign-sub-inv97.0%

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

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

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

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      10. associate-*l*94.7%

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]
      11. associate-*l*94.7%

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

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

      \[\leadsto \color{blue}{2 \cdot x - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u63.2%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(t \cdot z\right)\right)\right)} \]
      2. expm1-udef59.4%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left(t \cdot z\right)\right)} - 1\right)} \]
      3. *-commutative59.4%

        \[\leadsto 2 \cdot x - 9 \cdot \left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\left(z \cdot t\right)}\right)} - 1\right) \]
    6. Applied egg-rr59.4%

      \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left(z \cdot t\right)\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def63.2%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(z \cdot t\right)\right)\right)} \]
      2. expm1-log1p86.7%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(y \cdot \left(z \cdot t\right)\right)} \]
      3. *-commutative86.7%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(\left(z \cdot t\right) \cdot y\right)} \]
      4. *-commutative86.7%

        \[\leadsto 2 \cdot x - 9 \cdot \left(\color{blue}{\left(t \cdot z\right)} \cdot y\right) \]
      5. associate-*l*88.7%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(t \cdot \left(z \cdot y\right)\right)} \]
      6. *-commutative88.7%

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

      \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot \left(a \cdot 27\right) \leq -2 \cdot 10^{+101} \lor \neg \left(b \cdot \left(a \cdot 27\right) \leq 7 \cdot 10^{-80} \lor \neg \left(b \cdot \left(a \cdot 27\right) \leq 5 \cdot 10^{-46}\right) \land b \cdot \left(a \cdot 27\right) \leq 4 \cdot 10^{+98}\right):\\ \;\;\;\;b \cdot \left(a \cdot 27\right) + -9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\\ \end{array} \]

Alternative 3: 82.0% accurate, 0.5× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} t_1 := t \cdot \left(z \cdot y\right)\\ t_2 := b \cdot \left(a \cdot 27\right)\\ t_3 := x \cdot 2 - 9 \cdot t_1\\ t_4 := a \cdot \left(27 \cdot b\right) + y \cdot \left(-9 \cdot \left(z \cdot t\right)\right)\\ \mathbf{if}\;t_2 \leq -2 \cdot 10^{+101}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_2 \leq 7 \cdot 10^{-80}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{-39}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+98}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2 + -9 \cdot t_1\\ \end{array} \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* t (* z y)))
        (t_2 (* b (* a 27.0)))
        (t_3 (- (* x 2.0) (* 9.0 t_1)))
        (t_4 (+ (* a (* 27.0 b)) (* y (* -9.0 (* z t))))))
   (if (<= t_2 -2e+101)
     t_4
     (if (<= t_2 7e-80)
       t_3
       (if (<= t_2 5e-39) t_4 (if (<= t_2 4e+98) t_3 (+ t_2 (* -9.0 t_1))))))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = t * (z * y);
	double t_2 = b * (a * 27.0);
	double t_3 = (x * 2.0) - (9.0 * t_1);
	double t_4 = (a * (27.0 * b)) + (y * (-9.0 * (z * t)));
	double tmp;
	if (t_2 <= -2e+101) {
		tmp = t_4;
	} else if (t_2 <= 7e-80) {
		tmp = t_3;
	} else if (t_2 <= 5e-39) {
		tmp = t_4;
	} else if (t_2 <= 4e+98) {
		tmp = t_3;
	} else {
		tmp = t_2 + (-9.0 * t_1);
	}
	return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: t_4
    real(8) :: tmp
    t_1 = t * (z * y)
    t_2 = b * (a * 27.0d0)
    t_3 = (x * 2.0d0) - (9.0d0 * t_1)
    t_4 = (a * (27.0d0 * b)) + (y * ((-9.0d0) * (z * t)))
    if (t_2 <= (-2d+101)) then
        tmp = t_4
    else if (t_2 <= 7d-80) then
        tmp = t_3
    else if (t_2 <= 5d-39) then
        tmp = t_4
    else if (t_2 <= 4d+98) then
        tmp = t_3
    else
        tmp = t_2 + ((-9.0d0) * t_1)
    end if
    code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = t * (z * y);
	double t_2 = b * (a * 27.0);
	double t_3 = (x * 2.0) - (9.0 * t_1);
	double t_4 = (a * (27.0 * b)) + (y * (-9.0 * (z * t)));
	double tmp;
	if (t_2 <= -2e+101) {
		tmp = t_4;
	} else if (t_2 <= 7e-80) {
		tmp = t_3;
	} else if (t_2 <= 5e-39) {
		tmp = t_4;
	} else if (t_2 <= 4e+98) {
		tmp = t_3;
	} else {
		tmp = t_2 + (-9.0 * t_1);
	}
	return tmp;
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	t_1 = t * (z * y)
	t_2 = b * (a * 27.0)
	t_3 = (x * 2.0) - (9.0 * t_1)
	t_4 = (a * (27.0 * b)) + (y * (-9.0 * (z * t)))
	tmp = 0
	if t_2 <= -2e+101:
		tmp = t_4
	elif t_2 <= 7e-80:
		tmp = t_3
	elif t_2 <= 5e-39:
		tmp = t_4
	elif t_2 <= 4e+98:
		tmp = t_3
	else:
		tmp = t_2 + (-9.0 * t_1)
	return tmp
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(t * Float64(z * y))
	t_2 = Float64(b * Float64(a * 27.0))
	t_3 = Float64(Float64(x * 2.0) - Float64(9.0 * t_1))
	t_4 = Float64(Float64(a * Float64(27.0 * b)) + Float64(y * Float64(-9.0 * Float64(z * t))))
	tmp = 0.0
	if (t_2 <= -2e+101)
		tmp = t_4;
	elseif (t_2 <= 7e-80)
		tmp = t_3;
	elseif (t_2 <= 5e-39)
		tmp = t_4;
	elseif (t_2 <= 4e+98)
		tmp = t_3;
	else
		tmp = Float64(t_2 + Float64(-9.0 * t_1));
	end
	return tmp
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = t * (z * y);
	t_2 = b * (a * 27.0);
	t_3 = (x * 2.0) - (9.0 * t_1);
	t_4 = (a * (27.0 * b)) + (y * (-9.0 * (z * t)));
	tmp = 0.0;
	if (t_2 <= -2e+101)
		tmp = t_4;
	elseif (t_2 <= 7e-80)
		tmp = t_3;
	elseif (t_2 <= 5e-39)
		tmp = t_4;
	elseif (t_2 <= 4e+98)
		tmp = t_3;
	else
		tmp = t_2 + (-9.0 * t_1);
	end
	tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(t * N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x * 2.0), $MachinePrecision] - N[(9.0 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision] + N[(y * N[(-9.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+101], t$95$4, If[LessEqual[t$95$2, 7e-80], t$95$3, If[LessEqual[t$95$2, 5e-39], t$95$4, If[LessEqual[t$95$2, 4e+98], t$95$3, N[(t$95$2 + N[(-9.0 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := t \cdot \left(z \cdot y\right)\\
t_2 := b \cdot \left(a \cdot 27\right)\\
t_3 := x \cdot 2 - 9 \cdot t_1\\
t_4 := a \cdot \left(27 \cdot b\right) + y \cdot \left(-9 \cdot \left(z \cdot t\right)\right)\\
\mathbf{if}\;t_2 \leq -2 \cdot 10^{+101}:\\
\;\;\;\;t_4\\

\mathbf{elif}\;t_2 \leq 7 \cdot 10^{-80}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-39}:\\
\;\;\;\;t_4\\

\mathbf{elif}\;t_2 \leq 4 \cdot 10^{+98}:\\
\;\;\;\;t_3\\

\mathbf{else}:\\
\;\;\;\;t_2 + -9 \cdot t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 a 27) b) < -2e101 or 7.00000000000000029e-80 < (*.f64 (*.f64 a 27) b) < 4.9999999999999998e-39

    1. Initial program 99.7%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. sub-neg99.7%

        \[\leadsto \color{blue}{\left(x \cdot 2 + \left(-\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)} + \left(a \cdot 27\right) \cdot b \]
      2. distribute-lft-neg-in99.7%

        \[\leadsto \left(x \cdot 2 + \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*99.7%

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

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

        \[\leadsto \left(x \cdot 2 + \left(-\color{blue}{\left(z \cdot 9\right)} \cdot y\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      6. cancel-sign-sub-inv99.7%

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

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

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

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      10. associate-*l*97.9%

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]
      11. associate-*l*97.8%

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

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

      \[\leadsto \color{blue}{-9 \cdot \left(y \cdot \left(t \cdot z\right)\right)} + a \cdot \left(27 \cdot b\right) \]
    5. Step-by-step derivation
      1. *-commutative96.0%

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

        \[\leadsto \left(y \cdot \color{blue}{\left(z \cdot t\right)}\right) \cdot -9 + a \cdot \left(27 \cdot b\right) \]
      3. associate-*r*96.0%

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

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

        \[\leadsto y \cdot \left(-9 \cdot \color{blue}{\left(t \cdot z\right)}\right) + a \cdot \left(27 \cdot b\right) \]
    6. Simplified96.0%

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

    if -2e101 < (*.f64 (*.f64 a 27) b) < 7.00000000000000029e-80 or 4.9999999999999998e-39 < (*.f64 (*.f64 a 27) b) < 3.99999999999999999e98

    1. Initial program 96.9%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. sub-neg96.9%

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

        \[\leadsto \left(x \cdot 2 + \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*96.9%

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

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

        \[\leadsto \left(x \cdot 2 + \left(-\color{blue}{\left(z \cdot 9\right)} \cdot y\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      6. cancel-sign-sub-inv96.9%

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

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

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

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      10. associate-*l*94.6%

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]
      11. associate-*l*94.6%

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

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

      \[\leadsto \color{blue}{2 \cdot x - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u62.9%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(t \cdot z\right)\right)\right)} \]
      2. expm1-udef59.4%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left(t \cdot z\right)\right)} - 1\right)} \]
      3. *-commutative59.4%

        \[\leadsto 2 \cdot x - 9 \cdot \left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\left(z \cdot t\right)}\right)} - 1\right) \]
    6. Applied egg-rr59.4%

      \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left(z \cdot t\right)\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def62.9%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(z \cdot t\right)\right)\right)} \]
      2. expm1-log1p86.6%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(y \cdot \left(z \cdot t\right)\right)} \]
      3. *-commutative86.6%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(\left(z \cdot t\right) \cdot y\right)} \]
      4. *-commutative86.6%

        \[\leadsto 2 \cdot x - 9 \cdot \left(\color{blue}{\left(t \cdot z\right)} \cdot y\right) \]
      5. associate-*l*88.6%

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

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

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

    if 3.99999999999999999e98 < (*.f64 (*.f64 a 27) b)

    1. Initial program 95.2%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. pow195.2%

        \[\leadsto \left(x \cdot 2 - \color{blue}{{\left(\left(y \cdot 9\right) \cdot z\right)}^{1}} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      2. associate-*l*95.1%

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

      \[\leadsto \left(x \cdot 2 - \color{blue}{{\left(y \cdot \left(9 \cdot z\right)\right)}^{1}} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    4. Taylor expanded in x around 0 87.6%

      \[\leadsto \color{blue}{-9 \cdot \left(y \cdot \left(t \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    5. Step-by-step derivation
      1. associate-*r*89.9%

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

        \[\leadsto -9 \cdot \left(\color{blue}{\left(t \cdot y\right)} \cdot z\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*87.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot \left(a \cdot 27\right) \leq -2 \cdot 10^{+101}:\\ \;\;\;\;a \cdot \left(27 \cdot b\right) + y \cdot \left(-9 \cdot \left(z \cdot t\right)\right)\\ \mathbf{elif}\;b \cdot \left(a \cdot 27\right) \leq 7 \cdot 10^{-80}:\\ \;\;\;\;x \cdot 2 - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\\ \mathbf{elif}\;b \cdot \left(a \cdot 27\right) \leq 5 \cdot 10^{-39}:\\ \;\;\;\;a \cdot \left(27 \cdot b\right) + y \cdot \left(-9 \cdot \left(z \cdot t\right)\right)\\ \mathbf{elif}\;b \cdot \left(a \cdot 27\right) \leq 4 \cdot 10^{+98}:\\ \;\;\;\;x \cdot 2 - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(a \cdot 27\right) + -9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\\ \end{array} \]

Alternative 4: 81.6% accurate, 0.7× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} t_1 := b \cdot \left(a \cdot 27\right)\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+101} \lor \neg \left(t_1 \leq 2 \cdot 10^{+137}\right):\\ \;\;\;\;x \cdot 2 + 27 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 + y \cdot \left(t \cdot \left(z \cdot -9\right)\right)\\ \end{array} \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* b (* a 27.0))))
   (if (or (<= t_1 -2e+101) (not (<= t_1 2e+137)))
     (+ (* x 2.0) (* 27.0 (* a b)))
     (+ (* x 2.0) (* y (* t (* z -9.0)))))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = b * (a * 27.0);
	double tmp;
	if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) {
		tmp = (x * 2.0) + (27.0 * (a * b));
	} else {
		tmp = (x * 2.0) + (y * (t * (z * -9.0)));
	}
	return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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) :: t_1
    real(8) :: tmp
    t_1 = b * (a * 27.0d0)
    if ((t_1 <= (-2d+101)) .or. (.not. (t_1 <= 2d+137))) then
        tmp = (x * 2.0d0) + (27.0d0 * (a * b))
    else
        tmp = (x * 2.0d0) + (y * (t * (z * (-9.0d0))))
    end if
    code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = b * (a * 27.0);
	double tmp;
	if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) {
		tmp = (x * 2.0) + (27.0 * (a * b));
	} else {
		tmp = (x * 2.0) + (y * (t * (z * -9.0)));
	}
	return tmp;
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	t_1 = b * (a * 27.0)
	tmp = 0
	if (t_1 <= -2e+101) or not (t_1 <= 2e+137):
		tmp = (x * 2.0) + (27.0 * (a * b))
	else:
		tmp = (x * 2.0) + (y * (t * (z * -9.0)))
	return tmp
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(b * Float64(a * 27.0))
	tmp = 0.0
	if ((t_1 <= -2e+101) || !(t_1 <= 2e+137))
		tmp = Float64(Float64(x * 2.0) + Float64(27.0 * Float64(a * b)));
	else
		tmp = Float64(Float64(x * 2.0) + Float64(y * Float64(t * Float64(z * -9.0))));
	end
	return tmp
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = b * (a * 27.0);
	tmp = 0.0;
	if ((t_1 <= -2e+101) || ~((t_1 <= 2e+137)))
		tmp = (x * 2.0) + (27.0 * (a * b));
	else
		tmp = (x * 2.0) + (y * (t * (z * -9.0)));
	end
	tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+101], N[Not[LessEqual[t$95$1, 2e+137]], $MachinePrecision]], N[(N[(x * 2.0), $MachinePrecision] + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 2.0), $MachinePrecision] + N[(y * N[(t * N[(z * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := b \cdot \left(a \cdot 27\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+101} \lor \neg \left(t_1 \leq 2 \cdot 10^{+137}\right):\\
\;\;\;\;x \cdot 2 + 27 \cdot \left(a \cdot b\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 a 27) b) < -2e101 or 2.0000000000000001e137 < (*.f64 (*.f64 a 27) b)

    1. Initial program 98.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. sub-neg98.4%

        \[\leadsto \color{blue}{\left(x \cdot 2 + \left(-\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)} + \left(a \cdot 27\right) \cdot b \]
      2. distribute-lft-neg-in98.4%

        \[\leadsto \left(x \cdot 2 + \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*98.4%

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

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

        \[\leadsto \left(x \cdot 2 + \left(-\color{blue}{\left(z \cdot 9\right)} \cdot y\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      6. cancel-sign-sub-inv98.4%

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

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

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

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      10. associate-*l*96.0%

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]
      11. associate-*l*96.0%

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

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

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

    if -2e101 < (*.f64 (*.f64 a 27) b) < 2.0000000000000001e137

    1. Initial program 96.7%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. sub-neg96.7%

        \[\leadsto \color{blue}{\left(x \cdot 2 + \left(-\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)} + \left(a \cdot 27\right) \cdot b \]
      2. distribute-lft-neg-in96.7%

        \[\leadsto \left(x \cdot 2 + \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*96.7%

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

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

        \[\leadsto \left(x \cdot 2 + \left(-\color{blue}{\left(z \cdot 9\right)} \cdot y\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      6. cancel-sign-sub-inv96.7%

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

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

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

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      10. associate-*l*95.1%

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]
      11. associate-*l*95.1%

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

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

      \[\leadsto \color{blue}{2 \cdot x - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u60.7%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(t \cdot z\right)\right)\right)} \]
      2. expm1-udef57.1%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left(t \cdot z\right)\right)} - 1\right)} \]
      3. *-commutative57.1%

        \[\leadsto 2 \cdot x - 9 \cdot \left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\left(z \cdot t\right)}\right)} - 1\right) \]
    6. Applied egg-rr57.1%

      \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left(z \cdot t\right)\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def60.7%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(z \cdot t\right)\right)\right)} \]
      2. expm1-log1p83.6%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(y \cdot \left(z \cdot t\right)\right)} \]
      3. *-commutative83.6%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(\left(z \cdot t\right) \cdot y\right)} \]
      4. *-commutative83.6%

        \[\leadsto 2 \cdot x - 9 \cdot \left(\color{blue}{\left(t \cdot z\right)} \cdot y\right) \]
      5. associate-*l*84.9%

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

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

      \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)} \]
    9. Step-by-step derivation
      1. cancel-sign-sub-inv84.9%

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

        \[\leadsto \color{blue}{x \cdot 2} + \left(-9\right) \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      3. metadata-eval84.9%

        \[\leadsto x \cdot 2 + \color{blue}{-9} \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      4. *-commutative84.9%

        \[\leadsto x \cdot 2 + \color{blue}{\left(t \cdot \left(y \cdot z\right)\right) \cdot -9} \]
      5. associate-*r*83.9%

        \[\leadsto x \cdot 2 + \color{blue}{\left(\left(t \cdot y\right) \cdot z\right)} \cdot -9 \]
      6. *-commutative83.9%

        \[\leadsto x \cdot 2 + \left(\color{blue}{\left(y \cdot t\right)} \cdot z\right) \cdot -9 \]
      7. associate-*r*83.9%

        \[\leadsto x \cdot 2 + \color{blue}{\left(y \cdot t\right) \cdot \left(z \cdot -9\right)} \]
      8. associate-*l*83.7%

        \[\leadsto x \cdot 2 + \color{blue}{y \cdot \left(t \cdot \left(z \cdot -9\right)\right)} \]
    10. Applied egg-rr83.7%

      \[\leadsto \color{blue}{x \cdot 2 + y \cdot \left(t \cdot \left(z \cdot -9\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.1%

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

Alternative 5: 81.4% accurate, 0.7× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} t_1 := b \cdot \left(a \cdot 27\right)\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+101} \lor \neg \left(t_1 \leq 2 \cdot 10^{+137}\right):\\ \;\;\;\;x \cdot 2 + 27 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\\ \end{array} \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* b (* a 27.0))))
   (if (or (<= t_1 -2e+101) (not (<= t_1 2e+137)))
     (+ (* x 2.0) (* 27.0 (* a b)))
     (- (* x 2.0) (* 9.0 (* t (* z y)))))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = b * (a * 27.0);
	double tmp;
	if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) {
		tmp = (x * 2.0) + (27.0 * (a * b));
	} else {
		tmp = (x * 2.0) - (9.0 * (t * (z * y)));
	}
	return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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) :: t_1
    real(8) :: tmp
    t_1 = b * (a * 27.0d0)
    if ((t_1 <= (-2d+101)) .or. (.not. (t_1 <= 2d+137))) then
        tmp = (x * 2.0d0) + (27.0d0 * (a * b))
    else
        tmp = (x * 2.0d0) - (9.0d0 * (t * (z * y)))
    end if
    code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = b * (a * 27.0);
	double tmp;
	if ((t_1 <= -2e+101) || !(t_1 <= 2e+137)) {
		tmp = (x * 2.0) + (27.0 * (a * b));
	} else {
		tmp = (x * 2.0) - (9.0 * (t * (z * y)));
	}
	return tmp;
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	t_1 = b * (a * 27.0)
	tmp = 0
	if (t_1 <= -2e+101) or not (t_1 <= 2e+137):
		tmp = (x * 2.0) + (27.0 * (a * b))
	else:
		tmp = (x * 2.0) - (9.0 * (t * (z * y)))
	return tmp
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(b * Float64(a * 27.0))
	tmp = 0.0
	if ((t_1 <= -2e+101) || !(t_1 <= 2e+137))
		tmp = Float64(Float64(x * 2.0) + Float64(27.0 * Float64(a * b)));
	else
		tmp = Float64(Float64(x * 2.0) - Float64(9.0 * Float64(t * Float64(z * y))));
	end
	return tmp
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = b * (a * 27.0);
	tmp = 0.0;
	if ((t_1 <= -2e+101) || ~((t_1 <= 2e+137)))
		tmp = (x * 2.0) + (27.0 * (a * b));
	else
		tmp = (x * 2.0) - (9.0 * (t * (z * y)));
	end
	tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+101], N[Not[LessEqual[t$95$1, 2e+137]], $MachinePrecision]], N[(N[(x * 2.0), $MachinePrecision] + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 2.0), $MachinePrecision] - N[(9.0 * N[(t * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := b \cdot \left(a \cdot 27\right)\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+101} \lor \neg \left(t_1 \leq 2 \cdot 10^{+137}\right):\\
\;\;\;\;x \cdot 2 + 27 \cdot \left(a \cdot b\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 a 27) b) < -2e101 or 2.0000000000000001e137 < (*.f64 (*.f64 a 27) b)

    1. Initial program 98.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. sub-neg98.4%

        \[\leadsto \color{blue}{\left(x \cdot 2 + \left(-\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)} + \left(a \cdot 27\right) \cdot b \]
      2. distribute-lft-neg-in98.4%

        \[\leadsto \left(x \cdot 2 + \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*98.4%

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

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

        \[\leadsto \left(x \cdot 2 + \left(-\color{blue}{\left(z \cdot 9\right)} \cdot y\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      6. cancel-sign-sub-inv98.4%

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

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

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

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      10. associate-*l*96.0%

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]
      11. associate-*l*96.0%

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

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

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

    if -2e101 < (*.f64 (*.f64 a 27) b) < 2.0000000000000001e137

    1. Initial program 96.7%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. sub-neg96.7%

        \[\leadsto \color{blue}{\left(x \cdot 2 + \left(-\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)} + \left(a \cdot 27\right) \cdot b \]
      2. distribute-lft-neg-in96.7%

        \[\leadsto \left(x \cdot 2 + \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*96.7%

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

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

        \[\leadsto \left(x \cdot 2 + \left(-\color{blue}{\left(z \cdot 9\right)} \cdot y\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      6. cancel-sign-sub-inv96.7%

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

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

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

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      10. associate-*l*95.1%

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]
      11. associate-*l*95.1%

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

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

      \[\leadsto \color{blue}{2 \cdot x - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. expm1-log1p-u60.7%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(t \cdot z\right)\right)\right)} \]
      2. expm1-udef57.1%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left(t \cdot z\right)\right)} - 1\right)} \]
      3. *-commutative57.1%

        \[\leadsto 2 \cdot x - 9 \cdot \left(e^{\mathsf{log1p}\left(y \cdot \color{blue}{\left(z \cdot t\right)}\right)} - 1\right) \]
    6. Applied egg-rr57.1%

      \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(y \cdot \left(z \cdot t\right)\right)} - 1\right)} \]
    7. Step-by-step derivation
      1. expm1-def60.7%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(y \cdot \left(z \cdot t\right)\right)\right)} \]
      2. expm1-log1p83.6%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(y \cdot \left(z \cdot t\right)\right)} \]
      3. *-commutative83.6%

        \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(\left(z \cdot t\right) \cdot y\right)} \]
      4. *-commutative83.6%

        \[\leadsto 2 \cdot x - 9 \cdot \left(\color{blue}{\left(t \cdot z\right)} \cdot y\right) \]
      5. associate-*l*84.9%

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

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

      \[\leadsto 2 \cdot x - 9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.0%

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

Alternative 6: 97.9% accurate, 0.8× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} t_1 := a \cdot \left(27 \cdot b\right)\\ \mathbf{if}\;y \cdot 9 \leq -5 \cdot 10^{-40}:\\ \;\;\;\;t_1 + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 + \left(x \cdot 2 + z \cdot \left(y \cdot \left(t \cdot -9\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* a (* 27.0 b))))
   (if (<= (* y 9.0) -5e-40)
     (+ t_1 (- (* x 2.0) (* (* y 9.0) (* z t))))
     (+ t_1 (+ (* x 2.0) (* z (* y (* t -9.0))))))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = a * (27.0 * b);
	double tmp;
	if ((y * 9.0) <= -5e-40) {
		tmp = t_1 + ((x * 2.0) - ((y * 9.0) * (z * t)));
	} else {
		tmp = t_1 + ((x * 2.0) + (z * (y * (t * -9.0))));
	}
	return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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) :: t_1
    real(8) :: tmp
    t_1 = a * (27.0d0 * b)
    if ((y * 9.0d0) <= (-5d-40)) then
        tmp = t_1 + ((x * 2.0d0) - ((y * 9.0d0) * (z * t)))
    else
        tmp = t_1 + ((x * 2.0d0) + (z * (y * (t * (-9.0d0)))))
    end if
    code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = a * (27.0 * b);
	double tmp;
	if ((y * 9.0) <= -5e-40) {
		tmp = t_1 + ((x * 2.0) - ((y * 9.0) * (z * t)));
	} else {
		tmp = t_1 + ((x * 2.0) + (z * (y * (t * -9.0))));
	}
	return tmp;
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	t_1 = a * (27.0 * b)
	tmp = 0
	if (y * 9.0) <= -5e-40:
		tmp = t_1 + ((x * 2.0) - ((y * 9.0) * (z * t)))
	else:
		tmp = t_1 + ((x * 2.0) + (z * (y * (t * -9.0))))
	return tmp
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(a * Float64(27.0 * b))
	tmp = 0.0
	if (Float64(y * 9.0) <= -5e-40)
		tmp = Float64(t_1 + Float64(Float64(x * 2.0) - Float64(Float64(y * 9.0) * Float64(z * t))));
	else
		tmp = Float64(t_1 + Float64(Float64(x * 2.0) + Float64(z * Float64(y * Float64(t * -9.0)))));
	end
	return tmp
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = a * (27.0 * b);
	tmp = 0.0;
	if ((y * 9.0) <= -5e-40)
		tmp = t_1 + ((x * 2.0) - ((y * 9.0) * (z * t)));
	else
		tmp = t_1 + ((x * 2.0) + (z * (y * (t * -9.0))));
	end
	tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * 9.0), $MachinePrecision], -5e-40], N[(t$95$1 + N[(N[(x * 2.0), $MachinePrecision] - N[(N[(y * 9.0), $MachinePrecision] * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(x * 2.0), $MachinePrecision] + N[(z * N[(y * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_1 := a \cdot \left(27 \cdot b\right)\\
\mathbf{if}\;y \cdot 9 \leq -5 \cdot 10^{-40}:\\
\;\;\;\;t_1 + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y 9) < -4.99999999999999965e-40

    1. Initial program 95.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. Step-by-step derivation
      1. sub-neg95.0%

        \[\leadsto \color{blue}{\left(x \cdot 2 + \left(-\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)} + \left(a \cdot 27\right) \cdot b \]
      2. distribute-lft-neg-in95.0%

        \[\leadsto \left(x \cdot 2 + \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) + \left(a \cdot 27\right) \cdot b \]
      3. associate-*l*95.0%

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

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

        \[\leadsto \left(x \cdot 2 + \left(-\color{blue}{\left(z \cdot 9\right)} \cdot y\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      6. cancel-sign-sub-inv95.0%

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

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

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

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      10. associate-*l*97.4%

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]
      11. associate-*l*97.4%

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

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

    if -4.99999999999999965e-40 < (*.f64 y 9)

    1. Initial program 98.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. Step-by-step derivation
      1. +-commutative98.1%

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

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t} \]
      3. cancel-sign-sub-inv98.1%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{t \cdot \left(-\left(y \cdot 9\right) \cdot z\right)} \]
      5. distribute-rgt-neg-out98.1%

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(-z\right)\right)} \]
      6. associate-*r*96.1%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{\left(\left(y \cdot 9\right) \cdot t\right)} \cdot \left(-z\right) \]
      8. distribute-rgt-neg-in96.1%

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 2 - \left(\left(\left(y \cdot 9\right) \cdot t\right) \cdot z - \left(a \cdot 27\right) \cdot b\right)} \]
      13. fma-neg96.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 2, -\left(\left(\left(y \cdot 9\right) \cdot t\right) \cdot z - \left(a \cdot 27\right) \cdot b\right)\right)} \]
      14. associate-*l*94.4%

        \[\leadsto \mathsf{fma}\left(x, 2, -\left(\color{blue}{\left(y \cdot 9\right) \cdot \left(t \cdot z\right)} - \left(a \cdot 27\right) \cdot b\right)\right) \]
      15. fma-neg94.4%

        \[\leadsto \mathsf{fma}\left(x, 2, -\color{blue}{\mathsf{fma}\left(y \cdot 9, t \cdot z, -\left(a \cdot 27\right) \cdot b\right)}\right) \]
      16. *-commutative94.4%

        \[\leadsto \mathsf{fma}\left(x, 2, -\mathsf{fma}\left(y \cdot 9, \color{blue}{z \cdot t}, -\left(a \cdot 27\right) \cdot b\right)\right) \]
      17. fma-neg94.4%

        \[\leadsto \mathsf{fma}\left(x, 2, -\color{blue}{\left(\left(y \cdot 9\right) \cdot \left(z \cdot t\right) - \left(a \cdot 27\right) \cdot b\right)}\right) \]
    3. Simplified96.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 2, \mathsf{fma}\left(z, y \cdot \left(t \cdot -9\right), \left(a \cdot 27\right) \cdot b\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef96.1%

        \[\leadsto \color{blue}{x \cdot 2 + \mathsf{fma}\left(z, y \cdot \left(t \cdot -9\right), \left(a \cdot 27\right) \cdot b\right)} \]
      2. fma-udef96.1%

        \[\leadsto x \cdot 2 + \color{blue}{\left(z \cdot \left(y \cdot \left(t \cdot -9\right)\right) + \left(a \cdot 27\right) \cdot b\right)} \]
      3. associate-*r*96.1%

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

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

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

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

Alternative 7: 98.1% accurate, 0.9× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;t \leq 230000000:\\ \;\;\;\;\left(x \cdot 2 + a \cdot \left(27 \cdot b\right)\right) + \left(y \cdot t\right) \cdot \left(z \cdot -9\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - t \cdot \left(z \cdot \left(y \cdot 9\right)\right)\right) + b \cdot \left(a \cdot 27\right)\\ \end{array} \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (<= t 230000000.0)
   (+ (+ (* x 2.0) (* a (* 27.0 b))) (* (* y t) (* z -9.0)))
   (+ (- (* x 2.0) (* t (* z (* y 9.0)))) (* b (* a 27.0)))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (t <= 230000000.0) {
		tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
	} else {
		tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0));
	}
	return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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 <= 230000000.0d0) then
        tmp = ((x * 2.0d0) + (a * (27.0d0 * b))) + ((y * t) * (z * (-9.0d0)))
    else
        tmp = ((x * 2.0d0) - (t * (z * (y * 9.0d0)))) + (b * (a * 27.0d0))
    end if
    code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (t <= 230000000.0) {
		tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
	} else {
		tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0));
	}
	return tmp;
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	tmp = 0
	if t <= 230000000.0:
		tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0))
	else:
		tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0))
	return tmp
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (t <= 230000000.0)
		tmp = Float64(Float64(Float64(x * 2.0) + Float64(a * Float64(27.0 * b))) + Float64(Float64(y * t) * Float64(z * -9.0)));
	else
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(t * Float64(z * Float64(y * 9.0)))) + Float64(b * Float64(a * 27.0)));
	end
	return tmp
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (t <= 230000000.0)
		tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
	else
		tmp = ((x * 2.0) - (t * (z * (y * 9.0)))) + (b * (a * 27.0));
	end
	tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, 230000000.0], N[(N[(N[(x * 2.0), $MachinePrecision] + N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(y * t), $MachinePrecision] * N[(z * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(t * N[(z * N[(y * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * N[(a * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq 230000000:\\
\;\;\;\;\left(x \cdot 2 + a \cdot \left(27 \cdot b\right)\right) + \left(y \cdot t\right) \cdot \left(z \cdot -9\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < 2.3e8

    1. Initial program 96.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. Step-by-step derivation
      1. +-commutative96.0%

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

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t} \]
      3. cancel-sign-sub-inv96.0%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{t \cdot \left(-\left(y \cdot 9\right) \cdot z\right)} \]
      5. distribute-rgt-neg-out96.0%

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(-z\right)\right)} \]
      6. associate-*r*96.1%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{\left(\left(y \cdot 9\right) \cdot t\right)} \cdot \left(-z\right) \]
      8. distribute-rgt-neg-in96.1%

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

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

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
      11. associate-*l*96.1%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
      13. fma-neg96.1%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \color{blue}{\mathsf{fma}\left(x, 2, -\left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)}\right) \]
      14. associate-*l*96.1%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{\left(y \cdot \left(9 \cdot t\right)\right)} \cdot z\right)\right) \]
      15. *-commutative96.1%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\left(y \cdot \color{blue}{\left(t \cdot 9\right)}\right) \cdot z\right)\right) \]
      16. associate-*r*96.1%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{y \cdot \left(\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
      17. distribute-rgt-neg-in96.1%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, \color{blue}{y \cdot \left(-\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
    3. Simplified96.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef96.2%

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

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

        \[\leadsto \color{blue}{\left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right) + y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)} \]
      4. associate-*r*96.1%

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

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

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

    if 2.3e8 < t

    1. Initial program 99.8%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.2%

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

Alternative 8: 93.0% accurate, 1.0× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \left(x \cdot 2 + a \cdot \left(27 \cdot b\right)\right) + \left(y \cdot t\right) \cdot \left(z \cdot -9\right) \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (+ (+ (* x 2.0) (* a (* 27.0 b))) (* (* y t) (* z -9.0))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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
    code = ((x * 2.0d0) + (a * (27.0d0 * b))) + ((y * t) * (z * (-9.0d0)))
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	return ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0))
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x * 2.0) + Float64(a * Float64(27.0 * b))) + Float64(Float64(y * t) * Float64(z * -9.0)))
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = ((x * 2.0) + (a * (27.0 * b))) + ((y * t) * (z * -9.0));
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] + N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(y * t), $MachinePrecision] * N[(z * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\left(x \cdot 2 + a \cdot \left(27 \cdot b\right)\right) + \left(y \cdot t\right) \cdot \left(z \cdot -9\right)
\end{array}
Derivation
  1. Initial program 97.2%

    \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
  2. Step-by-step derivation
    1. +-commutative97.2%

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

      \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t} \]
    3. cancel-sign-sub-inv97.2%

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

      \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{t \cdot \left(-\left(y \cdot 9\right) \cdot z\right)} \]
    5. distribute-rgt-neg-out97.2%

      \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(-z\right)\right)} \]
    6. associate-*r*96.1%

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

      \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{\left(\left(y \cdot 9\right) \cdot t\right)} \cdot \left(-z\right) \]
    8. distribute-rgt-neg-in96.1%

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

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

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
    11. associate-*l*96.1%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
    13. fma-neg96.1%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \color{blue}{\mathsf{fma}\left(x, 2, -\left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)}\right) \]
    14. associate-*l*96.1%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{\left(y \cdot \left(9 \cdot t\right)\right)} \cdot z\right)\right) \]
    15. *-commutative96.1%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\left(y \cdot \color{blue}{\left(t \cdot 9\right)}\right) \cdot z\right)\right) \]
    16. associate-*r*95.3%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{y \cdot \left(\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
    17. distribute-rgt-neg-in95.3%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, \color{blue}{y \cdot \left(-\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
  3. Simplified95.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)\right)\right)} \]
  4. Step-by-step derivation
    1. fma-udef95.4%

      \[\leadsto \color{blue}{a \cdot \left(27 \cdot b\right) + \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)\right)} \]
    2. fma-udef95.4%

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

      \[\leadsto \color{blue}{\left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right) + y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)} \]
    4. associate-*r*96.1%

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

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

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

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

Alternative 9: 47.8% accurate, 1.9× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;b \leq -1.15 \cdot 10^{-62} \lor \neg \left(b \leq 4.5 \cdot 10^{+59}\right):\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2\\ \end{array} \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= b -1.15e-62) (not (<= b 4.5e+59))) (* 27.0 (* a b)) (* x 2.0)))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((b <= -1.15e-62) || !(b <= 4.5e+59)) {
		tmp = 27.0 * (a * b);
	} else {
		tmp = x * 2.0;
	}
	return tmp;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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 ((b <= (-1.15d-62)) .or. (.not. (b <= 4.5d+59))) then
        tmp = 27.0d0 * (a * b)
    else
        tmp = x * 2.0d0
    end if
    code = tmp
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((b <= -1.15e-62) || !(b <= 4.5e+59)) {
		tmp = 27.0 * (a * b);
	} else {
		tmp = x * 2.0;
	}
	return tmp;
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	tmp = 0
	if (b <= -1.15e-62) or not (b <= 4.5e+59):
		tmp = 27.0 * (a * b)
	else:
		tmp = x * 2.0
	return tmp
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if ((b <= -1.15e-62) || !(b <= 4.5e+59))
		tmp = Float64(27.0 * Float64(a * b));
	else
		tmp = Float64(x * 2.0);
	end
	return tmp
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if ((b <= -1.15e-62) || ~((b <= 4.5e+59)))
		tmp = 27.0 * (a * b);
	else
		tmp = x * 2.0;
	end
	tmp_2 = tmp;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[b, -1.15e-62], N[Not[LessEqual[b, 4.5e+59]], $MachinePrecision]], N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision], N[(x * 2.0), $MachinePrecision]]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{-62} \lor \neg \left(b \leq 4.5 \cdot 10^{+59}\right):\\
\;\;\;\;27 \cdot \left(a \cdot b\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.15e-62 or 4.49999999999999959e59 < b

    1. Initial program 98.2%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. +-commutative98.2%

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

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t} \]
      3. cancel-sign-sub-inv98.2%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{t \cdot \left(-\left(y \cdot 9\right) \cdot z\right)} \]
      5. distribute-rgt-neg-out98.2%

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(-z\right)\right)} \]
      6. associate-*r*95.3%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{\left(\left(y \cdot 9\right) \cdot t\right)} \cdot \left(-z\right) \]
      8. distribute-rgt-neg-in95.3%

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

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

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
      11. associate-*l*95.3%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
      13. fma-neg95.4%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \color{blue}{\mathsf{fma}\left(x, 2, -\left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)}\right) \]
      14. associate-*l*95.4%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{\left(y \cdot \left(9 \cdot t\right)\right)} \cdot z\right)\right) \]
      15. *-commutative95.4%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\left(y \cdot \color{blue}{\left(t \cdot 9\right)}\right) \cdot z\right)\right) \]
      16. associate-*r*95.3%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{y \cdot \left(\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
      17. distribute-rgt-neg-in95.3%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, \color{blue}{y \cdot \left(-\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
    3. Simplified95.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef95.3%

        \[\leadsto \color{blue}{a \cdot \left(27 \cdot b\right) + \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)\right)} \]
      2. fma-udef95.3%

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

        \[\leadsto \color{blue}{\left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right) + y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)} \]
      4. associate-*r*95.4%

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

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

      \[\leadsto \color{blue}{\left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right) + \left(y \cdot t\right) \cdot \left(z \cdot -9\right)} \]
    6. Taylor expanded in a around inf 56.1%

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]

    if -1.15e-62 < b < 4.49999999999999959e59

    1. Initial program 96.2%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Step-by-step derivation
      1. +-commutative96.2%

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

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t} \]
      3. cancel-sign-sub-inv96.2%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{t \cdot \left(-\left(y \cdot 9\right) \cdot z\right)} \]
      5. distribute-rgt-neg-out96.2%

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(-z\right)\right)} \]
      6. associate-*r*96.9%

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

        \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{\left(\left(y \cdot 9\right) \cdot t\right)} \cdot \left(-z\right) \]
      8. distribute-rgt-neg-in96.9%

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

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

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
      11. associate-*l*96.9%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
      13. fma-neg96.9%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \color{blue}{\mathsf{fma}\left(x, 2, -\left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)}\right) \]
      14. associate-*l*96.9%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{\left(y \cdot \left(9 \cdot t\right)\right)} \cdot z\right)\right) \]
      15. *-commutative96.9%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\left(y \cdot \color{blue}{\left(t \cdot 9\right)}\right) \cdot z\right)\right) \]
      16. associate-*r*95.3%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{y \cdot \left(\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
      17. distribute-rgt-neg-in95.3%

        \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, \color{blue}{y \cdot \left(-\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
    3. Simplified95.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef95.5%

        \[\leadsto \color{blue}{a \cdot \left(27 \cdot b\right) + \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)\right)} \]
      2. fma-udef95.5%

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

        \[\leadsto \color{blue}{\left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right) + y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)} \]
      4. associate-*r*96.9%

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

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

      \[\leadsto \color{blue}{\left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right) + \left(y \cdot t\right) \cdot \left(z \cdot -9\right)} \]
    6. Taylor expanded in x around inf 41.0%

      \[\leadsto \color{blue}{2 \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.15 \cdot 10^{-62} \lor \neg \left(b \leq 4.5 \cdot 10^{+59}\right):\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2\\ \end{array} \]

Alternative 10: 63.9% accurate, 1.9× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ x \cdot 2 + 27 \cdot \left(a \cdot b\right) \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b) :precision binary64 (+ (* x 2.0) (* 27.0 (* a b))))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	return (x * 2.0) + (27.0 * (a * b));
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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
    code = (x * 2.0d0) + (27.0d0 * (a * b))
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	return (x * 2.0) + (27.0 * (a * b));
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	return (x * 2.0) + (27.0 * (a * b))
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	return Float64(Float64(x * 2.0) + Float64(27.0 * Float64(a * b)))
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = (x * 2.0) + (27.0 * (a * b));
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * 2.0), $MachinePrecision] + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
x \cdot 2 + 27 \cdot \left(a \cdot b\right)
\end{array}
Derivation
  1. Initial program 97.2%

    \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
  2. Step-by-step derivation
    1. sub-neg97.2%

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

      \[\leadsto \left(x \cdot 2 + \color{blue}{\left(-\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) + \left(a \cdot 27\right) \cdot b \]
    3. associate-*l*97.2%

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

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

      \[\leadsto \left(x \cdot 2 + \left(-\color{blue}{\left(z \cdot 9\right)} \cdot y\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    6. cancel-sign-sub-inv97.2%

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

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

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

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    10. associate-*l*95.3%

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b \]
    11. associate-*l*95.4%

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

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

    \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
  5. Final simplification61.7%

    \[\leadsto x \cdot 2 + 27 \cdot \left(a \cdot b\right) \]

Alternative 11: 30.4% accurate, 5.7× speedup?

\[\begin{array}{l} [y, z, t] = \mathsf{sort}([y, z, t])\\ [a, b] = \mathsf{sort}([a, b])\\ \\ x \cdot 2 \end{array} \]
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b) :precision binary64 (* x 2.0))
assert(y < z && z < t);
assert(a < b);
double code(double x, double y, double z, double t, double a, double b) {
	return x * 2.0;
}
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this 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
    code = x * 2.0d0
end function
assert y < z && z < t;
assert a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	return x * 2.0;
}
[y, z, t] = sort([y, z, t])
[a, b] = sort([a, b])
def code(x, y, z, t, a, b):
	return x * 2.0
y, z, t = sort([y, z, t])
a, b = sort([a, b])
function code(x, y, z, t, a, b)
	return Float64(x * 2.0)
end
y, z, t = num2cell(sort([y, z, t])){:}
a, b = num2cell(sort([a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = x * 2.0;
end
NOTE: y, z, and t should be sorted in increasing order before calling this function.
NOTE: a and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := N[(x * 2.0), $MachinePrecision]
\begin{array}{l}
[y, z, t] = \mathsf{sort}([y, z, t])\\
[a, b] = \mathsf{sort}([a, b])\\
\\
x \cdot 2
\end{array}
Derivation
  1. Initial program 97.2%

    \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
  2. Step-by-step derivation
    1. +-commutative97.2%

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

      \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t} \]
    3. cancel-sign-sub-inv97.2%

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

      \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{t \cdot \left(-\left(y \cdot 9\right) \cdot z\right)} \]
    5. distribute-rgt-neg-out97.2%

      \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(-z\right)\right)} \]
    6. associate-*r*96.1%

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

      \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \color{blue}{\left(\left(y \cdot 9\right) \cdot t\right)} \cdot \left(-z\right) \]
    8. distribute-rgt-neg-in96.1%

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

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

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
    11. associate-*l*96.1%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)} \]
    13. fma-neg96.1%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \color{blue}{\mathsf{fma}\left(x, 2, -\left(\left(y \cdot 9\right) \cdot t\right) \cdot z\right)}\right) \]
    14. associate-*l*96.1%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{\left(y \cdot \left(9 \cdot t\right)\right)} \cdot z\right)\right) \]
    15. *-commutative96.1%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\left(y \cdot \color{blue}{\left(t \cdot 9\right)}\right) \cdot z\right)\right) \]
    16. associate-*r*95.3%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, -\color{blue}{y \cdot \left(\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
    17. distribute-rgt-neg-in95.3%

      \[\leadsto \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, \color{blue}{y \cdot \left(-\left(t \cdot 9\right) \cdot z\right)}\right)\right) \]
  3. Simplified95.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)\right)\right)} \]
  4. Step-by-step derivation
    1. fma-udef95.4%

      \[\leadsto \color{blue}{a \cdot \left(27 \cdot b\right) + \mathsf{fma}\left(x, 2, y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)\right)} \]
    2. fma-udef95.4%

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

      \[\leadsto \color{blue}{\left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right) + y \cdot \left(t \cdot \left(-9 \cdot z\right)\right)} \]
    4. associate-*r*96.1%

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

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

    \[\leadsto \color{blue}{\left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right) + \left(y \cdot t\right) \cdot \left(z \cdot -9\right)} \]
  6. Taylor expanded in x around inf 29.4%

    \[\leadsto \color{blue}{2 \cdot x} \]
  7. Final simplification29.4%

    \[\leadsto x \cdot 2 \]

Developer target: 94.5% 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 2023275 
(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)))