Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, B

Percentage Accurate: 96.5% → 99.2%
Time: 21.2s
Alternatives: 11
Speedup: 1.1×

Specification

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

\\
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}
\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 11 alternatives:

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

Initial Program: 96.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.2% accurate, 1.1× speedup?

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

\\
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(-1 \cdot z - b\right)}
\end{array}
Derivation
  1. Initial program 96.5%

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

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

    \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\color{blue}{-1 \cdot z} - b\right)} \]
  4. Add Preprocessing

Alternative 2: 96.5% accurate, 1.3× speedup?

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

\\
x \cdot e^{\mathsf{fma}\left(\log z - t, y, -a \cdot b\right)}
\end{array}
Derivation
  1. Initial program 96.5%

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

    \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(a \cdot b\right) + y \cdot \left(\log z - t\right)}} \]
  3. Applied rewrites96.0%

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

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

Alternative 3: 96.4% accurate, 1.4× speedup?

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

\\
\frac{x}{e^{\mathsf{fma}\left(b, a, \left(t - \log z\right) \cdot y\right)}}
\end{array}
Derivation
  1. Initial program 96.5%

    \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
  2. Applied rewrites96.9%

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

    \[\leadsto \frac{x}{e^{\mathsf{fma}\left(\color{blue}{b}, a, \left(t - \log z\right) \cdot y\right)}} \]
  4. Applied rewrites96.5%

    \[\leadsto \frac{x}{e^{\mathsf{fma}\left(\color{blue}{b}, a, \left(t - \log z\right) \cdot y\right)}} \]
  5. Add Preprocessing

Alternative 4: 91.6% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot e^{y \cdot \left(\log z - t\right)}\\ \mathbf{if}\;y \leq -5.6 \cdot 10^{+45}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+19}:\\ \;\;\;\;x \cdot e^{\mathsf{fma}\left(-1, a \cdot b, y \cdot \left(-1 \cdot t\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* x (exp (* y (- (log z) t))))))
   (if (<= y -5.6e+45)
     t_1
     (if (<= y 8.5e+19) (* x (exp (fma -1.0 (* a b) (* y (* -1.0 t))))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x * exp((y * (log(z) - t)));
	double tmp;
	if (y <= -5.6e+45) {
		tmp = t_1;
	} else if (y <= 8.5e+19) {
		tmp = x * exp(fma(-1.0, (a * b), (y * (-1.0 * t))));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = Float64(x * exp(Float64(y * Float64(log(z) - t))))
	tmp = 0.0
	if (y <= -5.6e+45)
		tmp = t_1;
	elseif (y <= 8.5e+19)
		tmp = Float64(x * exp(fma(-1.0, Float64(a * b), Float64(y * Float64(-1.0 * t)))));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x * N[Exp[N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.6e+45], t$95$1, If[LessEqual[y, 8.5e+19], N[(x * N[Exp[N[(-1.0 * N[(a * b), $MachinePrecision] + N[(y * N[(-1.0 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot e^{y \cdot \left(\log z - t\right)}\\
\mathbf{if}\;y \leq -5.6 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 8.5 \cdot 10^{+19}:\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(-1, a \cdot b, y \cdot \left(-1 \cdot t\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.5999999999999999e45 or 8.5e19 < y

    1. Initial program 96.5%

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

      \[\leadsto x \cdot \color{blue}{e^{y \cdot \left(\log z - t\right)}} \]
    3. Applied rewrites71.7%

      \[\leadsto x \cdot \color{blue}{e^{y \cdot \left(\log z - t\right)}} \]

    if -5.5999999999999999e45 < y < 8.5e19

    1. Initial program 96.5%

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

      \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(a \cdot b\right) + y \cdot \left(\log z - t\right)}} \]
    3. Applied rewrites96.0%

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

      \[\leadsto x \cdot e^{\mathsf{fma}\left(-1, a \cdot b, y \cdot \left(-1 \cdot t\right)\right)} \]
    5. Applied rewrites84.2%

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

Alternative 5: 84.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot e^{a \cdot \left(\left(-z\right) - b\right)}\\ \mathbf{if}\;a \leq -7.4 \cdot 10^{+83}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;a \leq 1.45 \cdot 10^{+72}:\\ \;\;\;\;x \cdot e^{y \cdot \left(\log z - t\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* x (exp (* a (- (- z) b))))))
   (if (<= a -7.4e+83)
     t_1
     (if (<= a 1.45e+72) (* x (exp (* y (- (log z) t)))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x * exp((a * (-z - b)));
	double tmp;
	if (a <= -7.4e+83) {
		tmp = t_1;
	} else if (a <= 1.45e+72) {
		tmp = x * exp((y * (log(z) - t)));
	} 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 * exp((a * (-z - b)))
    if (a <= (-7.4d+83)) then
        tmp = t_1
    else if (a <= 1.45d+72) then
        tmp = x * exp((y * (log(z) - t)))
    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 * Math.exp((a * (-z - b)));
	double tmp;
	if (a <= -7.4e+83) {
		tmp = t_1;
	} else if (a <= 1.45e+72) {
		tmp = x * Math.exp((y * (Math.log(z) - t)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = x * math.exp((a * (-z - b)))
	tmp = 0
	if a <= -7.4e+83:
		tmp = t_1
	elif a <= 1.45e+72:
		tmp = x * math.exp((y * (math.log(z) - t)))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(x * exp(Float64(a * Float64(Float64(-z) - b))))
	tmp = 0.0
	if (a <= -7.4e+83)
		tmp = t_1;
	elseif (a <= 1.45e+72)
		tmp = Float64(x * exp(Float64(y * Float64(log(z) - t))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = x * exp((a * (-z - b)));
	tmp = 0.0;
	if (a <= -7.4e+83)
		tmp = t_1;
	elseif (a <= 1.45e+72)
		tmp = x * exp((y * (log(z) - t)));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x * N[Exp[N[(a * N[((-z) - b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -7.4e+83], t$95$1, If[LessEqual[a, 1.45e+72], N[(x * N[Exp[N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot e^{a \cdot \left(\left(-z\right) - b\right)}\\
\mathbf{if}\;a \leq -7.4 \cdot 10^{+83}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;a \leq 1.45 \cdot 10^{+72}:\\
\;\;\;\;x \cdot e^{y \cdot \left(\log z - t\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -7.4000000000000005e83 or 1.45000000000000009e72 < a

    1. Initial program 96.5%

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

      \[\leadsto x \cdot e^{\color{blue}{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    3. Applied rewrites59.4%

      \[\leadsto x \cdot e^{\color{blue}{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites63.2%

      \[\leadsto x \cdot e^{a \cdot \left(\mathsf{log1p}\left(-z\right) - b\right)} \]
    5. Taylor expanded in z around 0

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - \color{blue}{b}\right)} \]
    6. Applied rewrites63.2%

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - \color{blue}{b}\right)} \]
    7. Applied rewrites63.2%

      \[\leadsto x \cdot e^{a \cdot \left(\left(-z\right) - \color{blue}{b}\right)} \]

    if -7.4000000000000005e83 < a < 1.45000000000000009e72

    1. Initial program 96.5%

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

      \[\leadsto x \cdot \color{blue}{e^{y \cdot \left(\log z - t\right)}} \]
    3. Applied rewrites71.7%

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

Alternative 6: 73.9% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot e^{a \cdot \left(\left(-z\right) - b\right)}\\ \mathbf{if}\;a \leq -6.8 \cdot 10^{+83}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;a \leq 2.35 \cdot 10^{-18}:\\ \;\;\;\;x \cdot e^{\left(-y\right) \cdot t}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* x (exp (* a (- (- z) b))))))
   (if (<= a -6.8e+83) t_1 (if (<= a 2.35e-18) (* x (exp (* (- y) t))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x * exp((a * (-z - b)));
	double tmp;
	if (a <= -6.8e+83) {
		tmp = t_1;
	} else if (a <= 2.35e-18) {
		tmp = x * exp((-y * t));
	} 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 * exp((a * (-z - b)))
    if (a <= (-6.8d+83)) then
        tmp = t_1
    else if (a <= 2.35d-18) then
        tmp = x * exp((-y * t))
    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 * Math.exp((a * (-z - b)));
	double tmp;
	if (a <= -6.8e+83) {
		tmp = t_1;
	} else if (a <= 2.35e-18) {
		tmp = x * Math.exp((-y * t));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = x * math.exp((a * (-z - b)))
	tmp = 0
	if a <= -6.8e+83:
		tmp = t_1
	elif a <= 2.35e-18:
		tmp = x * math.exp((-y * t))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(x * exp(Float64(a * Float64(Float64(-z) - b))))
	tmp = 0.0
	if (a <= -6.8e+83)
		tmp = t_1;
	elseif (a <= 2.35e-18)
		tmp = Float64(x * exp(Float64(Float64(-y) * t)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = x * exp((a * (-z - b)));
	tmp = 0.0;
	if (a <= -6.8e+83)
		tmp = t_1;
	elseif (a <= 2.35e-18)
		tmp = x * exp((-y * t));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x * N[Exp[N[(a * N[((-z) - b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -6.8e+83], t$95$1, If[LessEqual[a, 2.35e-18], N[(x * N[Exp[N[((-y) * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot e^{a \cdot \left(\left(-z\right) - b\right)}\\
\mathbf{if}\;a \leq -6.8 \cdot 10^{+83}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;a \leq 2.35 \cdot 10^{-18}:\\
\;\;\;\;x \cdot e^{\left(-y\right) \cdot t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -6.7999999999999996e83 or 2.3499999999999998e-18 < a

    1. Initial program 96.5%

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

      \[\leadsto x \cdot e^{\color{blue}{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    3. Applied rewrites59.4%

      \[\leadsto x \cdot e^{\color{blue}{a \cdot \left(\log \left(1 - z\right) - b\right)}} \]
    4. Applied rewrites63.2%

      \[\leadsto x \cdot e^{a \cdot \left(\mathsf{log1p}\left(-z\right) - b\right)} \]
    5. Taylor expanded in z around 0

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - \color{blue}{b}\right)} \]
    6. Applied rewrites63.2%

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - \color{blue}{b}\right)} \]
    7. Applied rewrites63.2%

      \[\leadsto x \cdot e^{a \cdot \left(\left(-z\right) - \color{blue}{b}\right)} \]

    if -6.7999999999999996e83 < a < 2.3499999999999998e-18

    1. Initial program 96.5%

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

      \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(t \cdot y\right)}} \]
    3. Applied rewrites56.9%

      \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(t \cdot y\right)}} \]
    4. Applied rewrites56.9%

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

Alternative 7: 69.6% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -7.2 \cdot 10^{+83}:\\ \;\;\;\;x \cdot e^{-a \cdot b}\\ \mathbf{elif}\;a \leq 2.35 \cdot 10^{-18}:\\ \;\;\;\;x \cdot e^{\left(-y\right) \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{a \cdot b}}\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= a -7.2e+83)
   (* x (exp (- (* a b))))
   (if (<= a 2.35e-18) (* x (exp (* (- y) t))) (/ x (exp (* a b))))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (a <= -7.2e+83) {
		tmp = x * exp(-(a * b));
	} else if (a <= 2.35e-18) {
		tmp = x * exp((-y * t));
	} else {
		tmp = x / exp((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) :: tmp
    if (a <= (-7.2d+83)) then
        tmp = x * exp(-(a * b))
    else if (a <= 2.35d-18) then
        tmp = x * exp((-y * t))
    else
        tmp = x / exp((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 tmp;
	if (a <= -7.2e+83) {
		tmp = x * Math.exp(-(a * b));
	} else if (a <= 2.35e-18) {
		tmp = x * Math.exp((-y * t));
	} else {
		tmp = x / Math.exp((a * b));
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if a <= -7.2e+83:
		tmp = x * math.exp(-(a * b))
	elif a <= 2.35e-18:
		tmp = x * math.exp((-y * t))
	else:
		tmp = x / math.exp((a * b))
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (a <= -7.2e+83)
		tmp = Float64(x * exp(Float64(-Float64(a * b))));
	elseif (a <= 2.35e-18)
		tmp = Float64(x * exp(Float64(Float64(-y) * t)));
	else
		tmp = Float64(x / exp(Float64(a * b)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (a <= -7.2e+83)
		tmp = x * exp(-(a * b));
	elseif (a <= 2.35e-18)
		tmp = x * exp((-y * t));
	else
		tmp = x / exp((a * b));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -7.2e+83], N[(x * N[Exp[(-N[(a * b), $MachinePrecision])], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.35e-18], N[(x * N[Exp[N[((-y) * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x / N[Exp[N[(a * b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.2 \cdot 10^{+83}:\\
\;\;\;\;x \cdot e^{-a \cdot b}\\

\mathbf{elif}\;a \leq 2.35 \cdot 10^{-18}:\\
\;\;\;\;x \cdot e^{\left(-y\right) \cdot t}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{a \cdot b}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -7.1999999999999995e83

    1. Initial program 96.5%

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

      \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(a \cdot b\right) + y \cdot \left(\log z - t\right)}} \]
    3. Applied rewrites96.0%

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

      \[\leadsto x \cdot e^{-1 \cdot \color{blue}{\left(a \cdot b\right)}} \]
    5. Applied rewrites58.6%

      \[\leadsto x \cdot e^{-1 \cdot \color{blue}{\left(a \cdot b\right)}} \]
    6. Applied rewrites58.6%

      \[\leadsto x \cdot \color{blue}{e^{-a \cdot b}} \]

    if -7.1999999999999995e83 < a < 2.3499999999999998e-18

    1. Initial program 96.5%

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

      \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(t \cdot y\right)}} \]
    3. Applied rewrites56.9%

      \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(t \cdot y\right)}} \]
    4. Applied rewrites56.9%

      \[\leadsto x \cdot e^{\left(-y\right) \cdot \color{blue}{t}} \]

    if 2.3499999999999998e-18 < a

    1. Initial program 96.5%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Applied rewrites96.9%

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

      \[\leadsto \frac{x}{e^{\color{blue}{a \cdot \left(b - \log \left(1 - z\right)\right)}}} \]
    4. Applied rewrites59.4%

      \[\leadsto \frac{x}{e^{\color{blue}{a \cdot \left(b - \log \left(1 - z\right)\right)}}} \]
    5. Taylor expanded in z around 0

      \[\leadsto \frac{x}{e^{a \cdot \color{blue}{b}}} \]
    6. Applied rewrites58.6%

      \[\leadsto \frac{x}{e^{a \cdot \color{blue}{b}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 69.5% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -7.2 \cdot 10^{+83}:\\ \;\;\;\;x \cdot e^{-a \cdot b}\\ \mathbf{elif}\;a \leq 2.35 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{e^{t \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{e^{a \cdot b}}\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= a -7.2e+83)
   (* x (exp (- (* a b))))
   (if (<= a 2.35e-18) (/ x (exp (* t y))) (/ x (exp (* a b))))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (a <= -7.2e+83) {
		tmp = x * exp(-(a * b));
	} else if (a <= 2.35e-18) {
		tmp = x / exp((t * y));
	} else {
		tmp = x / exp((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) :: tmp
    if (a <= (-7.2d+83)) then
        tmp = x * exp(-(a * b))
    else if (a <= 2.35d-18) then
        tmp = x / exp((t * y))
    else
        tmp = x / exp((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 tmp;
	if (a <= -7.2e+83) {
		tmp = x * Math.exp(-(a * b));
	} else if (a <= 2.35e-18) {
		tmp = x / Math.exp((t * y));
	} else {
		tmp = x / Math.exp((a * b));
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if a <= -7.2e+83:
		tmp = x * math.exp(-(a * b))
	elif a <= 2.35e-18:
		tmp = x / math.exp((t * y))
	else:
		tmp = x / math.exp((a * b))
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (a <= -7.2e+83)
		tmp = Float64(x * exp(Float64(-Float64(a * b))));
	elseif (a <= 2.35e-18)
		tmp = Float64(x / exp(Float64(t * y)));
	else
		tmp = Float64(x / exp(Float64(a * b)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (a <= -7.2e+83)
		tmp = x * exp(-(a * b));
	elseif (a <= 2.35e-18)
		tmp = x / exp((t * y));
	else
		tmp = x / exp((a * b));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, -7.2e+83], N[(x * N[Exp[(-N[(a * b), $MachinePrecision])], $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 2.35e-18], N[(x / N[Exp[N[(t * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x / N[Exp[N[(a * b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.2 \cdot 10^{+83}:\\
\;\;\;\;x \cdot e^{-a \cdot b}\\

\mathbf{elif}\;a \leq 2.35 \cdot 10^{-18}:\\
\;\;\;\;\frac{x}{e^{t \cdot y}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{e^{a \cdot b}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -7.1999999999999995e83

    1. Initial program 96.5%

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

      \[\leadsto x \cdot e^{\color{blue}{-1 \cdot \left(a \cdot b\right) + y \cdot \left(\log z - t\right)}} \]
    3. Applied rewrites96.0%

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

      \[\leadsto x \cdot e^{-1 \cdot \color{blue}{\left(a \cdot b\right)}} \]
    5. Applied rewrites58.6%

      \[\leadsto x \cdot e^{-1 \cdot \color{blue}{\left(a \cdot b\right)}} \]
    6. Applied rewrites58.6%

      \[\leadsto x \cdot \color{blue}{e^{-a \cdot b}} \]

    if -7.1999999999999995e83 < a < 2.3499999999999998e-18

    1. Initial program 96.5%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Applied rewrites96.9%

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

      \[\leadsto \frac{x}{e^{\color{blue}{t \cdot y}}} \]
    4. Applied rewrites56.9%

      \[\leadsto \frac{x}{e^{\color{blue}{t \cdot y}}} \]

    if 2.3499999999999998e-18 < a

    1. Initial program 96.5%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Applied rewrites96.9%

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

      \[\leadsto \frac{x}{e^{\color{blue}{a \cdot \left(b - \log \left(1 - z\right)\right)}}} \]
    4. Applied rewrites59.4%

      \[\leadsto \frac{x}{e^{\color{blue}{a \cdot \left(b - \log \left(1 - z\right)\right)}}} \]
    5. Taylor expanded in z around 0

      \[\leadsto \frac{x}{e^{a \cdot \color{blue}{b}}} \]
    6. Applied rewrites58.6%

      \[\leadsto \frac{x}{e^{a \cdot \color{blue}{b}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 69.5% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{x}{e^{a \cdot b}}\\ \mathbf{if}\;a \leq -7.2 \cdot 10^{+83}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;a \leq 2.35 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{e^{t \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (/ x (exp (* a b)))))
   (if (<= a -7.2e+83) t_1 (if (<= a 2.35e-18) (/ x (exp (* t y))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x / exp((a * b));
	double tmp;
	if (a <= -7.2e+83) {
		tmp = t_1;
	} else if (a <= 2.35e-18) {
		tmp = x / exp((t * y));
	} 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 / exp((a * b))
    if (a <= (-7.2d+83)) then
        tmp = t_1
    else if (a <= 2.35d-18) then
        tmp = x / exp((t * y))
    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 / Math.exp((a * b));
	double tmp;
	if (a <= -7.2e+83) {
		tmp = t_1;
	} else if (a <= 2.35e-18) {
		tmp = x / Math.exp((t * y));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = x / math.exp((a * b))
	tmp = 0
	if a <= -7.2e+83:
		tmp = t_1
	elif a <= 2.35e-18:
		tmp = x / math.exp((t * y))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(x / exp(Float64(a * b)))
	tmp = 0.0
	if (a <= -7.2e+83)
		tmp = t_1;
	elseif (a <= 2.35e-18)
		tmp = Float64(x / exp(Float64(t * y)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = x / exp((a * b));
	tmp = 0.0;
	if (a <= -7.2e+83)
		tmp = t_1;
	elseif (a <= 2.35e-18)
		tmp = x / exp((t * y));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x / N[Exp[N[(a * b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -7.2e+83], t$95$1, If[LessEqual[a, 2.35e-18], N[(x / N[Exp[N[(t * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{x}{e^{a \cdot b}}\\
\mathbf{if}\;a \leq -7.2 \cdot 10^{+83}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;a \leq 2.35 \cdot 10^{-18}:\\
\;\;\;\;\frac{x}{e^{t \cdot y}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -7.1999999999999995e83 or 2.3499999999999998e-18 < a

    1. Initial program 96.5%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Applied rewrites96.9%

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

      \[\leadsto \frac{x}{e^{\color{blue}{a \cdot \left(b - \log \left(1 - z\right)\right)}}} \]
    4. Applied rewrites59.4%

      \[\leadsto \frac{x}{e^{\color{blue}{a \cdot \left(b - \log \left(1 - z\right)\right)}}} \]
    5. Taylor expanded in z around 0

      \[\leadsto \frac{x}{e^{a \cdot \color{blue}{b}}} \]
    6. Applied rewrites58.6%

      \[\leadsto \frac{x}{e^{a \cdot \color{blue}{b}}} \]

    if -7.1999999999999995e83 < a < 2.3499999999999998e-18

    1. Initial program 96.5%

      \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
    2. Applied rewrites96.9%

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

      \[\leadsto \frac{x}{e^{\color{blue}{t \cdot y}}} \]
    4. Applied rewrites56.9%

      \[\leadsto \frac{x}{e^{\color{blue}{t \cdot y}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 58.6% accurate, 2.4× speedup?

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

\\
\frac{x}{e^{a \cdot b}}
\end{array}
Derivation
  1. Initial program 96.5%

    \[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
  2. Applied rewrites96.9%

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

    \[\leadsto \frac{x}{e^{\color{blue}{a \cdot \left(b - \log \left(1 - z\right)\right)}}} \]
  4. Applied rewrites59.4%

    \[\leadsto \frac{x}{e^{\color{blue}{a \cdot \left(b - \log \left(1 - z\right)\right)}}} \]
  5. Taylor expanded in z around 0

    \[\leadsto \frac{x}{e^{a \cdot \color{blue}{b}}} \]
  6. Applied rewrites58.6%

    \[\leadsto \frac{x}{e^{a \cdot \color{blue}{b}}} \]
  7. Add Preprocessing

Alternative 11: 19.1% accurate, 10.6× speedup?

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

\\
x \cdot 1
\end{array}
Derivation
  1. Initial program 96.5%

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

    \[\leadsto x \cdot \color{blue}{e^{y \cdot \left(\log z - t\right)}} \]
  3. Applied rewrites71.7%

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

    \[\leadsto x \cdot 1 \]
  5. Applied rewrites19.1%

    \[\leadsto x \cdot 1 \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2025153 
(FPCore (x y z t a b)
  :name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, B"
  :precision binary64
  (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))