Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A

Percentage Accurate: 99.8% → 99.9%
Time: 8.5s
Alternatives: 12
Speedup: 1.1×

Specification

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

\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\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 12 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: 99.8% accurate, 1.0× speedup?

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

\\
\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b
\end{array}

Alternative 1: 99.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y + x\right)\right) \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (fma (- 1.0 (log t)) z (fma (- a 0.5) b (+ y x))))
double code(double x, double y, double z, double t, double a, double b) {
	return fma((1.0 - log(t)), z, fma((a - 0.5), b, (y + x)));
}
function code(x, y, z, t, a, b)
	return fma(Float64(1.0 - log(t)), z, fma(Float64(a - 0.5), b, Float64(y + x)))
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(N[(a - 0.5), $MachinePrecision] * b + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y + x\right)\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
  2. Taylor expanded in z around 0

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y + x\right)\right)} \]
  5. Add Preprocessing

Alternative 2: 90.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + y \leq -0.0005:\\ \;\;\;\;\left(\left(x + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (+ x y) -0.0005)
   (+ (- (+ x z) (* z (log t))) (* (- a 0.5) b))
   (fma (- 1.0 (log t)) z (fma (- a 0.5) b y))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x + y) <= -0.0005) {
		tmp = ((x + z) - (z * log(t))) + ((a - 0.5) * b);
	} else {
		tmp = fma((1.0 - log(t)), z, fma((a - 0.5), b, y));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(x + y) <= -0.0005)
		tmp = Float64(Float64(Float64(x + z) - Float64(z * log(t))) + Float64(Float64(a - 0.5) * b));
	else
		tmp = fma(Float64(1.0 - log(t)), z, fma(Float64(a - 0.5), b, y));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -0.0005], N[(N[(N[(x + z), $MachinePrecision] - N[(z * N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -0.0005:\\
\;\;\;\;\left(\left(x + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x y) < -5.0000000000000001e-4

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in y around 0

      \[\leadsto \left(\color{blue}{\left(x + z\right)} - z \cdot \log t\right) + \left(a - \frac{1}{2}\right) \cdot b \]
    3. Applied rewrites78.6%

      \[\leadsto \left(\color{blue}{\left(x + z\right)} - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]

    if -5.0000000000000001e-4 < (+.f64 x y)

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y + x\right)\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - \frac{1}{2}, b, y\right)\right) \]
    6. Applied rewrites79.2%

      \[\leadsto \mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 84.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + y \leq -1:\\ \;\;\;\;x + \left(y + b \cdot \left(a - 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (+ x y) -1.0)
   (+ x (+ y (* b (- a 0.5))))
   (fma (- 1.0 (log t)) z (fma (- a 0.5) b y))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x + y) <= -1.0) {
		tmp = x + (y + (b * (a - 0.5)));
	} else {
		tmp = fma((1.0 - log(t)), z, fma((a - 0.5), b, y));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(x + y) <= -1.0)
		tmp = Float64(x + Float64(y + Float64(b * Float64(a - 0.5))));
	else
		tmp = fma(Float64(1.0 - log(t)), z, fma(Float64(a - 0.5), b, y));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -1.0], N[(x + N[(y + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision] * z + N[(N[(a - 0.5), $MachinePrecision] * b + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -1:\\
\;\;\;\;x + \left(y + b \cdot \left(a - 0.5\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x y) < -1

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

      \[\leadsto \color{blue}{x + \left(y + b \cdot \left(a - 0.5\right)\right)} \]

    if -1 < (+.f64 x y)

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y + x\right)\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - \frac{1}{2}, b, y\right)\right) \]
    6. Applied rewrites79.2%

      \[\leadsto \mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 83.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(a - 0.5\right) \cdot b\\ t_2 := x + \left(y + b \cdot \left(a - 0.5\right)\right)\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{+49}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+46}:\\ \;\;\;\;x + \left(y + z \cdot \left(1 - \log t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (- a 0.5) b)) (t_2 (+ x (+ y (* b (- a 0.5))))))
   (if (<= t_1 -2e+49)
     t_2
     (if (<= t_1 2e+46) (+ x (+ y (* z (- 1.0 (log t))))) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a - 0.5) * b;
	double t_2 = x + (y + (b * (a - 0.5)));
	double tmp;
	if (t_1 <= -2e+49) {
		tmp = t_2;
	} else if (t_1 <= 2e+46) {
		tmp = x + (y + (z * (1.0 - log(t))));
	} else {
		tmp = t_2;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (a - 0.5d0) * b
    t_2 = x + (y + (b * (a - 0.5d0)))
    if (t_1 <= (-2d+49)) then
        tmp = t_2
    else if (t_1 <= 2d+46) then
        tmp = x + (y + (z * (1.0d0 - log(t))))
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a - 0.5) * b;
	double t_2 = x + (y + (b * (a - 0.5)));
	double tmp;
	if (t_1 <= -2e+49) {
		tmp = t_2;
	} else if (t_1 <= 2e+46) {
		tmp = x + (y + (z * (1.0 - Math.log(t))));
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = (a - 0.5) * b
	t_2 = x + (y + (b * (a - 0.5)))
	tmp = 0
	if t_1 <= -2e+49:
		tmp = t_2
	elif t_1 <= 2e+46:
		tmp = x + (y + (z * (1.0 - math.log(t))))
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a - 0.5) * b)
	t_2 = Float64(x + Float64(y + Float64(b * Float64(a - 0.5))))
	tmp = 0.0
	if (t_1 <= -2e+49)
		tmp = t_2;
	elseif (t_1 <= 2e+46)
		tmp = Float64(x + Float64(y + Float64(z * Float64(1.0 - log(t)))));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (a - 0.5) * b;
	t_2 = x + (y + (b * (a - 0.5)));
	tmp = 0.0;
	if (t_1 <= -2e+49)
		tmp = t_2;
	elseif (t_1 <= 2e+46)
		tmp = x + (y + (z * (1.0 - log(t))));
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(y + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+49], t$95$2, If[LessEqual[t$95$1, 2e+46], N[(x + N[(y + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := x + \left(y + b \cdot \left(a - 0.5\right)\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+49}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+46}:\\
\;\;\;\;x + \left(y + z \cdot \left(1 - \log t\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.99999999999999989e49 or 2e46 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

      \[\leadsto \color{blue}{x + \left(y + b \cdot \left(a - 0.5\right)\right)} \]

    if -1.99999999999999989e49 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e46

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

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

      \[\leadsto x + \left(y + \color{blue}{z \cdot \left(1 - \log t\right)}\right) \]
    5. Applied rewrites63.8%

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

Alternative 5: 82.6% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;z \leq -2.2 \cdot 10^{+104}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{+132}:\\ \;\;\;\;x + \left(y + b \cdot \left(a - 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (+ x (* z (- 1.0 (log t))))))
   (if (<= z -2.2e+104)
     t_1
     (if (<= z 1.02e+132) (+ x (+ y (* b (- a 0.5)))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (z * (1.0 - log(t)));
	double tmp;
	if (z <= -2.2e+104) {
		tmp = t_1;
	} else if (z <= 1.02e+132) {
		tmp = x + (y + (b * (a - 0.5)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x + (z * (1.0d0 - log(t)))
    if (z <= (-2.2d+104)) then
        tmp = t_1
    else if (z <= 1.02d+132) then
        tmp = x + (y + (b * (a - 0.5d0)))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (z * (1.0 - Math.log(t)));
	double tmp;
	if (z <= -2.2e+104) {
		tmp = t_1;
	} else if (z <= 1.02e+132) {
		tmp = x + (y + (b * (a - 0.5)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = x + (z * (1.0 - math.log(t)))
	tmp = 0
	if z <= -2.2e+104:
		tmp = t_1
	elif z <= 1.02e+132:
		tmp = x + (y + (b * (a - 0.5)))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(x + Float64(z * Float64(1.0 - log(t))))
	tmp = 0.0
	if (z <= -2.2e+104)
		tmp = t_1;
	elseif (z <= 1.02e+132)
		tmp = Float64(x + Float64(y + Float64(b * Float64(a - 0.5))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = x + (z * (1.0 - log(t)));
	tmp = 0.0;
	if (z <= -2.2e+104)
		tmp = t_1;
	elseif (z <= 1.02e+132)
		tmp = x + (y + (b * (a - 0.5)));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.2e+104], t$95$1, If[LessEqual[z, 1.02e+132], N[(x + N[(y + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + z \cdot \left(1 - \log t\right)\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{+104}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.02 \cdot 10^{+132}:\\
\;\;\;\;x + \left(y + b \cdot \left(a - 0.5\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.2e104 or 1.0200000000000001e132 < z

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

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

      \[\leadsto x + \left(y + \color{blue}{z \cdot \left(1 - \log t\right)}\right) \]
    5. Applied rewrites63.8%

      \[\leadsto x + \left(y + \color{blue}{z \cdot \left(1 - \log t\right)}\right) \]
    6. Taylor expanded in y around 0

      \[\leadsto x + z \cdot \left(1 - \color{blue}{\log t}\right) \]
    7. Applied rewrites43.1%

      \[\leadsto x + z \cdot \left(1 - \color{blue}{\log t}\right) \]

    if -2.2e104 < z < 1.0200000000000001e132

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

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

Alternative 6: 78.9% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := z \cdot \left(1 - \log t\right)\\ \mathbf{if}\;z \leq -7.4 \cdot 10^{+202}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+144}:\\ \;\;\;\;x + \left(y + b \cdot \left(a - 0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* z (- 1.0 (log t)))))
   (if (<= z -7.4e+202)
     t_1
     (if (<= z 6e+144) (+ x (+ y (* b (- a 0.5)))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = z * (1.0 - log(t));
	double tmp;
	if (z <= -7.4e+202) {
		tmp = t_1;
	} else if (z <= 6e+144) {
		tmp = x + (y + (b * (a - 0.5)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = z * (1.0d0 - log(t))
    if (z <= (-7.4d+202)) then
        tmp = t_1
    else if (z <= 6d+144) then
        tmp = x + (y + (b * (a - 0.5d0)))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = z * (1.0 - Math.log(t));
	double tmp;
	if (z <= -7.4e+202) {
		tmp = t_1;
	} else if (z <= 6e+144) {
		tmp = x + (y + (b * (a - 0.5)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = z * (1.0 - math.log(t))
	tmp = 0
	if z <= -7.4e+202:
		tmp = t_1
	elif z <= 6e+144:
		tmp = x + (y + (b * (a - 0.5)))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(z * Float64(1.0 - log(t)))
	tmp = 0.0
	if (z <= -7.4e+202)
		tmp = t_1;
	elseif (z <= 6e+144)
		tmp = Float64(x + Float64(y + Float64(b * Float64(a - 0.5))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = z * (1.0 - log(t));
	tmp = 0.0;
	if (z <= -7.4e+202)
		tmp = t_1;
	elseif (z <= 6e+144)
		tmp = x + (y + (b * (a - 0.5)));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z * N[(1.0 - N[Log[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.4e+202], t$95$1, If[LessEqual[z, 6e+144], N[(x + N[(y + N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := z \cdot \left(1 - \log t\right)\\
\mathbf{if}\;z \leq -7.4 \cdot 10^{+202}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 6 \cdot 10^{+144}:\\
\;\;\;\;x + \left(y + b \cdot \left(a - 0.5\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.3999999999999997e202 or 5.9999999999999998e144 < z

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(1 - \log t\right)} \]
    3. Applied rewrites23.3%

      \[\leadsto \color{blue}{z \cdot \left(1 - \log t\right)} \]

    if -7.3999999999999997e202 < z < 5.9999999999999998e144

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

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

Alternative 7: 77.8% accurate, 2.2× speedup?

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

\\
x + \left(y + b \cdot \left(a - 0.5\right)\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
  2. Taylor expanded in z around 0

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

    \[\leadsto \color{blue}{x + \left(y + b \cdot \left(a - 0.5\right)\right)} \]
  4. Add Preprocessing

Alternative 8: 48.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x + y \leq -5 \cdot 10^{+176}:\\ \;\;\;\;-1 \cdot \left(-x\right)\\ \mathbf{elif}\;x + y \leq 10^{+124}:\\ \;\;\;\;b \cdot \left(a - 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \left(-1 \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (+ x y) -5e+176)
   (* -1.0 (- x))
   (if (<= (+ x y) 1e+124) (* b (- a 0.5)) (* -1.0 (* -1.0 y)))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x + y) <= -5e+176) {
		tmp = -1.0 * -x;
	} else if ((x + y) <= 1e+124) {
		tmp = b * (a - 0.5);
	} else {
		tmp = -1.0 * (-1.0 * y);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if ((x + y) <= (-5d+176)) then
        tmp = (-1.0d0) * -x
    else if ((x + y) <= 1d+124) then
        tmp = b * (a - 0.5d0)
    else
        tmp = (-1.0d0) * ((-1.0d0) * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x + y) <= -5e+176) {
		tmp = -1.0 * -x;
	} else if ((x + y) <= 1e+124) {
		tmp = b * (a - 0.5);
	} else {
		tmp = -1.0 * (-1.0 * y);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if (x + y) <= -5e+176:
		tmp = -1.0 * -x
	elif (x + y) <= 1e+124:
		tmp = b * (a - 0.5)
	else:
		tmp = -1.0 * (-1.0 * y)
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(x + y) <= -5e+176)
		tmp = Float64(-1.0 * Float64(-x));
	elseif (Float64(x + y) <= 1e+124)
		tmp = Float64(b * Float64(a - 0.5));
	else
		tmp = Float64(-1.0 * Float64(-1.0 * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if ((x + y) <= -5e+176)
		tmp = -1.0 * -x;
	elseif ((x + y) <= 1e+124)
		tmp = b * (a - 0.5);
	else
		tmp = -1.0 * (-1.0 * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x + y), $MachinePrecision], -5e+176], N[(-1.0 * (-x)), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 1e+124], N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(-1.0 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -5 \cdot 10^{+176}:\\
\;\;\;\;-1 \cdot \left(-x\right)\\

\mathbf{elif}\;x + y \leq 10^{+124}:\\
\;\;\;\;b \cdot \left(a - 0.5\right)\\

\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(-1 \cdot y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 x y) < -5e176

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in b around -inf

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

      \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \mathsf{fma}\left(-1, a - 0.5, -1 \cdot \frac{\left(x + \left(y + z\right)\right) - z \cdot \log t}{b}\right)\right)} \]
    4. Taylor expanded in x around inf

      \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{x}\right) \]
    5. Applied rewrites21.8%

      \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{x}\right) \]
    6. Applied rewrites21.8%

      \[\leadsto -1 \cdot \left(-x\right) \]

    if -5e176 < (+.f64 x y) < 9.99999999999999948e123

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y + x\right)\right)} \]
    5. Taylor expanded in b around inf

      \[\leadsto \color{blue}{b \cdot \left(a - \frac{1}{2}\right)} \]
    6. Applied rewrites37.2%

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

    if 9.99999999999999948e123 < (+.f64 x y)

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in b around -inf

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

      \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \mathsf{fma}\left(-1, a - 0.5, -1 \cdot \frac{\left(x + \left(y + z\right)\right) - z \cdot \log t}{b}\right)\right)} \]
    4. Taylor expanded in y around inf

      \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{y}\right) \]
    5. Applied rewrites22.3%

      \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{y}\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 40.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(a - 0.5\right) \cdot b\\ t_2 := b \cdot \left(a - 0.5\right)\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+136}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+46}:\\ \;\;\;\;-1 \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (- a 0.5) b)) (t_2 (* b (- a 0.5))))
   (if (<= t_1 -1e+136) t_2 (if (<= t_1 2e+46) (* -1.0 (- x)) t_2))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a - 0.5) * b;
	double t_2 = b * (a - 0.5);
	double tmp;
	if (t_1 <= -1e+136) {
		tmp = t_2;
	} else if (t_1 <= 2e+46) {
		tmp = -1.0 * -x;
	} else {
		tmp = t_2;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (a - 0.5d0) * b
    t_2 = b * (a - 0.5d0)
    if (t_1 <= (-1d+136)) then
        tmp = t_2
    else if (t_1 <= 2d+46) then
        tmp = (-1.0d0) * -x
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a - 0.5) * b;
	double t_2 = b * (a - 0.5);
	double tmp;
	if (t_1 <= -1e+136) {
		tmp = t_2;
	} else if (t_1 <= 2e+46) {
		tmp = -1.0 * -x;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = (a - 0.5) * b
	t_2 = b * (a - 0.5)
	tmp = 0
	if t_1 <= -1e+136:
		tmp = t_2
	elif t_1 <= 2e+46:
		tmp = -1.0 * -x
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a - 0.5) * b)
	t_2 = Float64(b * Float64(a - 0.5))
	tmp = 0.0
	if (t_1 <= -1e+136)
		tmp = t_2;
	elseif (t_1 <= 2e+46)
		tmp = Float64(-1.0 * Float64(-x));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (a - 0.5) * b;
	t_2 = b * (a - 0.5);
	tmp = 0.0;
	if (t_1 <= -1e+136)
		tmp = t_2;
	elseif (t_1 <= 2e+46)
		tmp = -1.0 * -x;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(a - 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+136], t$95$2, If[LessEqual[t$95$1, 2e+46], N[(-1.0 * (-x)), $MachinePrecision], t$95$2]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
t_2 := b \cdot \left(a - 0.5\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+136}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+46}:\\
\;\;\;\;-1 \cdot \left(-x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.00000000000000006e136 or 2e46 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in z around 0

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1 - \log t, z, \mathsf{fma}\left(a - 0.5, b, y + x\right)\right)} \]
    5. Taylor expanded in b around inf

      \[\leadsto \color{blue}{b \cdot \left(a - \frac{1}{2}\right)} \]
    6. Applied rewrites37.2%

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

    if -1.00000000000000006e136 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 2e46

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in b around -inf

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

      \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \mathsf{fma}\left(-1, a - 0.5, -1 \cdot \frac{\left(x + \left(y + z\right)\right) - z \cdot \log t}{b}\right)\right)} \]
    4. Taylor expanded in x around inf

      \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{x}\right) \]
    5. Applied rewrites21.8%

      \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{x}\right) \]
    6. Applied rewrites21.8%

      \[\leadsto -1 \cdot \left(-x\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 39.3% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(a - 0.5\right) \cdot b\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{+197}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+117}:\\ \;\;\;\;-1 \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (- a 0.5) b)))
   (if (<= t_1 -2e+197) (* a b) (if (<= t_1 5e+117) (* -1.0 (- x)) (* a b)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a - 0.5) * b;
	double tmp;
	if (t_1 <= -2e+197) {
		tmp = a * b;
	} else if (t_1 <= 5e+117) {
		tmp = -1.0 * -x;
	} else {
		tmp = a * b;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (a - 0.5d0) * b
    if (t_1 <= (-2d+197)) then
        tmp = a * b
    else if (t_1 <= 5d+117) then
        tmp = (-1.0d0) * -x
    else
        tmp = a * b
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a - 0.5) * b;
	double tmp;
	if (t_1 <= -2e+197) {
		tmp = a * b;
	} else if (t_1 <= 5e+117) {
		tmp = -1.0 * -x;
	} else {
		tmp = a * b;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = (a - 0.5) * b
	tmp = 0
	if t_1 <= -2e+197:
		tmp = a * b
	elif t_1 <= 5e+117:
		tmp = -1.0 * -x
	else:
		tmp = a * b
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a - 0.5) * b)
	tmp = 0.0
	if (t_1 <= -2e+197)
		tmp = Float64(a * b);
	elseif (t_1 <= 5e+117)
		tmp = Float64(-1.0 * Float64(-x));
	else
		tmp = Float64(a * b);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (a - 0.5) * b;
	tmp = 0.0;
	if (t_1 <= -2e+197)
		tmp = a * b;
	elseif (t_1 <= 5e+117)
		tmp = -1.0 * -x;
	else
		tmp = a * b;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a - 0.5), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+197], N[(a * b), $MachinePrecision], If[LessEqual[t$95$1, 5e+117], N[(-1.0 * (-x)), $MachinePrecision], N[(a * b), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(a - 0.5\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+197}:\\
\;\;\;\;a \cdot b\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+117}:\\
\;\;\;\;-1 \cdot \left(-x\right)\\

\mathbf{else}:\\
\;\;\;\;a \cdot b\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < -1.9999999999999999e197 or 4.99999999999999983e117 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b)

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in a around inf

      \[\leadsto \color{blue}{a \cdot b} \]
    3. Applied rewrites25.5%

      \[\leadsto \color{blue}{a \cdot b} \]

    if -1.9999999999999999e197 < (*.f64 (-.f64 a #s(literal 1/2 binary64)) b) < 4.99999999999999983e117

    1. Initial program 99.8%

      \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
    2. Taylor expanded in b around -inf

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

      \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \mathsf{fma}\left(-1, a - 0.5, -1 \cdot \frac{\left(x + \left(y + z\right)\right) - z \cdot \log t}{b}\right)\right)} \]
    4. Taylor expanded in x around inf

      \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{x}\right) \]
    5. Applied rewrites21.8%

      \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{x}\right) \]
    6. Applied rewrites21.8%

      \[\leadsto -1 \cdot \left(-x\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 25.5% accurate, 6.6× speedup?

\[\begin{array}{l} \\ a \cdot b \end{array} \]
(FPCore (x y z t a b) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b) {
	return a * b;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return a * b;
}
def code(x, y, z, t, a, b):
	return a * b
function code(x, y, z, t, a, b)
	return Float64(a * b)
end
function tmp = code(x, y, z, t, a, b)
	tmp = a * b;
end
code[x_, y_, z_, t_, a_, b_] := N[(a * b), $MachinePrecision]
\begin{array}{l}

\\
a \cdot b
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
  2. Taylor expanded in a around inf

    \[\leadsto \color{blue}{a \cdot b} \]
  3. Applied rewrites25.5%

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

Alternative 12: 2.2% accurate, 6.6× speedup?

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

\\
-1 \cdot y
\end{array}
Derivation
  1. Initial program 99.8%

    \[\left(\left(\left(x + y\right) + z\right) - z \cdot \log t\right) + \left(a - 0.5\right) \cdot b \]
  2. Taylor expanded in b around -inf

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

    \[\leadsto \color{blue}{-1 \cdot \left(b \cdot \mathsf{fma}\left(-1, a - 0.5, -1 \cdot \frac{\left(x + \left(y + z\right)\right) - z \cdot \log t}{b}\right)\right)} \]
  4. Taylor expanded in x around inf

    \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{x}\right) \]
  5. Applied rewrites21.8%

    \[\leadsto -1 \cdot \left(-1 \cdot \color{blue}{x}\right) \]
  6. Applied rewrites21.8%

    \[\leadsto -1 \cdot \left(-x\right) \]
  7. Taylor expanded in y around inf

    \[\leadsto -1 \cdot \color{blue}{y} \]
  8. Applied rewrites2.2%

    \[\leadsto -1 \cdot \color{blue}{y} \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2025159 
(FPCore (x y z t a b)
  :name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, A"
  :precision binary64
  (+ (- (+ (+ x y) z) (* z (log t))) (* (- a 0.5) b)))