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

Percentage Accurate: 94.4% → 98.7%
Time: 5.3s
Alternatives: 13
Speedup: 0.4×

Specification

?
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
(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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    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]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b

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 13 alternatives:

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

Initial Program: 94.4% accurate, 1.0× speedup?

\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
(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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    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]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b

Alternative 1: 98.7% accurate, 0.3× speedup?

\[\begin{array}{l} t_1 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_2 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_2\right)\\ t_4 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_2\right)\\ \mathbf{if}\;t\_4 \leq 2000000000:\\ \;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_3 \cdot t\_4\right), t\_1, \mathsf{fma}\left(b \cdot a, 27, x + x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(t\_1 \cdot 9\right) \cdot t\_4\right) \cdot t\_3\right) + \left(a \cdot 27\right) \cdot b\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (let* ((t_1 (fmin (fmin y z) t))
       (t_2 (fmax (fmin y z) t))
       (t_3 (fmax (fmax y z) t_2))
       (t_4 (fmin (fmax y z) t_2)))
  (if (<= t_4 2000000000.0)
    (fma (* -9.0 (* t_3 t_4)) t_1 (fma (* b a) 27.0 (+ x x)))
    (+ (- (* x 2.0) (* (* (* t_1 9.0) t_4) t_3)) (* (* a 27.0) b)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fmin(fmin(y, z), t);
	double t_2 = fmax(fmin(y, z), t);
	double t_3 = fmax(fmax(y, z), t_2);
	double t_4 = fmin(fmax(y, z), t_2);
	double tmp;
	if (t_4 <= 2000000000.0) {
		tmp = fma((-9.0 * (t_3 * t_4)), t_1, fma((b * a), 27.0, (x + x)));
	} else {
		tmp = ((x * 2.0) - (((t_1 * 9.0) * t_4) * t_3)) + ((a * 27.0) * b);
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fmin(fmin(y, z), t)
	t_2 = fmax(fmin(y, z), t)
	t_3 = fmax(fmax(y, z), t_2)
	t_4 = fmin(fmax(y, z), t_2)
	tmp = 0.0
	if (t_4 <= 2000000000.0)
		tmp = fma(Float64(-9.0 * Float64(t_3 * t_4)), t_1, fma(Float64(b * a), 27.0, Float64(x + x)));
	else
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(t_1 * 9.0) * t_4) * t_3)) + Float64(Float64(a * 27.0) * b));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Min[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[y, z], $MachinePrecision], t$95$2], $MachinePrecision]}, Block[{t$95$4 = N[Min[N[Max[y, z], $MachinePrecision], t$95$2], $MachinePrecision]}, If[LessEqual[t$95$4, 2000000000.0], N[(N[(-9.0 * N[(t$95$3 * t$95$4), $MachinePrecision]), $MachinePrecision] * t$95$1 + N[(N[(b * a), $MachinePrecision] * 27.0 + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(t$95$1 * 9.0), $MachinePrecision] * t$95$4), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_2 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_2\right)\\
t_4 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_2\right)\\
\mathbf{if}\;t\_4 \leq 2000000000:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_3 \cdot t\_4\right), t\_1, \mathsf{fma}\left(b \cdot a, 27, x + x\right)\right)\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2e9

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{\left(a \cdot 27\right) \cdot b} \]
      3. lift-*.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{a \cdot \left(27 \cdot b\right)} \]
      5. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right)} \]
      6. lift--.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)} - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      7. lift-*.f64N/A

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \color{blue}{\left(\mathsf{neg}\left(a \cdot 27\right)\right)} \cdot b \]
      12. lift-*.f64N/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \left(\mathsf{neg}\left(\color{blue}{a \cdot 27}\right)\right) \cdot b \]
      13. associate--l+N/A

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

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

    if 2e9 < z

    1. Initial program 94.4%

      \[\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. Add Preprocessing

Alternative 2: 98.5% accurate, 0.4× speedup?

\[\begin{array}{l} t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_2 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_3 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_4 := \mathsf{fma}\left(b \cdot a, 27, x + x\right)\\ t_5 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\ \mathbf{if}\;t\_5 \leq -5 \cdot 10^{+23}:\\ \;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot t\_3\right), t\_5, t\_4\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot t\_5\right), t\_3, t\_4\right)\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (let* ((t_1 (fmax (fmin y z) t))
       (t_2 (fmax (fmax y z) t_1))
       (t_3 (fmin (fmax y z) t_1))
       (t_4 (fma (* b a) 27.0 (+ x x)))
       (t_5 (fmin (fmin y z) t)))
  (if (<= t_5 -5e+23)
    (fma (* -9.0 (* t_2 t_3)) t_5 t_4)
    (fma (* -9.0 (* t_2 t_5)) t_3 t_4))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fmax(fmin(y, z), t);
	double t_2 = fmax(fmax(y, z), t_1);
	double t_3 = fmin(fmax(y, z), t_1);
	double t_4 = fma((b * a), 27.0, (x + x));
	double t_5 = fmin(fmin(y, z), t);
	double tmp;
	if (t_5 <= -5e+23) {
		tmp = fma((-9.0 * (t_2 * t_3)), t_5, t_4);
	} else {
		tmp = fma((-9.0 * (t_2 * t_5)), t_3, t_4);
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fmax(fmin(y, z), t)
	t_2 = fmax(fmax(y, z), t_1)
	t_3 = fmin(fmax(y, z), t_1)
	t_4 = fma(Float64(b * a), 27.0, Float64(x + x))
	t_5 = fmin(fmin(y, z), t)
	tmp = 0.0
	if (t_5 <= -5e+23)
		tmp = fma(Float64(-9.0 * Float64(t_2 * t_3)), t_5, t_4);
	else
		tmp = fma(Float64(-9.0 * Float64(t_2 * t_5)), t_3, t_4);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Max[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Min[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$4 = N[(N[(b * a), $MachinePrecision] * 27.0 + N[(x + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Min[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, If[LessEqual[t$95$5, -5e+23], N[(N[(-9.0 * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision] * t$95$5 + t$95$4), $MachinePrecision], N[(N[(-9.0 * N[(t$95$2 * t$95$5), $MachinePrecision]), $MachinePrecision] * t$95$3 + t$95$4), $MachinePrecision]]]]]]]
\begin{array}{l}
t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_3 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_4 := \mathsf{fma}\left(b \cdot a, 27, x + x\right)\\
t_5 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\
\mathbf{if}\;t\_5 \leq -5 \cdot 10^{+23}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot t\_3\right), t\_5, t\_4\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot t\_5\right), t\_3, t\_4\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.9999999999999999e23

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{\left(a \cdot 27\right) \cdot b} \]
      3. lift-*.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{a \cdot \left(27 \cdot b\right)} \]
      5. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right)} \]
      6. lift--.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)} - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      7. lift-*.f64N/A

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \color{blue}{\left(\mathsf{neg}\left(a \cdot 27\right)\right)} \cdot b \]
      12. lift-*.f64N/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \left(\mathsf{neg}\left(\color{blue}{a \cdot 27}\right)\right) \cdot b \]
      13. associate--l+N/A

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

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

    if -4.9999999999999999e23 < y

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{\left(a \cdot 27\right) \cdot b} \]
      3. lift-*.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{a \cdot \left(27 \cdot b\right)} \]
      5. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right)} \]
      6. lift--.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)} - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      7. lift-*.f64N/A

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \color{blue}{\left(\mathsf{neg}\left(a \cdot 27\right)\right)} \cdot b \]
      12. lift-*.f64N/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \left(\mathsf{neg}\left(\color{blue}{a \cdot 27}\right)\right) \cdot b \]
      13. associate--l+N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right)} \]
      14. *-commutativeN/A

        \[\leadsto \color{blue}{t \cdot \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      15. lift-*.f64N/A

        \[\leadsto t \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right) \cdot z}\right)\right) + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      16. distribute-rgt-neg-inN/A

        \[\leadsto t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      17. associate-*r*N/A

        \[\leadsto \color{blue}{\left(t \cdot \left(y \cdot 9\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      18. distribute-rgt-neg-inN/A

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

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

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

Alternative 3: 94.1% accurate, 0.7× speedup?

\[\begin{array}{l} \mathbf{if}\;\mathsf{min}\left(y, t\right) \leq -1.75 \cdot 10^{+204}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, \left(\left(\mathsf{max}\left(y, t\right) \cdot z\right) \cdot -9\right) \cdot \mathsf{min}\left(y, t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-9 \cdot \left(\mathsf{max}\left(y, t\right) \cdot \mathsf{min}\left(y, t\right)\right), z, \mathsf{fma}\left(b \cdot a, 27, x + x\right)\right)\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (if (<= (fmin y t) -1.75e+204)
  (fma (* 27.0 b) a (* (* (* (fmax y t) z) -9.0) (fmin y t)))
  (fma
   (* -9.0 (* (fmax y t) (fmin y t)))
   z
   (fma (* b a) 27.0 (+ x x)))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (fmin(y, t) <= -1.75e+204) {
		tmp = fma((27.0 * b), a, (((fmax(y, t) * z) * -9.0) * fmin(y, t)));
	} else {
		tmp = fma((-9.0 * (fmax(y, t) * fmin(y, t))), z, fma((b * a), 27.0, (x + x)));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (fmin(y, t) <= -1.75e+204)
		tmp = fma(Float64(27.0 * b), a, Float64(Float64(Float64(fmax(y, t) * z) * -9.0) * fmin(y, t)));
	else
		tmp = fma(Float64(-9.0 * Float64(fmax(y, t) * fmin(y, t))), z, fma(Float64(b * a), 27.0, Float64(x + x)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[Min[y, t], $MachinePrecision], -1.75e+204], N[(N[(27.0 * b), $MachinePrecision] * a + N[(N[(N[(N[Max[y, t], $MachinePrecision] * z), $MachinePrecision] * -9.0), $MachinePrecision] * N[Min[y, t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-9.0 * N[(N[Max[y, t], $MachinePrecision] * N[Min[y, t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + N[(N[(b * a), $MachinePrecision] * 27.0 + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{min}\left(y, t\right) \leq -1.75 \cdot 10^{+204}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot b, a, \left(\left(\mathsf{max}\left(y, t\right) \cdot z\right) \cdot -9\right) \cdot \mathsf{min}\left(y, t\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(\mathsf{max}\left(y, t\right) \cdot \mathsf{min}\left(y, t\right)\right), z, \mathsf{fma}\left(b \cdot a, 27, x + x\right)\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.7499999999999999e204

    1. Initial program 94.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. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      4. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right)} \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      5. associate-*l*N/A

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

        \[\leadsto \color{blue}{\left(27 \cdot b\right) \cdot a} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      7. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{27 \cdot b}, a, -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right) \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \left(t \cdot \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \color{blue}{\left(y \cdot z\right)}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \left(y \cdot \color{blue}{z}\right)\right) \]
      13. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot z\right) \cdot \color{blue}{y}\right) \]
      15. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      17. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      18. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot \color{blue}{y}\right) \]
      19. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
      21. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
    6. Applied rewrites67.3%

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

    if -1.7499999999999999e204 < y

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{\left(a \cdot 27\right) \cdot b} \]
      3. lift-*.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{a \cdot \left(27 \cdot b\right)} \]
      5. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right)} \]
      6. lift--.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)} - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      7. lift-*.f64N/A

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \color{blue}{\left(\mathsf{neg}\left(a \cdot 27\right)\right)} \cdot b \]
      12. lift-*.f64N/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \left(\mathsf{neg}\left(\color{blue}{a \cdot 27}\right)\right) \cdot b \]
      13. associate--l+N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right)} \]
      14. *-commutativeN/A

        \[\leadsto \color{blue}{t \cdot \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      15. lift-*.f64N/A

        \[\leadsto t \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right) \cdot z}\right)\right) + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      16. distribute-rgt-neg-inN/A

        \[\leadsto t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      17. associate-*r*N/A

        \[\leadsto \color{blue}{\left(t \cdot \left(y \cdot 9\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      18. distribute-rgt-neg-inN/A

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

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

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

Alternative 4: 87.4% accurate, 0.2× speedup?

\[\begin{array}{l} t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_4 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_5 := \left(\left(t\_4 \cdot 9\right) \cdot t\_2\right) \cdot t\_3\\ \mathbf{if}\;t\_5 \leq -5 \cdot 10^{+52}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, \left(\left(t\_3 \cdot t\_2\right) \cdot -9\right) \cdot t\_4\right)\\ \mathbf{elif}\;t\_5 \leq 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b \cdot 27, a, \left(\left(-9 \cdot t\_4\right) \cdot t\_2\right) \cdot t\_3\right)\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (let* ((t_1 (fmax (fmin y z) t))
       (t_2 (fmin (fmax y z) t_1))
       (t_3 (fmax (fmax y z) t_1))
       (t_4 (fmin (fmin y z) t))
       (t_5 (* (* (* t_4 9.0) t_2) t_3)))
  (if (<= t_5 -5e+52)
    (fma (* 27.0 b) a (* (* (* t_3 t_2) -9.0) t_4))
    (if (<= t_5 1e-8)
      (fma (* a 27.0) b (+ x x))
      (fma (* b 27.0) a (* (* (* -9.0 t_4) t_2) t_3))))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fmax(fmin(y, z), t);
	double t_2 = fmin(fmax(y, z), t_1);
	double t_3 = fmax(fmax(y, z), t_1);
	double t_4 = fmin(fmin(y, z), t);
	double t_5 = ((t_4 * 9.0) * t_2) * t_3;
	double tmp;
	if (t_5 <= -5e+52) {
		tmp = fma((27.0 * b), a, (((t_3 * t_2) * -9.0) * t_4));
	} else if (t_5 <= 1e-8) {
		tmp = fma((a * 27.0), b, (x + x));
	} else {
		tmp = fma((b * 27.0), a, (((-9.0 * t_4) * t_2) * t_3));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fmax(fmin(y, z), t)
	t_2 = fmin(fmax(y, z), t_1)
	t_3 = fmax(fmax(y, z), t_1)
	t_4 = fmin(fmin(y, z), t)
	t_5 = Float64(Float64(Float64(t_4 * 9.0) * t_2) * t_3)
	tmp = 0.0
	if (t_5 <= -5e+52)
		tmp = fma(Float64(27.0 * b), a, Float64(Float64(Float64(t_3 * t_2) * -9.0) * t_4));
	elseif (t_5 <= 1e-8)
		tmp = fma(Float64(a * 27.0), b, Float64(x + x));
	else
		tmp = fma(Float64(b * 27.0), a, Float64(Float64(Float64(-9.0 * t_4) * t_2) * t_3));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Max[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$4 = N[Min[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[(t$95$4 * 9.0), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision]}, If[LessEqual[t$95$5, -5e+52], N[(N[(27.0 * b), $MachinePrecision] * a + N[(N[(N[(t$95$3 * t$95$2), $MachinePrecision] * -9.0), $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 1e-8], N[(N[(a * 27.0), $MachinePrecision] * b + N[(x + x), $MachinePrecision]), $MachinePrecision], N[(N[(b * 27.0), $MachinePrecision] * a + N[(N[(N[(-9.0 * t$95$4), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_4 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_5 := \left(\left(t\_4 \cdot 9\right) \cdot t\_2\right) \cdot t\_3\\
\mathbf{if}\;t\_5 \leq -5 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot b, a, \left(\left(t\_3 \cdot t\_2\right) \cdot -9\right) \cdot t\_4\right)\\

\mathbf{elif}\;t\_5 \leq 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b \cdot 27, a, \left(\left(-9 \cdot t\_4\right) \cdot t\_2\right) \cdot t\_3\right)\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -5e52

    1. Initial program 94.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. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      4. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right)} \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      5. associate-*l*N/A

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

        \[\leadsto \color{blue}{\left(27 \cdot b\right) \cdot a} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      7. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{27 \cdot b}, a, -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right) \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \left(t \cdot \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \color{blue}{\left(y \cdot z\right)}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \left(y \cdot \color{blue}{z}\right)\right) \]
      13. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot z\right) \cdot \color{blue}{y}\right) \]
      15. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      17. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      18. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot \color{blue}{y}\right) \]
      19. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
      21. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
    6. Applied rewrites67.3%

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

    if -5e52 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 1e-8

    1. Initial program 94.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. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f6464.2%

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    4. Applied rewrites64.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      2. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      3. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
      4. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
      5. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      6. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
      8. count-2-revN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
      11. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      12. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      15. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      16. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      17. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      19. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      21. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      22. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      25. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      26. distribute-rgt-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      27. distribute-lft-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
      28. remove-double-negN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
      29. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
    6. Applied rewrites64.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(x + x\right)} \]
      2. lift-+.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(x + \color{blue}{x}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + \color{blue}{x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + x \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(b \cdot 27\right) \cdot a + x\right) + x \]
      6. associate-*l*N/A

        \[\leadsto \left(b \cdot \left(27 \cdot a\right) + x\right) + x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot \left(a \cdot 27\right) + x\right) + x \]
      8. associate-*l*N/A

        \[\leadsto \left(\left(b \cdot a\right) \cdot 27 + x\right) + x \]
      9. associate-+r+N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{\left(x + x\right)} \]
      10. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      11. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      12. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      13. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. count-2N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      15. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      16. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      18. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      19. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      20. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      21. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      22. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(2 \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      23. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      24. sub-flip-reverseN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - x\right)\right)\right) \]
      25. sub-negate-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      26. add-flipN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      27. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      28. lower-fma.f6464.2%

        \[\leadsto \mathsf{fma}\left(a \cdot 27, \color{blue}{b}, x + x\right) \]
    8. Applied rewrites64.2%

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

    if 1e-8 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t)

    1. Initial program 94.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. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      4. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right)} \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      5. associate-*l*N/A

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

        \[\leadsto \color{blue}{\left(27 \cdot b\right) \cdot a} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      7. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{27 \cdot b}, a, -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right) \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \left(t \cdot \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \color{blue}{\left(y \cdot z\right)}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \left(y \cdot \color{blue}{z}\right)\right) \]
      13. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot z\right) \cdot \color{blue}{y}\right) \]
      15. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      17. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      18. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot \color{blue}{y}\right) \]
      19. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
      21. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
    6. Applied rewrites67.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right)} \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, y \cdot \color{blue}{\left(\left(t \cdot z\right) \cdot -9\right)}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, y \cdot \left(\left(t \cdot z\right) \cdot \color{blue}{-9}\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(y \cdot \left(t \cdot z\right)\right) \cdot \color{blue}{-9}\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot y\right) \cdot -9\right) \]
      6. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot y\right) \cdot -9\right) \]
      7. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(t \cdot \left(z \cdot y\right)\right) \cdot -9\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(t \cdot \left(y \cdot z\right)\right) \cdot -9\right) \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(t \cdot \left(y \cdot z\right)\right) \cdot -9\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(t \cdot \left(y \cdot z\right)\right) \cdot -9\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \left(t \cdot \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \color{blue}{\left(y \cdot z\right)}\right) \]
      14. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \left(y \cdot \color{blue}{z}\right)\right) \]
      15. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot y\right) \cdot \color{blue}{z}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot y\right) \cdot \color{blue}{z}\right) \]
      17. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot y\right)\right) \cdot z\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(y \cdot t\right)\right) \cdot z\right) \]
      19. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot y\right) \cdot t\right) \cdot z\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(y \cdot -9\right) \cdot t\right) \cdot z\right) \]
      21. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(y \cdot \left(\mathsf{neg}\left(9\right)\right)\right) \cdot t\right) \cdot z\right) \]
      22. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(\mathsf{neg}\left(y \cdot 9\right)\right) \cdot t\right) \cdot z\right) \]
      23. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(\mathsf{neg}\left(y \cdot 9\right)\right) \cdot t\right) \cdot z\right) \]
      24. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(y \cdot \left(\mathsf{neg}\left(9\right)\right)\right) \cdot t\right) \cdot z\right) \]
      25. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(y \cdot -9\right) \cdot t\right) \cdot z\right) \]
      26. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot y\right) \cdot t\right) \cdot z\right) \]
      27. lower-*.f6467.0%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot y\right) \cdot t\right) \cdot z\right) \]
    8. Applied rewrites67.0%

      \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot y\right) \cdot t\right) \cdot \color{blue}{z}\right) \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{b \cdot 27}, a, \left(\left(-9 \cdot y\right) \cdot t\right) \cdot z\right) \]
      3. lower-*.f6467.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{b \cdot 27}, a, \left(\left(-9 \cdot y\right) \cdot t\right) \cdot z\right) \]
      4. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\left(-9 \cdot y\right) \cdot t\right) \cdot \color{blue}{z}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\left(-9 \cdot y\right) \cdot t\right) \cdot z\right) \]
      6. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(-9 \cdot y\right) \cdot \color{blue}{\left(t \cdot z\right)}\right) \]
      7. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(-9 \cdot y\right) \cdot \left(\color{blue}{t} \cdot z\right)\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, -9 \cdot \color{blue}{\left(y \cdot \left(t \cdot z\right)\right)}\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\mathsf{neg}\left(9\right)\right) \cdot \left(\color{blue}{y} \cdot \left(t \cdot z\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\mathsf{neg}\left(9\right)\right) \cdot \left(y \cdot \left(z \cdot \color{blue}{t}\right)\right)\right) \]
      11. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \mathsf{neg}\left(9 \cdot \left(y \cdot \left(z \cdot t\right)\right)\right)\right) \]
      12. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \mathsf{neg}\left(\left(9 \cdot y\right) \cdot \left(z \cdot t\right)\right)\right) \]
      13. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \mathsf{neg}\left(\left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) \]
      15. distribute-lft-neg-outN/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot \color{blue}{t}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot \color{blue}{t}\right) \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\left(\mathsf{neg}\left(y \cdot 9\right)\right) \cdot z\right) \cdot t\right) \]
      18. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\left(y \cdot \left(\mathsf{neg}\left(9\right)\right)\right) \cdot z\right) \cdot t\right) \]
      19. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\left(y \cdot -9\right) \cdot z\right) \cdot t\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\left(-9 \cdot y\right) \cdot z\right) \cdot t\right) \]
      21. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\left(-9 \cdot y\right) \cdot z\right) \cdot t\right) \]
      22. lower-*.f6467.0%

        \[\leadsto \mathsf{fma}\left(b \cdot 27, a, \left(\left(-9 \cdot y\right) \cdot z\right) \cdot t\right) \]
    10. Applied rewrites67.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(b \cdot 27, a, \left(\left(-9 \cdot y\right) \cdot z\right) \cdot t\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 87.2% accurate, 0.2× speedup?

\[\begin{array}{l} t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_4 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_5 := \left(\left(t\_4 \cdot 9\right) \cdot t\_2\right) \cdot t\_3\\ \mathbf{if}\;t\_5 \leq -5 \cdot 10^{+52}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, \left(\left(t\_3 \cdot t\_2\right) \cdot -9\right) \cdot t\_4\right)\\ \mathbf{elif}\;t\_5 \leq 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot t\_4\right), t\_3, 27 \cdot \left(a \cdot b\right)\right)\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (let* ((t_1 (fmax (fmin y z) t))
       (t_2 (fmin (fmax y z) t_1))
       (t_3 (fmax (fmax y z) t_1))
       (t_4 (fmin (fmin y z) t))
       (t_5 (* (* (* t_4 9.0) t_2) t_3)))
  (if (<= t_5 -5e+52)
    (fma (* 27.0 b) a (* (* (* t_3 t_2) -9.0) t_4))
    (if (<= t_5 1e-8)
      (fma (* a 27.0) b (+ x x))
      (fma (* -9.0 (* t_2 t_4)) t_3 (* 27.0 (* a b)))))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fmax(fmin(y, z), t);
	double t_2 = fmin(fmax(y, z), t_1);
	double t_3 = fmax(fmax(y, z), t_1);
	double t_4 = fmin(fmin(y, z), t);
	double t_5 = ((t_4 * 9.0) * t_2) * t_3;
	double tmp;
	if (t_5 <= -5e+52) {
		tmp = fma((27.0 * b), a, (((t_3 * t_2) * -9.0) * t_4));
	} else if (t_5 <= 1e-8) {
		tmp = fma((a * 27.0), b, (x + x));
	} else {
		tmp = fma((-9.0 * (t_2 * t_4)), t_3, (27.0 * (a * b)));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fmax(fmin(y, z), t)
	t_2 = fmin(fmax(y, z), t_1)
	t_3 = fmax(fmax(y, z), t_1)
	t_4 = fmin(fmin(y, z), t)
	t_5 = Float64(Float64(Float64(t_4 * 9.0) * t_2) * t_3)
	tmp = 0.0
	if (t_5 <= -5e+52)
		tmp = fma(Float64(27.0 * b), a, Float64(Float64(Float64(t_3 * t_2) * -9.0) * t_4));
	elseif (t_5 <= 1e-8)
		tmp = fma(Float64(a * 27.0), b, Float64(x + x));
	else
		tmp = fma(Float64(-9.0 * Float64(t_2 * t_4)), t_3, Float64(27.0 * Float64(a * b)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Max[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$4 = N[Min[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[(t$95$4 * 9.0), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision]}, If[LessEqual[t$95$5, -5e+52], N[(N[(27.0 * b), $MachinePrecision] * a + N[(N[(N[(t$95$3 * t$95$2), $MachinePrecision] * -9.0), $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 1e-8], N[(N[(a * 27.0), $MachinePrecision] * b + N[(x + x), $MachinePrecision]), $MachinePrecision], N[(N[(-9.0 * N[(t$95$2 * t$95$4), $MachinePrecision]), $MachinePrecision] * t$95$3 + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_4 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_5 := \left(\left(t\_4 \cdot 9\right) \cdot t\_2\right) \cdot t\_3\\
\mathbf{if}\;t\_5 \leq -5 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot b, a, \left(\left(t\_3 \cdot t\_2\right) \cdot -9\right) \cdot t\_4\right)\\

\mathbf{elif}\;t\_5 \leq 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot t\_4\right), t\_3, 27 \cdot \left(a \cdot b\right)\right)\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -5e52

    1. Initial program 94.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. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      4. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right)} \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      5. associate-*l*N/A

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

        \[\leadsto \color{blue}{\left(27 \cdot b\right) \cdot a} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      7. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{27 \cdot b}, a, -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right) \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \left(t \cdot \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \color{blue}{\left(y \cdot z\right)}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \left(y \cdot \color{blue}{z}\right)\right) \]
      13. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot z\right) \cdot \color{blue}{y}\right) \]
      15. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      17. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      18. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot \color{blue}{y}\right) \]
      19. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
      21. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
    6. Applied rewrites67.3%

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

    if -5e52 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 1e-8

    1. Initial program 94.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. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f6464.2%

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    4. Applied rewrites64.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      2. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      3. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
      4. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
      5. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      6. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
      8. count-2-revN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
      11. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      12. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      15. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      16. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      17. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      19. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      21. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      22. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      25. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      26. distribute-rgt-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      27. distribute-lft-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
      28. remove-double-negN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
      29. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
    6. Applied rewrites64.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(x + x\right)} \]
      2. lift-+.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(x + \color{blue}{x}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + \color{blue}{x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + x \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(b \cdot 27\right) \cdot a + x\right) + x \]
      6. associate-*l*N/A

        \[\leadsto \left(b \cdot \left(27 \cdot a\right) + x\right) + x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot \left(a \cdot 27\right) + x\right) + x \]
      8. associate-*l*N/A

        \[\leadsto \left(\left(b \cdot a\right) \cdot 27 + x\right) + x \]
      9. associate-+r+N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{\left(x + x\right)} \]
      10. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      11. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      12. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      13. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. count-2N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      15. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      16. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      18. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      19. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      20. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      21. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      22. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(2 \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      23. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      24. sub-flip-reverseN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - x\right)\right)\right) \]
      25. sub-negate-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      26. add-flipN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      27. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      28. lower-fma.f6464.2%

        \[\leadsto \mathsf{fma}\left(a \cdot 27, \color{blue}{b}, x + x\right) \]
    8. Applied rewrites64.2%

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

    if 1e-8 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t)

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\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)} \]
      3. lift--.f64N/A

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

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) \]
      5. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t\right)} \]
      6. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      8. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right) \cdot z}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(9 \cdot y\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      12. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{9 \cdot \left(y \cdot z\right)}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(y \cdot z\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(9\right)\right) \cdot \color{blue}{\left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-9} \cdot \left(z \cdot y\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      17. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{\left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right)}\right) \]
      19. sub-flipN/A

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

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

      \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{27 \cdot \left(a \cdot b\right)}\right) \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, 27 \cdot \left(a \cdot \color{blue}{b}\right)\right) \]
    6. Applied rewrites66.8%

      \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{27 \cdot \left(a \cdot b\right)}\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 86.9% accurate, 0.3× speedup?

\[\begin{array}{l} t_1 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\right)\\ t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\right)\\ t_3 := \left(\left(\mathsf{min}\left(y, z\right) \cdot 9\right) \cdot t\_2\right) \cdot t\_1\\ \mathbf{if}\;t\_3 \leq -5 \cdot 10^{+52}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\_1\right) \cdot t\_2\right) \cdot \mathsf{min}\left(y, z\right)\right)\\ \mathbf{elif}\;t\_3 \leq 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot \mathsf{min}\left(y, z\right)\right), t\_1, 27 \cdot \left(a \cdot b\right)\right)\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (let* ((t_1 (fmax (fmax y z) t))
       (t_2 (fmin (fmax y z) t))
       (t_3 (* (* (* (fmin y z) 9.0) t_2) t_1)))
  (if (<= t_3 -5e+52)
    (fma (* 27.0 b) a (* (* (* -9.0 t_1) t_2) (fmin y z)))
    (if (<= t_3 1e-8)
      (fma (* a 27.0) b (+ x x))
      (fma (* -9.0 (* t_2 (fmin y z))) t_1 (* 27.0 (* a b)))))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fmax(fmax(y, z), t);
	double t_2 = fmin(fmax(y, z), t);
	double t_3 = ((fmin(y, z) * 9.0) * t_2) * t_1;
	double tmp;
	if (t_3 <= -5e+52) {
		tmp = fma((27.0 * b), a, (((-9.0 * t_1) * t_2) * fmin(y, z)));
	} else if (t_3 <= 1e-8) {
		tmp = fma((a * 27.0), b, (x + x));
	} else {
		tmp = fma((-9.0 * (t_2 * fmin(y, z))), t_1, (27.0 * (a * b)));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fmax(fmax(y, z), t)
	t_2 = fmin(fmax(y, z), t)
	t_3 = Float64(Float64(Float64(fmin(y, z) * 9.0) * t_2) * t_1)
	tmp = 0.0
	if (t_3 <= -5e+52)
		tmp = fma(Float64(27.0 * b), a, Float64(Float64(Float64(-9.0 * t_1) * t_2) * fmin(y, z)));
	elseif (t_3 <= 1e-8)
		tmp = fma(Float64(a * 27.0), b, Float64(x + x));
	else
		tmp = fma(Float64(-9.0 * Float64(t_2 * fmin(y, z))), t_1, Float64(27.0 * Float64(a * b)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Max[N[Max[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[Min[y, z], $MachinePrecision] * 9.0), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, -5e+52], N[(N[(27.0 * b), $MachinePrecision] * a + N[(N[(N[(-9.0 * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision] * N[Min[y, z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1e-8], N[(N[(a * 27.0), $MachinePrecision] * b + N[(x + x), $MachinePrecision]), $MachinePrecision], N[(N[(-9.0 * N[(t$95$2 * N[Min[y, z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1 + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_1 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\right)\\
t_3 := \left(\left(\mathsf{min}\left(y, z\right) \cdot 9\right) \cdot t\_2\right) \cdot t\_1\\
\mathbf{if}\;t\_3 \leq -5 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\_1\right) \cdot t\_2\right) \cdot \mathsf{min}\left(y, z\right)\right)\\

\mathbf{elif}\;t\_3 \leq 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot \mathsf{min}\left(y, z\right)\right), t\_1, 27 \cdot \left(a \cdot b\right)\right)\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -5e52

    1. Initial program 94.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. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} + \left(a \cdot 27\right) \cdot b \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      3. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      4. lift-*.f64N/A

        \[\leadsto \color{blue}{\left(a \cdot 27\right)} \cdot b + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      5. associate-*l*N/A

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

        \[\leadsto \color{blue}{\left(27 \cdot b\right) \cdot a} + -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) \]
      7. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{27 \cdot b}, a, -9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right) \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \color{blue}{\left(t \cdot \left(y \cdot z\right)\right)}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, -9 \cdot \left(t \cdot \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \color{blue}{\left(y \cdot z\right)}\right) \]
      12. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot t\right) \cdot \left(y \cdot \color{blue}{z}\right)\right) \]
      13. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot z\right) \cdot \color{blue}{y}\right) \]
      15. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      16. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      17. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      18. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot \color{blue}{y}\right) \]
      19. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
      21. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
    6. Applied rewrites67.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right)} \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(t \cdot z\right) \cdot -9\right) \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(-9 \cdot \left(t \cdot z\right)\right) \cdot y\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot z\right) \cdot y\right) \]
      5. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot z\right) \cdot y\right) \]
      6. lower-*.f6467.3%

        \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \left(\left(-9 \cdot t\right) \cdot z\right) \cdot y\right) \]
    8. Applied rewrites67.3%

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

    if -5e52 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 1e-8

    1. Initial program 94.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. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f6464.2%

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    4. Applied rewrites64.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      2. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      3. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
      4. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
      5. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      6. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
      8. count-2-revN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
      11. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      12. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      15. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      16. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      17. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      19. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      21. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      22. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      25. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      26. distribute-rgt-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      27. distribute-lft-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
      28. remove-double-negN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
      29. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
    6. Applied rewrites64.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(x + x\right)} \]
      2. lift-+.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(x + \color{blue}{x}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + \color{blue}{x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + x \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(b \cdot 27\right) \cdot a + x\right) + x \]
      6. associate-*l*N/A

        \[\leadsto \left(b \cdot \left(27 \cdot a\right) + x\right) + x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot \left(a \cdot 27\right) + x\right) + x \]
      8. associate-*l*N/A

        \[\leadsto \left(\left(b \cdot a\right) \cdot 27 + x\right) + x \]
      9. associate-+r+N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{\left(x + x\right)} \]
      10. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      11. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      12. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      13. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. count-2N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      15. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      16. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      18. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      19. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      20. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      21. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      22. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(2 \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      23. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      24. sub-flip-reverseN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - x\right)\right)\right) \]
      25. sub-negate-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      26. add-flipN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      27. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      28. lower-fma.f6464.2%

        \[\leadsto \mathsf{fma}\left(a \cdot 27, \color{blue}{b}, x + x\right) \]
    8. Applied rewrites64.2%

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

    if 1e-8 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t)

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\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)} \]
      3. lift--.f64N/A

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

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) \]
      5. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t\right)} \]
      6. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      8. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right) \cdot z}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(9 \cdot y\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      12. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{9 \cdot \left(y \cdot z\right)}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(y \cdot z\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(9\right)\right) \cdot \color{blue}{\left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-9} \cdot \left(z \cdot y\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      17. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{\left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right)}\right) \]
      19. sub-flipN/A

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

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

      \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{27 \cdot \left(a \cdot b\right)}\right) \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, 27 \cdot \left(a \cdot \color{blue}{b}\right)\right) \]
    6. Applied rewrites66.8%

      \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{27 \cdot \left(a \cdot b\right)}\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 85.7% accurate, 0.2× speedup?

\[\begin{array}{l} t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_4 := 27 \cdot \left(a \cdot b\right)\\ t_5 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_6 := \left(\left(t\_5 \cdot 9\right) \cdot t\_2\right) \cdot t\_3\\ \mathbf{if}\;t\_6 \leq -5 \cdot 10^{+181}:\\ \;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_3 \cdot t\_5\right), t\_2, t\_4\right)\\ \mathbf{elif}\;t\_6 \leq 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot t\_5\right), t\_3, t\_4\right)\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (let* ((t_1 (fmax (fmin y z) t))
       (t_2 (fmin (fmax y z) t_1))
       (t_3 (fmax (fmax y z) t_1))
       (t_4 (* 27.0 (* a b)))
       (t_5 (fmin (fmin y z) t))
       (t_6 (* (* (* t_5 9.0) t_2) t_3)))
  (if (<= t_6 -5e+181)
    (fma (* -9.0 (* t_3 t_5)) t_2 t_4)
    (if (<= t_6 1e-8)
      (fma (* a 27.0) b (+ x x))
      (fma (* -9.0 (* t_2 t_5)) t_3 t_4)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fmax(fmin(y, z), t);
	double t_2 = fmin(fmax(y, z), t_1);
	double t_3 = fmax(fmax(y, z), t_1);
	double t_4 = 27.0 * (a * b);
	double t_5 = fmin(fmin(y, z), t);
	double t_6 = ((t_5 * 9.0) * t_2) * t_3;
	double tmp;
	if (t_6 <= -5e+181) {
		tmp = fma((-9.0 * (t_3 * t_5)), t_2, t_4);
	} else if (t_6 <= 1e-8) {
		tmp = fma((a * 27.0), b, (x + x));
	} else {
		tmp = fma((-9.0 * (t_2 * t_5)), t_3, t_4);
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fmax(fmin(y, z), t)
	t_2 = fmin(fmax(y, z), t_1)
	t_3 = fmax(fmax(y, z), t_1)
	t_4 = Float64(27.0 * Float64(a * b))
	t_5 = fmin(fmin(y, z), t)
	t_6 = Float64(Float64(Float64(t_5 * 9.0) * t_2) * t_3)
	tmp = 0.0
	if (t_6 <= -5e+181)
		tmp = fma(Float64(-9.0 * Float64(t_3 * t_5)), t_2, t_4);
	elseif (t_6 <= 1e-8)
		tmp = fma(Float64(a * 27.0), b, Float64(x + x));
	else
		tmp = fma(Float64(-9.0 * Float64(t_2 * t_5)), t_3, t_4);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Max[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$4 = N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Min[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$6 = N[(N[(N[(t$95$5 * 9.0), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision]}, If[LessEqual[t$95$6, -5e+181], N[(N[(-9.0 * N[(t$95$3 * t$95$5), $MachinePrecision]), $MachinePrecision] * t$95$2 + t$95$4), $MachinePrecision], If[LessEqual[t$95$6, 1e-8], N[(N[(a * 27.0), $MachinePrecision] * b + N[(x + x), $MachinePrecision]), $MachinePrecision], N[(N[(-9.0 * N[(t$95$2 * t$95$5), $MachinePrecision]), $MachinePrecision] * t$95$3 + t$95$4), $MachinePrecision]]]]]]]]]
\begin{array}{l}
t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_4 := 27 \cdot \left(a \cdot b\right)\\
t_5 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_6 := \left(\left(t\_5 \cdot 9\right) \cdot t\_2\right) \cdot t\_3\\
\mathbf{if}\;t\_6 \leq -5 \cdot 10^{+181}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_3 \cdot t\_5\right), t\_2, t\_4\right)\\

\mathbf{elif}\;t\_6 \leq 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_2 \cdot t\_5\right), t\_3, t\_4\right)\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -5.0000000000000003e181

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{\left(a \cdot 27\right) \cdot b} \]
      3. lift-*.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{a \cdot \left(27 \cdot b\right)} \]
      5. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right)} \]
      6. lift--.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)} - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      7. lift-*.f64N/A

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \color{blue}{\left(\mathsf{neg}\left(a \cdot 27\right)\right)} \cdot b \]
      12. lift-*.f64N/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \left(\mathsf{neg}\left(\color{blue}{a \cdot 27}\right)\right) \cdot b \]
      13. associate--l+N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right)} \]
      14. *-commutativeN/A

        \[\leadsto \color{blue}{t \cdot \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      15. lift-*.f64N/A

        \[\leadsto t \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right) \cdot z}\right)\right) + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      16. distribute-rgt-neg-inN/A

        \[\leadsto t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      17. associate-*r*N/A

        \[\leadsto \color{blue}{\left(t \cdot \left(y \cdot 9\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      18. distribute-rgt-neg-inN/A

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

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

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

      \[\leadsto \mathsf{fma}\left(-9 \cdot \left(t \cdot y\right), z, \color{blue}{27 \cdot \left(a \cdot b\right)}\right) \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(t \cdot y\right), z, 27 \cdot \left(a \cdot \color{blue}{b}\right)\right) \]
    6. Applied rewrites66.8%

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

    if -5.0000000000000003e181 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 1e-8

    1. Initial program 94.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. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f6464.2%

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    4. Applied rewrites64.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      2. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      3. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
      4. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
      5. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      6. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
      8. count-2-revN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
      11. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      12. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      15. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      16. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      17. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      19. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      21. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      22. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      25. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      26. distribute-rgt-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      27. distribute-lft-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
      28. remove-double-negN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
      29. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
    6. Applied rewrites64.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(x + x\right)} \]
      2. lift-+.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(x + \color{blue}{x}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + \color{blue}{x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + x \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(b \cdot 27\right) \cdot a + x\right) + x \]
      6. associate-*l*N/A

        \[\leadsto \left(b \cdot \left(27 \cdot a\right) + x\right) + x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot \left(a \cdot 27\right) + x\right) + x \]
      8. associate-*l*N/A

        \[\leadsto \left(\left(b \cdot a\right) \cdot 27 + x\right) + x \]
      9. associate-+r+N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{\left(x + x\right)} \]
      10. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      11. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      12. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      13. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. count-2N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      15. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      16. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      18. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      19. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      20. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      21. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      22. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(2 \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      23. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      24. sub-flip-reverseN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - x\right)\right)\right) \]
      25. sub-negate-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      26. add-flipN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      27. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      28. lower-fma.f6464.2%

        \[\leadsto \mathsf{fma}\left(a \cdot 27, \color{blue}{b}, x + x\right) \]
    8. Applied rewrites64.2%

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

    if 1e-8 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t)

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\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)} \]
      3. lift--.f64N/A

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

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) \]
      5. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t\right)} \]
      6. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      8. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right) \cdot z}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(9 \cdot y\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      12. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{9 \cdot \left(y \cdot z\right)}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(y \cdot z\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(9\right)\right) \cdot \color{blue}{\left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-9} \cdot \left(z \cdot y\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      17. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{\left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right)}\right) \]
      19. sub-flipN/A

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

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

      \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{27 \cdot \left(a \cdot b\right)}\right) \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, 27 \cdot \left(a \cdot \color{blue}{b}\right)\right) \]
    6. Applied rewrites66.8%

      \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{27 \cdot \left(a \cdot b\right)}\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 85.2% accurate, 0.2× speedup?

\[\begin{array}{l} t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\ t_4 := 27 \cdot \left(a \cdot b\right)\\ t_5 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\ t_6 := \left(\left(t\_5 \cdot 9\right) \cdot t\_2\right) \cdot t\_3\\ \mathbf{if}\;t\_6 \leq -5 \cdot 10^{+181}:\\ \;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_3 \cdot t\_5\right), t\_2, t\_4\right)\\ \mathbf{elif}\;t\_6 \leq 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-9, t\_3 \cdot \left(t\_5 \cdot t\_2\right), t\_4\right)\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (let* ((t_1 (fmax (fmin y z) t))
       (t_2 (fmin (fmax y z) t_1))
       (t_3 (fmax (fmax y z) t_1))
       (t_4 (* 27.0 (* a b)))
       (t_5 (fmin (fmin y z) t))
       (t_6 (* (* (* t_5 9.0) t_2) t_3)))
  (if (<= t_6 -5e+181)
    (fma (* -9.0 (* t_3 t_5)) t_2 t_4)
    (if (<= t_6 1e-8)
      (fma (* a 27.0) b (+ x x))
      (fma -9.0 (* t_3 (* t_5 t_2)) t_4)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fmax(fmin(y, z), t);
	double t_2 = fmin(fmax(y, z), t_1);
	double t_3 = fmax(fmax(y, z), t_1);
	double t_4 = 27.0 * (a * b);
	double t_5 = fmin(fmin(y, z), t);
	double t_6 = ((t_5 * 9.0) * t_2) * t_3;
	double tmp;
	if (t_6 <= -5e+181) {
		tmp = fma((-9.0 * (t_3 * t_5)), t_2, t_4);
	} else if (t_6 <= 1e-8) {
		tmp = fma((a * 27.0), b, (x + x));
	} else {
		tmp = fma(-9.0, (t_3 * (t_5 * t_2)), t_4);
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fmax(fmin(y, z), t)
	t_2 = fmin(fmax(y, z), t_1)
	t_3 = fmax(fmax(y, z), t_1)
	t_4 = Float64(27.0 * Float64(a * b))
	t_5 = fmin(fmin(y, z), t)
	t_6 = Float64(Float64(Float64(t_5 * 9.0) * t_2) * t_3)
	tmp = 0.0
	if (t_6 <= -5e+181)
		tmp = fma(Float64(-9.0 * Float64(t_3 * t_5)), t_2, t_4);
	elseif (t_6 <= 1e-8)
		tmp = fma(Float64(a * 27.0), b, Float64(x + x));
	else
		tmp = fma(-9.0, Float64(t_3 * Float64(t_5 * t_2)), t_4);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[Max[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$2 = N[Min[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[y, z], $MachinePrecision], t$95$1], $MachinePrecision]}, Block[{t$95$4 = N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Min[N[Min[y, z], $MachinePrecision], t], $MachinePrecision]}, Block[{t$95$6 = N[(N[(N[(t$95$5 * 9.0), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision]}, If[LessEqual[t$95$6, -5e+181], N[(N[(-9.0 * N[(t$95$3 * t$95$5), $MachinePrecision]), $MachinePrecision] * t$95$2 + t$95$4), $MachinePrecision], If[LessEqual[t$95$6, 1e-8], N[(N[(a * 27.0), $MachinePrecision] * b + N[(x + x), $MachinePrecision]), $MachinePrecision], N[(-9.0 * N[(t$95$3 * N[(t$95$5 * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]]]]]]]]]
\begin{array}{l}
t_1 := \mathsf{max}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_2 := \mathsf{min}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(y, z\right), t\_1\right)\\
t_4 := 27 \cdot \left(a \cdot b\right)\\
t_5 := \mathsf{min}\left(\mathsf{min}\left(y, z\right), t\right)\\
t_6 := \left(\left(t\_5 \cdot 9\right) \cdot t\_2\right) \cdot t\_3\\
\mathbf{if}\;t\_6 \leq -5 \cdot 10^{+181}:\\
\;\;\;\;\mathsf{fma}\left(-9 \cdot \left(t\_3 \cdot t\_5\right), t\_2, t\_4\right)\\

\mathbf{elif}\;t\_6 \leq 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-9, t\_3 \cdot \left(t\_5 \cdot t\_2\right), t\_4\right)\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < -5.0000000000000003e181

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{\left(a \cdot 27\right) \cdot b} \]
      3. lift-*.f64N/A

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

        \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{a \cdot \left(27 \cdot b\right)} \]
      5. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right)} \]
      6. lift--.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)} - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      7. lift-*.f64N/A

        \[\leadsto \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) - \left(\mathsf{neg}\left(a\right)\right) \cdot \left(27 \cdot b\right) \]
      8. fp-cancel-sub-sign-invN/A

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \color{blue}{\left(\mathsf{neg}\left(a \cdot 27\right)\right)} \cdot b \]
      12. lift-*.f64N/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + x \cdot 2\right) - \left(\mathsf{neg}\left(\color{blue}{a \cdot 27}\right)\right) \cdot b \]
      13. associate--l+N/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right)} \]
      14. *-commutativeN/A

        \[\leadsto \color{blue}{t \cdot \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      15. lift-*.f64N/A

        \[\leadsto t \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right) \cdot z}\right)\right) + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      16. distribute-rgt-neg-inN/A

        \[\leadsto t \cdot \color{blue}{\left(\left(y \cdot 9\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      17. associate-*r*N/A

        \[\leadsto \color{blue}{\left(t \cdot \left(y \cdot 9\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)} + \left(x \cdot 2 - \left(\mathsf{neg}\left(a \cdot 27\right)\right) \cdot b\right) \]
      18. distribute-rgt-neg-inN/A

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

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

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

      \[\leadsto \mathsf{fma}\left(-9 \cdot \left(t \cdot y\right), z, \color{blue}{27 \cdot \left(a \cdot b\right)}\right) \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(t \cdot y\right), z, 27 \cdot \left(a \cdot \color{blue}{b}\right)\right) \]
    6. Applied rewrites66.8%

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

    if -5.0000000000000003e181 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 1e-8

    1. Initial program 94.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. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f6464.2%

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    4. Applied rewrites64.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      2. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      3. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
      4. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
      5. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      6. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
      8. count-2-revN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
      11. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      12. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      15. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      16. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      17. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      19. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      21. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      22. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      25. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      26. distribute-rgt-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      27. distribute-lft-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
      28. remove-double-negN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
      29. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
    6. Applied rewrites64.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(x + x\right)} \]
      2. lift-+.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(x + \color{blue}{x}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + \color{blue}{x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + x \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(b \cdot 27\right) \cdot a + x\right) + x \]
      6. associate-*l*N/A

        \[\leadsto \left(b \cdot \left(27 \cdot a\right) + x\right) + x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot \left(a \cdot 27\right) + x\right) + x \]
      8. associate-*l*N/A

        \[\leadsto \left(\left(b \cdot a\right) \cdot 27 + x\right) + x \]
      9. associate-+r+N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{\left(x + x\right)} \]
      10. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      11. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      12. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      13. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. count-2N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      15. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      16. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      18. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      19. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      20. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      21. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      22. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(2 \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      23. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      24. sub-flip-reverseN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - x\right)\right)\right) \]
      25. sub-negate-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      26. add-flipN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      27. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      28. lower-fma.f6464.2%

        \[\leadsto \mathsf{fma}\left(a \cdot 27, \color{blue}{b}, x + x\right) \]
    8. Applied rewrites64.2%

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

    if 1e-8 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t)

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\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)} \]
      3. lift--.f64N/A

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

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) \]
      5. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t\right)} \]
      6. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      8. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right) \cdot z}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(9 \cdot y\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      12. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{9 \cdot \left(y \cdot z\right)}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(y \cdot z\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(9\right)\right) \cdot \color{blue}{\left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-9} \cdot \left(z \cdot y\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      17. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{\left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right)}\right) \]
      19. sub-flipN/A

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

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

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + 27 \cdot \left(a \cdot b\right)} \]
    5. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(-9, \color{blue}{t \cdot \left(y \cdot z\right)}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-9, t \cdot \color{blue}{\left(y \cdot z\right)}, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-9, t \cdot \left(y \cdot \color{blue}{z}\right), 27 \cdot \left(a \cdot b\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), 27 \cdot \left(a \cdot b\right)\right) \]
      5. lower-*.f6466.4%

        \[\leadsto \mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), 27 \cdot \left(a \cdot b\right)\right) \]
    6. Applied rewrites66.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), 27 \cdot \left(a \cdot b\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 85.0% accurate, 0.6× speedup?

\[\begin{array}{l} t_1 := \mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), 27 \cdot \left(a \cdot b\right)\right)\\ t_2 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+52}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 10^{-8}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (let* ((t_1 (fma -9.0 (* t (* y z)) (* 27.0 (* a b))))
       (t_2 (* (* (* y 9.0) z) t)))
  (if (<= t_2 -5e+52)
    t_1
    (if (<= t_2 1e-8) (fma (* a 27.0) b (+ x x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fma(-9.0, (t * (y * z)), (27.0 * (a * b)));
	double t_2 = ((y * 9.0) * z) * t;
	double tmp;
	if (t_2 <= -5e+52) {
		tmp = t_1;
	} else if (t_2 <= 1e-8) {
		tmp = fma((a * 27.0), b, (x + x));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fma(-9.0, Float64(t * Float64(y * z)), Float64(27.0 * Float64(a * b)))
	t_2 = Float64(Float64(Float64(y * 9.0) * z) * t)
	tmp = 0.0
	if (t_2 <= -5e+52)
		tmp = t_1;
	elseif (t_2 <= 1e-8)
		tmp = fma(Float64(a * 27.0), b, Float64(x + x));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(-9.0 * N[(t * N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+52], t$95$1, If[LessEqual[t$95$2, 1e-8], N[(N[(a * 27.0), $MachinePrecision] * b + N[(x + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), 27 \cdot \left(a \cdot b\right)\right)\\
t_2 := \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x + x\right)\\

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


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

    1. Initial program 94.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. lift-+.f64N/A

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

        \[\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)} \]
      3. lift--.f64N/A

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

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x \cdot 2 - \color{blue}{\left(\left(y \cdot 9\right) \cdot z\right) \cdot t}\right) \]
      5. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(x \cdot 2 + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t\right)} \]
      6. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right) + \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t} \]
      7. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      8. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right)} \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right) \cdot z}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      10. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(y \cdot 9\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(9 \cdot y\right)} \cdot z\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      12. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{9 \cdot \left(y \cdot z\right)}\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      13. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(y \cdot z\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\mathsf{neg}\left(9\right)\right) \cdot \color{blue}{\left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(z \cdot y\right)}, t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{-9} \cdot \left(z \cdot y\right), t, \left(a \cdot 27\right) \cdot b + x \cdot 2\right) \]
      17. lower-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(-9 \cdot \left(z \cdot y\right), t, \color{blue}{\left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right)}\right) \]
      19. sub-flipN/A

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

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

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + 27 \cdot \left(a \cdot b\right)} \]
    5. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(-9, \color{blue}{t \cdot \left(y \cdot z\right)}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-9, t \cdot \color{blue}{\left(y \cdot z\right)}, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-9, t \cdot \left(y \cdot \color{blue}{z}\right), 27 \cdot \left(a \cdot b\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), 27 \cdot \left(a \cdot b\right)\right) \]
      5. lower-*.f6466.4%

        \[\leadsto \mathsf{fma}\left(-9, t \cdot \left(y \cdot z\right), 27 \cdot \left(a \cdot b\right)\right) \]
    6. Applied rewrites66.4%

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

    if -5e52 < (*.f64 (*.f64 (*.f64 y #s(literal 9 binary64)) z) t) < 1e-8

    1. Initial program 94.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. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f6464.2%

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    4. Applied rewrites64.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      2. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      3. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
      4. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
      5. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      6. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
      8. count-2-revN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
      11. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      12. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      15. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      16. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      17. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      19. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      21. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      22. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      25. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      26. distribute-rgt-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      27. distribute-lft-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
      28. remove-double-negN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
      29. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
    6. Applied rewrites64.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
    7. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(x + x\right)} \]
      2. lift-+.f64N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(x + \color{blue}{x}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + \color{blue}{x} \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + x \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(b \cdot 27\right) \cdot a + x\right) + x \]
      6. associate-*l*N/A

        \[\leadsto \left(b \cdot \left(27 \cdot a\right) + x\right) + x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot \left(a \cdot 27\right) + x\right) + x \]
      8. associate-*l*N/A

        \[\leadsto \left(\left(b \cdot a\right) \cdot 27 + x\right) + x \]
      9. associate-+r+N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{\left(x + x\right)} \]
      10. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      11. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      12. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      13. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. count-2N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      15. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      16. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      18. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      19. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      20. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      21. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      22. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(2 \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      23. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      24. sub-flip-reverseN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - x\right)\right)\right) \]
      25. sub-negate-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
      26. add-flipN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      27. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      28. lower-fma.f6464.2%

        \[\leadsto \mathsf{fma}\left(a \cdot 27, \color{blue}{b}, x + x\right) \]
    8. Applied rewrites64.2%

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

Alternative 10: 64.2% accurate, 2.1× speedup?

\[\mathsf{fma}\left(a \cdot 27, b, x + x\right) \]
(FPCore (x y z t a b)
  :precision binary64
  (fma (* a 27.0) b (+ x x)))
double code(double x, double y, double z, double t, double a, double b) {
	return fma((a * 27.0), b, (x + x));
}
function code(x, y, z, t, a, b)
	return fma(Float64(a * 27.0), b, Float64(x + x))
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * 27.0), $MachinePrecision] * b + N[(x + x), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(a \cdot 27, b, x + x\right)
Derivation
  1. Initial program 94.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. Taylor expanded in y around 0

    \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
  3. Step-by-step derivation
    1. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
    2. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    3. lower-*.f6464.2%

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
  4. Applied rewrites64.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
  5. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    2. +-commutativeN/A

      \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
    3. lift-*.f64N/A

      \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
    4. lift-*.f64N/A

      \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
    5. *-commutativeN/A

      \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
    6. lift-*.f64N/A

      \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
    7. *-commutativeN/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
    8. count-2-revN/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
    9. lift-+.f64N/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
    10. lift-*.f64N/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
    11. associate-*l*N/A

      \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
    12. lift-*.f64N/A

      \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
    13. *-commutativeN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
    14. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
    15. lift-+.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
    16. count-2-revN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
    17. *-commutativeN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
    18. fp-cancel-sign-sub-invN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
    19. distribute-lft-neg-inN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
    20. distribute-rgt-neg-inN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
    21. fp-cancel-sub-sign-invN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
    22. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    23. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    24. associate-*l*N/A

      \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    25. *-commutativeN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    26. distribute-rgt-neg-inN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
    27. distribute-lft-neg-inN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
    28. remove-double-negN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
    29. *-commutativeN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
  6. Applied rewrites64.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
  7. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(x + x\right)} \]
    2. lift-+.f64N/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \left(x + \color{blue}{x}\right) \]
    3. associate-+r+N/A

      \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + \color{blue}{x} \]
    4. lift-*.f64N/A

      \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + x \]
    5. *-commutativeN/A

      \[\leadsto \left(\left(b \cdot 27\right) \cdot a + x\right) + x \]
    6. associate-*l*N/A

      \[\leadsto \left(b \cdot \left(27 \cdot a\right) + x\right) + x \]
    7. *-commutativeN/A

      \[\leadsto \left(b \cdot \left(a \cdot 27\right) + x\right) + x \]
    8. associate-*l*N/A

      \[\leadsto \left(\left(b \cdot a\right) \cdot 27 + x\right) + x \]
    9. associate-+r+N/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{\left(x + x\right)} \]
    10. associate-*l*N/A

      \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
    11. lift-*.f64N/A

      \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
    12. *-commutativeN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
    13. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
    14. count-2N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
    15. *-commutativeN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
    16. fp-cancel-sign-sub-invN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
    17. distribute-lft-neg-inN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
    18. distribute-rgt-neg-inN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
    19. fp-cancel-sub-sign-invN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
    20. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    21. distribute-rgt-neg-inN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
    22. *-commutativeN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(2 \cdot \left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
    23. count-2-revN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
    24. sub-flip-reverseN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - x\right)\right)\right) \]
    25. sub-negate-revN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) \]
    26. add-flipN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
    27. lift-+.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
    28. lower-fma.f6464.2%

      \[\leadsto \mathsf{fma}\left(a \cdot 27, \color{blue}{b}, x + x\right) \]
  8. Applied rewrites64.2%

    \[\leadsto \mathsf{fma}\left(a \cdot 27, \color{blue}{b}, x + x\right) \]
  9. Add Preprocessing

Alternative 11: 64.2% accurate, 1.4× speedup?

\[\mathsf{fma}\left(\mathsf{min}\left(a, b\right) \cdot 27, \mathsf{max}\left(a, b\right), x\right) + x \]
(FPCore (x y z t a b)
  :precision binary64
  (+ (fma (* (fmin a b) 27.0) (fmax a b) x) x))
double code(double x, double y, double z, double t, double a, double b) {
	return fma((fmin(a, b) * 27.0), fmax(a, b), x) + x;
}
function code(x, y, z, t, a, b)
	return Float64(fma(Float64(fmin(a, b) * 27.0), fmax(a, b), x) + x)
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[Min[a, b], $MachinePrecision] * 27.0), $MachinePrecision] * N[Max[a, b], $MachinePrecision] + x), $MachinePrecision] + x), $MachinePrecision]
\mathsf{fma}\left(\mathsf{min}\left(a, b\right) \cdot 27, \mathsf{max}\left(a, b\right), x\right) + x
Derivation
  1. Initial program 94.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. Taylor expanded in y around 0

    \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
  3. Step-by-step derivation
    1. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
    2. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    3. lower-*.f6464.2%

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
  4. Applied rewrites64.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
  5. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    2. +-commutativeN/A

      \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
    3. lift-*.f64N/A

      \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
    4. lift-*.f64N/A

      \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
    5. *-commutativeN/A

      \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
    6. lift-*.f64N/A

      \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
    7. *-commutativeN/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
    8. count-2-revN/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
    9. lift-+.f64N/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
    10. lift-*.f64N/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
    11. associate-*l*N/A

      \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
    12. lift-*.f64N/A

      \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
    13. *-commutativeN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
    14. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
    15. lift-+.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
    16. count-2-revN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
    17. *-commutativeN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
    18. fp-cancel-sign-sub-invN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
    19. distribute-lft-neg-inN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
    20. distribute-rgt-neg-inN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
    21. fp-cancel-sub-sign-invN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
    22. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    23. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    24. associate-*l*N/A

      \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    25. *-commutativeN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    26. distribute-rgt-neg-inN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
    27. distribute-lft-neg-inN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
    28. remove-double-negN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
    29. *-commutativeN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
  6. Applied rewrites64.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
  7. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(x + x\right)} \]
    2. lift-+.f64N/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \left(x + \color{blue}{x}\right) \]
    3. associate-+r+N/A

      \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + \color{blue}{x} \]
    4. lower-+.f64N/A

      \[\leadsto \left(\left(27 \cdot b\right) \cdot a + x\right) + \color{blue}{x} \]
    5. *-commutativeN/A

      \[\leadsto \left(a \cdot \left(27 \cdot b\right) + x\right) + x \]
    6. lift-*.f64N/A

      \[\leadsto \left(a \cdot \left(27 \cdot b\right) + x\right) + x \]
    7. associate-*l*N/A

      \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x\right) + x \]
    8. lift-*.f64N/A

      \[\leadsto \left(\left(a \cdot 27\right) \cdot b + x\right) + x \]
    9. lower-fma.f6464.2%

      \[\leadsto \mathsf{fma}\left(a \cdot 27, b, x\right) + x \]
  8. Applied rewrites64.2%

    \[\leadsto \mathsf{fma}\left(a \cdot 27, b, x\right) + \color{blue}{x} \]
  9. Add Preprocessing

Alternative 12: 46.2% accurate, 0.5× speedup?

\[\begin{array}{l} t_1 := \left(\mathsf{min}\left(a, b\right) \cdot 27\right) \cdot \mathsf{max}\left(a, b\right)\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{+78}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_1 \leq 10^{-54}:\\ \;\;\;\;\mathsf{max}\left(a, b\right) \cdot \left(2 \cdot \frac{x}{\mathsf{max}\left(a, b\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;27 \cdot \left(\mathsf{min}\left(a, b\right) \cdot \mathsf{max}\left(a, b\right)\right)\\ \end{array} \]
(FPCore (x y z t a b)
  :precision binary64
  (let* ((t_1 (* (* (fmin a b) 27.0) (fmax a b))))
  (if (<= t_1 -5e+78)
    t_1
    (if (<= t_1 1e-54)
      (* (fmax a b) (* 2.0 (/ x (fmax a b))))
      (* 27.0 (* (fmin a b) (fmax a b)))))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (fmin(a, b) * 27.0) * fmax(a, b);
	double tmp;
	if (t_1 <= -5e+78) {
		tmp = t_1;
	} else if (t_1 <= 1e-54) {
		tmp = fmax(a, b) * (2.0 * (x / fmax(a, b)));
	} else {
		tmp = 27.0 * (fmin(a, b) * fmax(a, b));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    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 = (fmin(a, b) * 27.0d0) * fmax(a, b)
    if (t_1 <= (-5d+78)) then
        tmp = t_1
    else if (t_1 <= 1d-54) then
        tmp = fmax(a, b) * (2.0d0 * (x / fmax(a, b)))
    else
        tmp = 27.0d0 * (fmin(a, b) * fmax(a, b))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (fmin(a, b) * 27.0) * fmax(a, b);
	double tmp;
	if (t_1 <= -5e+78) {
		tmp = t_1;
	} else if (t_1 <= 1e-54) {
		tmp = fmax(a, b) * (2.0 * (x / fmax(a, b)));
	} else {
		tmp = 27.0 * (fmin(a, b) * fmax(a, b));
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = (fmin(a, b) * 27.0) * fmax(a, b)
	tmp = 0
	if t_1 <= -5e+78:
		tmp = t_1
	elif t_1 <= 1e-54:
		tmp = fmax(a, b) * (2.0 * (x / fmax(a, b)))
	else:
		tmp = 27.0 * (fmin(a, b) * fmax(a, b))
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(fmin(a, b) * 27.0) * fmax(a, b))
	tmp = 0.0
	if (t_1 <= -5e+78)
		tmp = t_1;
	elseif (t_1 <= 1e-54)
		tmp = Float64(fmax(a, b) * Float64(2.0 * Float64(x / fmax(a, b))));
	else
		tmp = Float64(27.0 * Float64(fmin(a, b) * fmax(a, b)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (min(a, b) * 27.0) * max(a, b);
	tmp = 0.0;
	if (t_1 <= -5e+78)
		tmp = t_1;
	elseif (t_1 <= 1e-54)
		tmp = max(a, b) * (2.0 * (x / max(a, b)));
	else
		tmp = 27.0 * (min(a, b) * max(a, b));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[Min[a, b], $MachinePrecision] * 27.0), $MachinePrecision] * N[Max[a, b], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+78], t$95$1, If[LessEqual[t$95$1, 1e-54], N[(N[Max[a, b], $MachinePrecision] * N[(2.0 * N[(x / N[Max[a, b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(27.0 * N[(N[Min[a, b], $MachinePrecision] * N[Max[a, b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \left(\mathsf{min}\left(a, b\right) \cdot 27\right) \cdot \mathsf{max}\left(a, b\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+78}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_1 \leq 10^{-54}:\\
\;\;\;\;\mathsf{max}\left(a, b\right) \cdot \left(2 \cdot \frac{x}{\mathsf{max}\left(a, b\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;27 \cdot \left(\mathsf{min}\left(a, b\right) \cdot \mathsf{max}\left(a, b\right)\right)\\


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -4.9999999999999998e78

    1. Initial program 94.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. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f6464.2%

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    4. Applied rewrites64.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      2. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      3. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
      4. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
      5. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      6. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
      8. count-2-revN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
      11. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      12. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      15. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      16. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      17. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      19. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      21. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      22. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      25. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      26. distribute-rgt-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      27. distribute-lft-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
      28. remove-double-negN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
      29. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
    6. Applied rewrites64.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
    7. Taylor expanded in x around 0

      \[\leadsto 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot \color{blue}{b}\right) \]
      2. lower-*.f6435.8%

        \[\leadsto 27 \cdot \left(a \cdot b\right) \]
    9. Applied rewrites35.8%

      \[\leadsto 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
    10. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot \color{blue}{b}\right) \]
      2. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) \]
      3. associate-*r*N/A

        \[\leadsto \left(27 \cdot a\right) \cdot b \]
      4. lift-*.f64N/A

        \[\leadsto \left(27 \cdot a\right) \cdot b \]
      5. lower-*.f6435.8%

        \[\leadsto \left(27 \cdot a\right) \cdot b \]
      6. lift-*.f64N/A

        \[\leadsto \left(27 \cdot a\right) \cdot b \]
      7. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b \]
      8. lift-*.f6435.8%

        \[\leadsto \left(a \cdot 27\right) \cdot b \]
    11. Applied rewrites35.8%

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

    if -4.9999999999999998e78 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 1e-54

    1. Initial program 94.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. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f6464.2%

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    4. Applied rewrites64.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      2. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      3. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
      4. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
      5. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      6. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
      8. count-2-revN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
      11. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      12. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      15. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      16. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      17. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      19. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      21. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      22. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      25. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      26. distribute-rgt-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      27. distribute-lft-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
      28. remove-double-negN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
      29. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
    6. Applied rewrites64.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
    7. Taylor expanded in b around inf

      \[\leadsto b \cdot \color{blue}{\left(2 \cdot \frac{x}{b} + 27 \cdot a\right)} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto b \cdot \left(2 \cdot \frac{x}{b} + \color{blue}{27 \cdot a}\right) \]
      2. lower-fma.f64N/A

        \[\leadsto b \cdot \mathsf{fma}\left(2, \frac{x}{\color{blue}{b}}, 27 \cdot a\right) \]
      3. lower-/.f64N/A

        \[\leadsto b \cdot \mathsf{fma}\left(2, \frac{x}{b}, 27 \cdot a\right) \]
      4. lower-*.f6456.8%

        \[\leadsto b \cdot \mathsf{fma}\left(2, \frac{x}{b}, 27 \cdot a\right) \]
    9. Applied rewrites56.8%

      \[\leadsto b \cdot \color{blue}{\mathsf{fma}\left(2, \frac{x}{b}, 27 \cdot a\right)} \]
    10. Taylor expanded in x around inf

      \[\leadsto b \cdot \left(2 \cdot \frac{x}{\color{blue}{b}}\right) \]
    11. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto b \cdot \left(2 \cdot \frac{x}{b}\right) \]
      2. lower-/.f6423.0%

        \[\leadsto b \cdot \left(2 \cdot \frac{x}{b}\right) \]
    12. Applied rewrites23.0%

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

    if 1e-54 < (*.f64 (*.f64 a #s(literal 27 binary64)) b)

    1. Initial program 94.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. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
      2. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
      3. lower-*.f6464.2%

        \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    4. Applied rewrites64.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
    5. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      2. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      3. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
      4. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
      5. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      6. lift-*.f64N/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
      7. *-commutativeN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
      8. count-2-revN/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
      10. lift-*.f64N/A

        \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
      11. associate-*l*N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
      12. lift-*.f64N/A

        \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      14. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
      15. lift-+.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
      16. count-2-revN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
      17. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
      18. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
      19. distribute-lft-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
      20. distribute-rgt-neg-inN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
      21. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
      22. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      23. lift-*.f64N/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      25. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
      26. distribute-rgt-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
      27. distribute-lft-neg-inN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
      28. remove-double-negN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
      29. *-commutativeN/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
    6. Applied rewrites64.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
    7. Taylor expanded in x around 0

      \[\leadsto 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
    8. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto 27 \cdot \left(a \cdot \color{blue}{b}\right) \]
      2. lower-*.f6435.8%

        \[\leadsto 27 \cdot \left(a \cdot b\right) \]
    9. Applied rewrites35.8%

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

Alternative 13: 35.8% accurate, 3.5× speedup?

\[27 \cdot \left(a \cdot b\right) \]
(FPCore (x y z t a b)
  :precision binary64
  (* 27.0 (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
	return 27.0 * (a * b);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    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 = 27.0d0 * (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return 27.0 * (a * b);
}
def code(x, y, z, t, a, b):
	return 27.0 * (a * b)
function code(x, y, z, t, a, b)
	return Float64(27.0 * Float64(a * b))
end
function tmp = code(x, y, z, t, a, b)
	tmp = 27.0 * (a * b);
end
code[x_, y_, z_, t_, a_, b_] := N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]
27 \cdot \left(a \cdot b\right)
Derivation
  1. Initial program 94.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. Taylor expanded in y around 0

    \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
  3. Step-by-step derivation
    1. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(2, \color{blue}{x}, 27 \cdot \left(a \cdot b\right)\right) \]
    2. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
    3. lower-*.f6464.2%

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right) \]
  4. Applied rewrites64.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right)\right)} \]
  5. Step-by-step derivation
    1. lift-fma.f64N/A

      \[\leadsto 2 \cdot x + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    2. +-commutativeN/A

      \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
    3. lift-*.f64N/A

      \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2} \cdot x \]
    4. lift-*.f64N/A

      \[\leadsto 27 \cdot \left(a \cdot b\right) + 2 \cdot x \]
    5. *-commutativeN/A

      \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
    6. lift-*.f64N/A

      \[\leadsto 27 \cdot \left(b \cdot a\right) + 2 \cdot x \]
    7. *-commutativeN/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \color{blue}{2} \cdot x \]
    8. count-2-revN/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
    9. lift-+.f64N/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + \color{blue}{x}\right) \]
    10. lift-*.f64N/A

      \[\leadsto \left(b \cdot a\right) \cdot 27 + \left(x + x\right) \]
    11. associate-*l*N/A

      \[\leadsto b \cdot \left(a \cdot 27\right) + \left(\color{blue}{x} + x\right) \]
    12. lift-*.f64N/A

      \[\leadsto b \cdot \left(a \cdot 27\right) + \left(x + x\right) \]
    13. *-commutativeN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
    14. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\color{blue}{x} + x\right) \]
    15. lift-+.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(x + \color{blue}{x}\right) \]
    16. count-2-revN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + 2 \cdot \color{blue}{x} \]
    17. *-commutativeN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + x \cdot \color{blue}{2} \]
    18. fp-cancel-sign-sub-invN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot 2} \]
    19. distribute-lft-neg-inN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - \left(\mathsf{neg}\left(x \cdot 2\right)\right) \]
    20. distribute-rgt-neg-inN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b - x \cdot \color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \]
    21. fp-cancel-sub-sign-invN/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right)} \]
    22. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    23. lift-*.f64N/A

      \[\leadsto \left(a \cdot 27\right) \cdot b + \left(\mathsf{neg}\left(\color{blue}{x}\right)\right) \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    24. associate-*l*N/A

      \[\leadsto a \cdot \left(27 \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    25. *-commutativeN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(\mathsf{neg}\left(2\right)\right) \]
    26. distribute-rgt-neg-inN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right) \cdot 2\right)\right) \]
    27. distribute-lft-neg-inN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \cdot \color{blue}{2} \]
    28. remove-double-negN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + x \cdot 2 \]
    29. *-commutativeN/A

      \[\leadsto \left(27 \cdot b\right) \cdot a + 2 \cdot \color{blue}{x} \]
  6. Applied rewrites64.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, x + x\right)} \]
  7. Taylor expanded in x around 0

    \[\leadsto 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
  8. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto 27 \cdot \left(a \cdot \color{blue}{b}\right) \]
    2. lower-*.f6435.8%

      \[\leadsto 27 \cdot \left(a \cdot b\right) \]
  9. Applied rewrites35.8%

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

Reproduce

?
herbie shell --seed 2025212 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"
  :precision binary64
  (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))