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

Percentage Accurate: 95.3% → 98.5%
Time: 3.0s
Alternatives: 4
Speedup: N/A×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 4 alternatives:

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

Initial Program: 95.3% accurate, 1.0× speedup?

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

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

Alternative 1: 98.5% accurate, N/A× speedup?

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

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


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

    1. Initial program 95.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. 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 \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 \]
      3. lift-*.f64N/A

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

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

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

        \[\leadsto \left(x \cdot 2 - \left(\color{blue}{\left(y \cdot 9\right)} \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      7. +-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)} \]
      8. lift-*.f64N/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) \]
      9. lift-*.f64N/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) \]
      10. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

    if 1e280 < (*.f64 (*.f64 y #s(literal 9 binary64)) z)

    1. Initial program 77.2%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. 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(\color{blue}{x \cdot 2} - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      3. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.3% accurate, N/A× speedup?

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

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


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

    1. Initial program 95.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. 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} \]
      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. 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)} \]
      4. *-commutativeN/A

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

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

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

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

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

    if 1e280 < (*.f64 (*.f64 y #s(literal 9 binary64)) z)

    1. Initial program 77.2%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. 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(\color{blue}{x \cdot 2} - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
      3. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.3% accurate, N/A× speedup?

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

    \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. 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} \]
    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. 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)} \]
    4. *-commutativeN/A

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

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

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

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

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

Alternative 4: 95.3% accurate, N/A× speedup?

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

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

Reproduce

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

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

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