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

Percentage Accurate: 69.8% → 77.3%
Time: 14.0s
Alternatives: 9
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0));
}
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 = ((2.0d0 * sqrt(x)) * cos((y - ((z * t) / 3.0d0)))) - (a / (b * 3.0d0))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((2.0 * Math.sqrt(x)) * Math.cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0));
}
def code(x, y, z, t, a, b):
	return ((2.0 * math.sqrt(x)) * math.cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0))
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(2.0 * sqrt(x)) * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - Float64(a / Float64(b * 3.0)))
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((2.0 * sqrt(x)) * cos((y - ((z * t) / 3.0)))) - (a / (b * 3.0));
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}
\end{array}

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 9 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: 69.8% accurate, 1.0× speedup?

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

\\
\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3}
\end{array}

Alternative 1: 77.3% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \frac{a}{b \cdot 3}\\ t_2 := 2 \cdot \sqrt{x}\\ \mathbf{if}\;t\_2 \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - t\_1 \leq 5 \cdot 10^{+272}:\\ \;\;\;\;t\_2 \cdot \mathsf{fma}\left(\sin \left(\left(z \cdot 0.3333333333333333\right) \cdot t\right), \sin y, \cos \left(\left(t \cdot -0.3333333333333333\right) \cdot z\right) \cdot \cos y\right) - t\_1\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \mathsf{fma}\left(0.3333333333333333, \frac{a}{b}, 2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)\right)\\ \end{array} \end{array} \]
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 (/ a (* b 3.0))) (t_2 (* 2.0 (sqrt x))))
   (if (<= (- (* t_2 (cos (- y (/ (* z t) 3.0)))) t_1) 5e+272)
     (-
      (*
       t_2
       (fma
        (sin (* (* z 0.3333333333333333) t))
        (sin y)
        (* (cos (* (* t -0.3333333333333333) z)) (cos y))))
      t_1)
     (*
      -1.0
      (fma
       0.3333333333333333
       (/ a b)
       (* 2.0 (* x (* (cos y) (sqrt (/ 1.0 x))))))))))
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 = a / (b * 3.0);
	double t_2 = 2.0 * sqrt(x);
	double tmp;
	if (((t_2 * cos((y - ((z * t) / 3.0)))) - t_1) <= 5e+272) {
		tmp = (t_2 * fma(sin(((z * 0.3333333333333333) * t)), sin(y), (cos(((t * -0.3333333333333333) * z)) * cos(y)))) - t_1;
	} else {
		tmp = -1.0 * fma(0.3333333333333333, (a / b), (2.0 * (x * (cos(y) * sqrt((1.0 / x))))));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(a / Float64(b * 3.0))
	t_2 = Float64(2.0 * sqrt(x))
	tmp = 0.0
	if (Float64(Float64(t_2 * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - t_1) <= 5e+272)
		tmp = Float64(Float64(t_2 * fma(sin(Float64(Float64(z * 0.3333333333333333) * t)), sin(y), Float64(cos(Float64(Float64(t * -0.3333333333333333) * z)) * cos(y)))) - t_1);
	else
		tmp = Float64(-1.0 * fma(0.3333333333333333, Float64(a / b), Float64(2.0 * Float64(x * Float64(cos(y) * sqrt(Float64(1.0 / x)))))));
	end
	return tmp
end
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[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$2 * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], 5e+272], N[(N[(t$95$2 * N[(N[Sin[N[(N[(z * 0.3333333333333333), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision] * N[Sin[y], $MachinePrecision] + N[(N[Cos[N[(N[(t * -0.3333333333333333), $MachinePrecision] * z), $MachinePrecision]], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(-1.0 * N[(0.3333333333333333 * N[(a / b), $MachinePrecision] + N[(2.0 * N[(x * N[(N[Cos[y], $MachinePrecision] * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
t_2 := 2 \cdot \sqrt{x}\\
\mathbf{if}\;t\_2 \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - t\_1 \leq 5 \cdot 10^{+272}:\\
\;\;\;\;t\_2 \cdot \mathsf{fma}\left(\sin \left(\left(z \cdot 0.3333333333333333\right) \cdot t\right), \sin y, \cos \left(\left(t \cdot -0.3333333333333333\right) \cdot z\right) \cdot \cos y\right) - t\_1\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \mathsf{fma}\left(0.3333333333333333, \frac{a}{b}, 2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (*.f64 #s(literal 2 binary64) (sqrt.f64 x)) (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64))))) (/.f64 a (*.f64 b #s(literal 3 binary64)))) < 4.99999999999999973e272

    1. Initial program 69.8%

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Applied rewrites70.3%

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(z \cdot 0.3333333333333333\right) \cdot t\right), \sin y, \cos \left(\left(t \cdot -0.3333333333333333\right) \cdot z\right) \cdot \cos y\right)} - \frac{a}{b \cdot 3} \]

    if 4.99999999999999973e272 < (-.f64 (*.f64 (*.f64 #s(literal 2 binary64) (sqrt.f64 x)) (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64))))) (/.f64 a (*.f64 b #s(literal 3 binary64))))

    1. Initial program 69.8%

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(\frac{1}{3} \cdot \frac{a}{b \cdot x} + 2 \cdot \left(\cos \left(y - \frac{1}{3} \cdot \left(t \cdot z\right)\right) \cdot \sqrt{\frac{1}{x}}\right)\right)\right)} \]
    3. Applied rewrites35.1%

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \mathsf{fma}\left(0.3333333333333333, \frac{a}{b \cdot x}, 2 \cdot \left(\cos \left(y - 0.3333333333333333 \cdot \left(t \cdot z\right)\right) \cdot \sqrt{\frac{1}{x}}\right)\right)\right)} \]
    4. Applied rewrites38.5%

      \[\leadsto -1 \cdot \left(x \cdot \frac{\mathsf{fma}\left(\cos \left(\mathsf{fma}\left(t, z \cdot -0.3333333333333333, y\right)\right), \sqrt{\frac{1}{x}} \cdot \left(x + x\right), \frac{a}{b \cdot 3}\right)}{\color{blue}{x}}\right) \]
    5. Taylor expanded in z around 0

      \[\leadsto -1 \cdot \left(\frac{1}{3} \cdot \frac{a}{b} + \color{blue}{2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)}\right) \]
    6. Applied rewrites51.8%

      \[\leadsto -1 \cdot \mathsf{fma}\left(0.3333333333333333, \color{blue}{\frac{a}{b}}, 2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 77.3% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \frac{a}{b \cdot 3}\\ t_2 := 2 \cdot \sqrt{x}\\ \mathbf{if}\;t\_2 \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - t\_1 \leq 5 \cdot 10^{+272}:\\ \;\;\;\;t\_2 \cdot \mathsf{fma}\left(\sin \left(\left(z \cdot 0.3333333333333333\right) \cdot t\right), \sin y, \cos \left(-0.3333333333333333 \cdot \left(t \cdot z\right)\right) \cdot \cos y\right) - t\_1\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \mathsf{fma}\left(0.3333333333333333, \frac{a}{b}, 2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)\right)\\ \end{array} \end{array} \]
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 (/ a (* b 3.0))) (t_2 (* 2.0 (sqrt x))))
   (if (<= (- (* t_2 (cos (- y (/ (* z t) 3.0)))) t_1) 5e+272)
     (-
      (*
       t_2
       (fma
        (sin (* (* z 0.3333333333333333) t))
        (sin y)
        (* (cos (* -0.3333333333333333 (* t z))) (cos y))))
      t_1)
     (*
      -1.0
      (fma
       0.3333333333333333
       (/ a b)
       (* 2.0 (* x (* (cos y) (sqrt (/ 1.0 x))))))))))
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 = a / (b * 3.0);
	double t_2 = 2.0 * sqrt(x);
	double tmp;
	if (((t_2 * cos((y - ((z * t) / 3.0)))) - t_1) <= 5e+272) {
		tmp = (t_2 * fma(sin(((z * 0.3333333333333333) * t)), sin(y), (cos((-0.3333333333333333 * (t * z))) * cos(y)))) - t_1;
	} else {
		tmp = -1.0 * fma(0.3333333333333333, (a / b), (2.0 * (x * (cos(y) * sqrt((1.0 / x))))));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(a / Float64(b * 3.0))
	t_2 = Float64(2.0 * sqrt(x))
	tmp = 0.0
	if (Float64(Float64(t_2 * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - t_1) <= 5e+272)
		tmp = Float64(Float64(t_2 * fma(sin(Float64(Float64(z * 0.3333333333333333) * t)), sin(y), Float64(cos(Float64(-0.3333333333333333 * Float64(t * z))) * cos(y)))) - t_1);
	else
		tmp = Float64(-1.0 * fma(0.3333333333333333, Float64(a / b), Float64(2.0 * Float64(x * Float64(cos(y) * sqrt(Float64(1.0 / x)))))));
	end
	return tmp
end
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[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$2 * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], 5e+272], N[(N[(t$95$2 * N[(N[Sin[N[(N[(z * 0.3333333333333333), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision] * N[Sin[y], $MachinePrecision] + N[(N[Cos[N[(-0.3333333333333333 * N[(t * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(-1.0 * N[(0.3333333333333333 * N[(a / b), $MachinePrecision] + N[(2.0 * N[(x * N[(N[Cos[y], $MachinePrecision] * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
t_2 := 2 \cdot \sqrt{x}\\
\mathbf{if}\;t\_2 \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - t\_1 \leq 5 \cdot 10^{+272}:\\
\;\;\;\;t\_2 \cdot \mathsf{fma}\left(\sin \left(\left(z \cdot 0.3333333333333333\right) \cdot t\right), \sin y, \cos \left(-0.3333333333333333 \cdot \left(t \cdot z\right)\right) \cdot \cos y\right) - t\_1\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \mathsf{fma}\left(0.3333333333333333, \frac{a}{b}, 2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (*.f64 #s(literal 2 binary64) (sqrt.f64 x)) (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64))))) (/.f64 a (*.f64 b #s(literal 3 binary64)))) < 4.99999999999999973e272

    1. Initial program 69.8%

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Applied rewrites69.8%

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos \color{blue}{\left(\mathsf{fma}\left(t, \frac{z}{-3}, y\right)\right)} - \frac{a}{b \cdot 3} \]
    3. Applied rewrites59.2%

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\sin \left(\mathsf{fma}\left(z \cdot -0.3333333333333333, t, \mathsf{fma}\left(0.5, \pi, y\right)\right)\right)} - \frac{a}{b \cdot 3} \]
    4. Applied rewrites70.3%

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(z \cdot 0.3333333333333333\right) \cdot t\right), \sin y, \cos \left(-0.3333333333333333 \cdot \left(t \cdot z\right)\right) \cdot \cos y\right)} - \frac{a}{b \cdot 3} \]

    if 4.99999999999999973e272 < (-.f64 (*.f64 (*.f64 #s(literal 2 binary64) (sqrt.f64 x)) (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64))))) (/.f64 a (*.f64 b #s(literal 3 binary64))))

    1. Initial program 69.8%

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(\frac{1}{3} \cdot \frac{a}{b \cdot x} + 2 \cdot \left(\cos \left(y - \frac{1}{3} \cdot \left(t \cdot z\right)\right) \cdot \sqrt{\frac{1}{x}}\right)\right)\right)} \]
    3. Applied rewrites35.1%

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \mathsf{fma}\left(0.3333333333333333, \frac{a}{b \cdot x}, 2 \cdot \left(\cos \left(y - 0.3333333333333333 \cdot \left(t \cdot z\right)\right) \cdot \sqrt{\frac{1}{x}}\right)\right)\right)} \]
    4. Applied rewrites38.5%

      \[\leadsto -1 \cdot \left(x \cdot \frac{\mathsf{fma}\left(\cos \left(\mathsf{fma}\left(t, z \cdot -0.3333333333333333, y\right)\right), \sqrt{\frac{1}{x}} \cdot \left(x + x\right), \frac{a}{b \cdot 3}\right)}{\color{blue}{x}}\right) \]
    5. Taylor expanded in z around 0

      \[\leadsto -1 \cdot \left(\frac{1}{3} \cdot \frac{a}{b} + \color{blue}{2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)}\right) \]
    6. Applied rewrites51.8%

      \[\leadsto -1 \cdot \mathsf{fma}\left(0.3333333333333333, \color{blue}{\frac{a}{b}}, 2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 77.3% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \frac{a}{b \cdot 3}\\ t_2 := 2 \cdot \sqrt{x}\\ t_3 := 0.3333333333333333 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;t\_2 \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - t\_1 \leq 5 \cdot 10^{+272}:\\ \;\;\;\;t\_2 \cdot \mathsf{fma}\left(\sin t\_3, \sin y, \cos t\_3 \cdot \cos y\right) - t\_1\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \mathsf{fma}\left(0.3333333333333333, \frac{a}{b}, 2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)\right)\\ \end{array} \end{array} \]
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 (/ a (* b 3.0)))
        (t_2 (* 2.0 (sqrt x)))
        (t_3 (* 0.3333333333333333 (* z t))))
   (if (<= (- (* t_2 (cos (- y (/ (* z t) 3.0)))) t_1) 5e+272)
     (- (* t_2 (fma (sin t_3) (sin y) (* (cos t_3) (cos y)))) t_1)
     (*
      -1.0
      (fma
       0.3333333333333333
       (/ a b)
       (* 2.0 (* x (* (cos y) (sqrt (/ 1.0 x))))))))))
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 = a / (b * 3.0);
	double t_2 = 2.0 * sqrt(x);
	double t_3 = 0.3333333333333333 * (z * t);
	double tmp;
	if (((t_2 * cos((y - ((z * t) / 3.0)))) - t_1) <= 5e+272) {
		tmp = (t_2 * fma(sin(t_3), sin(y), (cos(t_3) * cos(y)))) - t_1;
	} else {
		tmp = -1.0 * fma(0.3333333333333333, (a / b), (2.0 * (x * (cos(y) * sqrt((1.0 / x))))));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(a / Float64(b * 3.0))
	t_2 = Float64(2.0 * sqrt(x))
	t_3 = Float64(0.3333333333333333 * Float64(z * t))
	tmp = 0.0
	if (Float64(Float64(t_2 * cos(Float64(y - Float64(Float64(z * t) / 3.0)))) - t_1) <= 5e+272)
		tmp = Float64(Float64(t_2 * fma(sin(t_3), sin(y), Float64(cos(t_3) * cos(y)))) - t_1);
	else
		tmp = Float64(-1.0 * fma(0.3333333333333333, Float64(a / b), Float64(2.0 * Float64(x * Float64(cos(y) * sqrt(Float64(1.0 / x)))))));
	end
	return tmp
end
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[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(0.3333333333333333 * N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$2 * N[Cos[N[(y - N[(N[(z * t), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], 5e+272], N[(N[(t$95$2 * N[(N[Sin[t$95$3], $MachinePrecision] * N[Sin[y], $MachinePrecision] + N[(N[Cos[t$95$3], $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[(-1.0 * N[(0.3333333333333333 * N[(a / b), $MachinePrecision] + N[(2.0 * N[(x * N[(N[Cos[y], $MachinePrecision] * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \frac{a}{b \cdot 3}\\
t_2 := 2 \cdot \sqrt{x}\\
t_3 := 0.3333333333333333 \cdot \left(z \cdot t\right)\\
\mathbf{if}\;t\_2 \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - t\_1 \leq 5 \cdot 10^{+272}:\\
\;\;\;\;t\_2 \cdot \mathsf{fma}\left(\sin t\_3, \sin y, \cos t\_3 \cdot \cos y\right) - t\_1\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \mathsf{fma}\left(0.3333333333333333, \frac{a}{b}, 2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (*.f64 #s(literal 2 binary64) (sqrt.f64 x)) (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64))))) (/.f64 a (*.f64 b #s(literal 3 binary64)))) < 4.99999999999999973e272

    1. Initial program 69.8%

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Applied rewrites69.8%

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos \color{blue}{\left(\mathsf{fma}\left(t, \frac{z}{-3}, y\right)\right)} - \frac{a}{b \cdot 3} \]
    3. Applied rewrites70.3%

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(0.3333333333333333 \cdot \left(z \cdot t\right)\right), \sin y, \cos \left(0.3333333333333333 \cdot \left(z \cdot t\right)\right) \cdot \cos y\right)} - \frac{a}{b \cdot 3} \]

    if 4.99999999999999973e272 < (-.f64 (*.f64 (*.f64 #s(literal 2 binary64) (sqrt.f64 x)) (cos.f64 (-.f64 y (/.f64 (*.f64 z t) #s(literal 3 binary64))))) (/.f64 a (*.f64 b #s(literal 3 binary64))))

    1. Initial program 69.8%

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(\frac{1}{3} \cdot \frac{a}{b \cdot x} + 2 \cdot \left(\cos \left(y - \frac{1}{3} \cdot \left(t \cdot z\right)\right) \cdot \sqrt{\frac{1}{x}}\right)\right)\right)} \]
    3. Applied rewrites35.1%

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \mathsf{fma}\left(0.3333333333333333, \frac{a}{b \cdot x}, 2 \cdot \left(\cos \left(y - 0.3333333333333333 \cdot \left(t \cdot z\right)\right) \cdot \sqrt{\frac{1}{x}}\right)\right)\right)} \]
    4. Applied rewrites38.5%

      \[\leadsto -1 \cdot \left(x \cdot \frac{\mathsf{fma}\left(\cos \left(\mathsf{fma}\left(t, z \cdot -0.3333333333333333, y\right)\right), \sqrt{\frac{1}{x}} \cdot \left(x + x\right), \frac{a}{b \cdot 3}\right)}{\color{blue}{x}}\right) \]
    5. Taylor expanded in z around 0

      \[\leadsto -1 \cdot \left(\frac{1}{3} \cdot \frac{a}{b} + \color{blue}{2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)}\right) \]
    6. Applied rewrites51.8%

      \[\leadsto -1 \cdot \mathsf{fma}\left(0.3333333333333333, \color{blue}{\frac{a}{b}}, 2 \cdot \left(x \cdot \left(\cos y \cdot \sqrt{\frac{1}{x}}\right)\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 76.5% accurate, 1.2× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{b \cdot 3} \end{array} \]
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
 (- (* (* 2.0 (sqrt x)) (cos y)) (/ a (* b 3.0))))
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 ((2.0 * sqrt(x)) * cos(y)) - (a / (b * 3.0));
}
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 = ((2.0d0 * sqrt(x)) * cos(y)) - (a / (b * 3.0d0))
end function
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 ((2.0 * Math.sqrt(x)) * Math.cos(y)) - (a / (b * 3.0));
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	return ((2.0 * math.sqrt(x)) * math.cos(y)) - (a / (b * 3.0))
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(2.0 * sqrt(x)) * cos(y)) - Float64(a / Float64(b * 3.0)))
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = ((2.0 * sqrt(x)) * cos(y)) - (a / (b * 3.0));
end
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[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{b \cdot 3}
\end{array}
Derivation
  1. Initial program 69.8%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in z around 0

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
  3. Applied rewrites76.5%

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
  4. Add Preprocessing

Alternative 5: 65.7% accurate, 3.3× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \left(2 \cdot \sqrt{x}\right) \cdot 1 - \frac{a}{b \cdot 3} \end{array} \]
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
 (- (* (* 2.0 (sqrt x)) 1.0) (/ a (* b 3.0))))
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 ((2.0 * sqrt(x)) * 1.0) - (a / (b * 3.0));
}
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 = ((2.0d0 * sqrt(x)) * 1.0d0) - (a / (b * 3.0d0))
end function
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 ((2.0 * Math.sqrt(x)) * 1.0) - (a / (b * 3.0));
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	return ((2.0 * math.sqrt(x)) * 1.0) - (a / (b * 3.0))
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(2.0 * sqrt(x)) * 1.0) - Float64(a / Float64(b * 3.0)))
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = ((2.0 * sqrt(x)) * 1.0) - (a / (b * 3.0));
end
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[(2.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] - N[(a / N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\left(2 \cdot \sqrt{x}\right) \cdot 1 - \frac{a}{b \cdot 3}
\end{array}
Derivation
  1. Initial program 69.8%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in z around 0

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
  3. Applied rewrites76.5%

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
  4. Taylor expanded in y around 0

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot 1 - \frac{a}{b \cdot 3} \]
  5. Applied rewrites65.7%

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot 1 - \frac{a}{b \cdot 3} \]
  6. Add Preprocessing

Alternative 6: 50.6% accurate, 7.6× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \frac{\frac{a}{b}}{-3} \end{array} \]
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 (/ (/ a b) -3.0))
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 (a / b) / -3.0;
}
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 = (a / b) / (-3.0d0)
end function
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 (a / b) / -3.0;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	return (a / b) / -3.0
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	return Float64(Float64(a / b) / -3.0)
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = (a / b) / -3.0;
end
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[(a / b), $MachinePrecision] / -3.0), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\frac{\frac{a}{b}}{-3}
\end{array}
Derivation
  1. Initial program 69.8%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in a around inf

    \[\leadsto \color{blue}{\frac{-1}{3} \cdot \frac{a}{b}} \]
  3. Applied rewrites50.5%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{a}{b}} \]
  4. Applied rewrites50.6%

    \[\leadsto \frac{\frac{a}{b}}{\color{blue}{-3}} \]
  5. Add Preprocessing

Alternative 7: 50.6% accurate, 8.0× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \frac{a}{b \cdot -3} \end{array} \]
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 (/ a (* b -3.0)))
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 a / (b * -3.0);
}
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 = a / (b * (-3.0d0))
end function
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 a / (b * -3.0);
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	return a / (b * -3.0)
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	return Float64(a / Float64(b * -3.0))
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = a / (b * -3.0);
end
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[(a / N[(b * -3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\frac{a}{b \cdot -3}
\end{array}
Derivation
  1. Initial program 69.8%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in a around inf

    \[\leadsto \color{blue}{\frac{-1}{3} \cdot \frac{a}{b}} \]
  3. Applied rewrites50.5%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{a}{b}} \]
  4. Applied rewrites50.6%

    \[\leadsto \frac{a}{\color{blue}{b \cdot -3}} \]
  5. Add Preprocessing

Alternative 8: 50.5% accurate, 8.0× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \frac{-0.3333333333333333}{b} \cdot a \end{array} \]
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 (* (/ -0.3333333333333333 b) a))
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 (-0.3333333333333333 / b) * a;
}
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 = ((-0.3333333333333333d0) / b) * a
end function
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 (-0.3333333333333333 / b) * a;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	return (-0.3333333333333333 / b) * a
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	return Float64(Float64(-0.3333333333333333 / b) * a)
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = (-0.3333333333333333 / b) * a;
end
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[(-0.3333333333333333 / b), $MachinePrecision] * a), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\frac{-0.3333333333333333}{b} \cdot a
\end{array}
Derivation
  1. Initial program 69.8%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in a around inf

    \[\leadsto \color{blue}{\frac{-1}{3} \cdot \frac{a}{b}} \]
  3. Applied rewrites50.5%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{a}{b}} \]
  4. Applied rewrites50.5%

    \[\leadsto \frac{-0.3333333333333333}{b} \cdot \color{blue}{a} \]
  5. Add Preprocessing

Alternative 9: 50.5% accurate, 8.0× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ -0.3333333333333333 \cdot \frac{a}{b} \end{array} \]
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 (* -0.3333333333333333 (/ 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 -0.3333333333333333 * (a / b);
}
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 = (-0.3333333333333333d0) * (a / b)
end function
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 -0.3333333333333333 * (a / b);
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	return -0.3333333333333333 * (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(-0.3333333333333333 * Float64(a / b))
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = -0.3333333333333333 * (a / b);
end
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[(-0.3333333333333333 * N[(a / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
-0.3333333333333333 \cdot \frac{a}{b}
\end{array}
Derivation
  1. Initial program 69.8%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in a around inf

    \[\leadsto \color{blue}{\frac{-1}{3} \cdot \frac{a}{b}} \]
  3. Applied rewrites50.5%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{a}{b}} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2025161 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, K"
  :precision binary64
  (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))