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

Percentage Accurate: 96.8% → 99.2%
Time: 6.8s
Alternatives: 7
Speedup: 1.3×

Specification

?
\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
(FPCore (x y z t a b)
  :precision binary64
  (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1 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 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}

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 7 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.8% accurate, 1.0× speedup?

\[x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \]
(FPCore (x y z t a b)
  :precision binary64
  (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1 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 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}

Alternative 1: 99.2% accurate, 1.3× speedup?

\[x \cdot e^{\left(a \cdot \left(\mathsf{30\_log1z0}\left(z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
(FPCore (x y z t a b)
  :precision binary64
  (* x (exp (- (+ (* a (- (30-log1z0 z) b)) (* y (log z))) (* t y)))))
x \cdot e^{\left(a \cdot \left(\mathsf{30\_log1z0}\left(z\right) - b\right) + y \cdot \log z\right) - t \cdot y}
Derivation
  1. Initial program 96.8%

    \[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 inf

    \[\leadsto x \cdot \color{blue}{e^{\left(a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \log z\right) - t \cdot y}} \]
  3. Step-by-step derivation
    1. lower-exp.f64N/A

      \[\leadsto x \cdot e^{\left(a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
    2. lower--.f64N/A

      \[\leadsto x \cdot e^{\left(a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
    3. lower-+.f64N/A

      \[\leadsto x \cdot e^{\left(a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
    4. lower-*.f64N/A

      \[\leadsto x \cdot e^{\left(a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
    5. lower--.f64N/A

      \[\leadsto x \cdot e^{\left(a \cdot \left(\log \left(1 - z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
    6. lower-30-log1z0N/A

      \[\leadsto x \cdot e^{\left(a \cdot \left(\mathsf{30\_log1z0}\left(z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
    7. lower-*.f64N/A

      \[\leadsto x \cdot e^{\left(a \cdot \left(\mathsf{30\_log1z0}\left(z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
    8. lower-log.f64N/A

      \[\leadsto x \cdot e^{\left(a \cdot \left(\mathsf{30\_log1z0}\left(z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
    9. lower-*.f6499.2%

      \[\leadsto x \cdot e^{\left(a \cdot \left(\mathsf{30\_log1z0}\left(z\right) - b\right) + y \cdot \log z\right) - t \cdot y} \]
  4. Applied rewrites99.2%

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

Alternative 2: 85.8% accurate, 1.5× speedup?

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

\mathbf{elif}\;y \leq 9200:\\
\;\;\;\;e^{\left(\left(-z\right) - b\right) \cdot a} \cdot x\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.4999999999999995e37 or 9200 < y

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-exp.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      2. lower-*.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      3. lower--.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      4. lower-log.f6472.5%

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    4. Applied rewrites72.5%

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

    if -9.4999999999999995e37 < y < 9200

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto x \cdot e^{a \cdot \color{blue}{\left(\log \left(1 - z\right) - b\right)}} \]
      2. lower--.f64N/A

        \[\leadsto x \cdot e^{a \cdot \left(\log \left(1 - z\right) - \color{blue}{b}\right)} \]
      3. lower-30-log1z062.5%

        \[\leadsto x \cdot e^{a \cdot \left(\mathsf{30\_log1z0}\left(z\right) - b\right)} \]
    4. Applied rewrites62.5%

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

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - b\right)} \]
    6. Step-by-step derivation
      1. lower-*.f6462.5%

        \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - b\right)} \]
    7. Applied rewrites62.5%

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - b\right)} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(-1 \cdot z - b\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{e^{a \cdot \left(-1 \cdot z - b\right)} \cdot x} \]
      3. lower-*.f6462.5%

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

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

Alternative 3: 73.8% accurate, 2.5× speedup?

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

\mathbf{elif}\;y \leq 12000:\\
\;\;\;\;e^{\left(\left(-z\right) - b\right) \cdot a} \cdot x\\

\mathbf{elif}\;y \leq 10199999999999999168735447530637548288280156818942794594306261329182187057441323244557076267008:\\
\;\;\;\;x \cdot {z}^{y}\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.4999999999999995e37 or 1.0199999999999999e94 < y

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-exp.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      2. lower-*.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      3. lower--.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      4. lower-log.f6472.5%

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    4. Applied rewrites72.5%

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

      \[\leadsto x \cdot e^{y \cdot \left(-1 \cdot t\right)} \]
    6. Step-by-step derivation
      1. lower-*.f6457.7%

        \[\leadsto x \cdot e^{y \cdot \left(-1 \cdot t\right)} \]
    7. Applied rewrites57.7%

      \[\leadsto x \cdot e^{y \cdot \left(-1 \cdot t\right)} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot e^{y \cdot \left(-1 \cdot t\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{e^{y \cdot \left(-1 \cdot t\right)} \cdot x} \]
      3. lower-*.f6457.7%

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

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

    if -9.4999999999999995e37 < y < 12000

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto x \cdot e^{a \cdot \color{blue}{\left(\log \left(1 - z\right) - b\right)}} \]
      2. lower--.f64N/A

        \[\leadsto x \cdot e^{a \cdot \left(\log \left(1 - z\right) - \color{blue}{b}\right)} \]
      3. lower-30-log1z062.5%

        \[\leadsto x \cdot e^{a \cdot \left(\mathsf{30\_log1z0}\left(z\right) - b\right)} \]
    4. Applied rewrites62.5%

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

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - b\right)} \]
    6. Step-by-step derivation
      1. lower-*.f6462.5%

        \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - b\right)} \]
    7. Applied rewrites62.5%

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot z - b\right)} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(-1 \cdot z - b\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{e^{a \cdot \left(-1 \cdot z - b\right)} \cdot x} \]
      3. lower-*.f6462.5%

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

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

    if 12000 < y < 1.0199999999999999e94

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-exp.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      2. lower-*.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      3. lower--.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      4. lower-log.f6472.5%

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    4. Applied rewrites72.5%

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

      \[\leadsto x \cdot {z}^{\color{blue}{y}} \]
    6. Step-by-step derivation
      1. lower-pow.f6451.7%

        \[\leadsto x \cdot {z}^{y} \]
    7. Applied rewrites51.7%

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

Alternative 4: 70.9% accurate, 2.5× speedup?

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

\mathbf{elif}\;y \leq 1800:\\
\;\;\;\;e^{\left(-b\right) \cdot a} \cdot x\\

\mathbf{elif}\;y \leq 10199999999999999168735447530637548288280156818942794594306261329182187057441323244557076267008:\\
\;\;\;\;x \cdot {z}^{y}\\

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


\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.4999999999999995e37 or 1.0199999999999999e94 < y

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-exp.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      2. lower-*.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      3. lower--.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      4. lower-log.f6472.5%

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    4. Applied rewrites72.5%

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

      \[\leadsto x \cdot e^{y \cdot \left(-1 \cdot t\right)} \]
    6. Step-by-step derivation
      1. lower-*.f6457.7%

        \[\leadsto x \cdot e^{y \cdot \left(-1 \cdot t\right)} \]
    7. Applied rewrites57.7%

      \[\leadsto x \cdot e^{y \cdot \left(-1 \cdot t\right)} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot e^{y \cdot \left(-1 \cdot t\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{e^{y \cdot \left(-1 \cdot t\right)} \cdot x} \]
      3. lower-*.f6457.7%

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

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

    if -9.4999999999999995e37 < y < 1800

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto x \cdot e^{a \cdot \color{blue}{\left(\log \left(1 - z\right) - b\right)}} \]
      2. lower--.f64N/A

        \[\leadsto x \cdot e^{a \cdot \left(\log \left(1 - z\right) - \color{blue}{b}\right)} \]
      3. lower-30-log1z062.5%

        \[\leadsto x \cdot e^{a \cdot \left(\mathsf{30\_log1z0}\left(z\right) - b\right)} \]
    4. Applied rewrites62.5%

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

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot \color{blue}{b}\right)} \]
    6. Step-by-step derivation
      1. lower-*.f6458.1%

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

      \[\leadsto x \cdot e^{a \cdot \left(-1 \cdot \color{blue}{b}\right)} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot e^{a \cdot \left(-1 \cdot b\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{e^{a \cdot \left(-1 \cdot b\right)} \cdot x} \]
      3. lower-*.f6458.1%

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

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

    if 1800 < y < 1.0199999999999999e94

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-exp.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      2. lower-*.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      3. lower--.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      4. lower-log.f6472.5%

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    4. Applied rewrites72.5%

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

      \[\leadsto x \cdot {z}^{\color{blue}{y}} \]
    6. Step-by-step derivation
      1. lower-pow.f6451.7%

        \[\leadsto x \cdot {z}^{y} \]
    7. Applied rewrites51.7%

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

Alternative 5: 70.9% accurate, 2.6× speedup?

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

\mathbf{elif}\;t \leq 24999999999999998821833863412802751999361545695464520794771346937446488059801446767248924750854127694096827515373733105246240827891950550502659321931910610944:\\
\;\;\;\;x \cdot {z}^{y}\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -7.1999999999999996e-8 or 2.4999999999999999e157 < t

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-exp.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      2. lower-*.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      3. lower--.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      4. lower-log.f6472.5%

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    4. Applied rewrites72.5%

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

      \[\leadsto x \cdot e^{y \cdot \left(-1 \cdot t\right)} \]
    6. Step-by-step derivation
      1. lower-*.f6457.7%

        \[\leadsto x \cdot e^{y \cdot \left(-1 \cdot t\right)} \]
    7. Applied rewrites57.7%

      \[\leadsto x \cdot e^{y \cdot \left(-1 \cdot t\right)} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{x \cdot e^{y \cdot \left(-1 \cdot t\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{e^{y \cdot \left(-1 \cdot t\right)} \cdot x} \]
      3. lower-*.f6457.7%

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

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

    if -7.1999999999999996e-8 < t < 2.4999999999999999e157

    1. Initial program 96.8%

      \[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. Step-by-step derivation
      1. lower-exp.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      2. lower-*.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      3. lower--.f64N/A

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
      4. lower-log.f6472.5%

        \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    4. Applied rewrites72.5%

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

      \[\leadsto x \cdot {z}^{\color{blue}{y}} \]
    6. Step-by-step derivation
      1. lower-pow.f6451.7%

        \[\leadsto x \cdot {z}^{y} \]
    7. Applied rewrites51.7%

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

Alternative 6: 51.7% accurate, 3.1× speedup?

\[x \cdot {z}^{y} \]
(FPCore (x y z t a b)
  :precision binary64
  (* x (pow z y)))
double code(double x, double y, double z, double t, double a, double b) {
	return x * pow(z, 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 = x * (z ** y)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return x * Math.pow(z, y);
}
def code(x, y, z, t, a, b):
	return x * math.pow(z, y)
function code(x, y, z, t, a, b)
	return Float64(x * (z ^ y))
end
function tmp = code(x, y, z, t, a, b)
	tmp = x * (z ^ y);
end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Power[z, y], $MachinePrecision]), $MachinePrecision]
x \cdot {z}^{y}
Derivation
  1. Initial program 96.8%

    \[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. Step-by-step derivation
    1. lower-exp.f64N/A

      \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    2. lower-*.f64N/A

      \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    3. lower--.f64N/A

      \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    4. lower-log.f6472.5%

      \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
  4. Applied rewrites72.5%

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

    \[\leadsto x \cdot {z}^{\color{blue}{y}} \]
  6. Step-by-step derivation
    1. lower-pow.f6451.7%

      \[\leadsto x \cdot {z}^{y} \]
  7. Applied rewrites51.7%

    \[\leadsto x \cdot {z}^{\color{blue}{y}} \]
  8. Add Preprocessing

Alternative 7: 19.0% accurate, 54.7× speedup?

\[x \cdot 1 \]
(FPCore (x y z t a b)
  :precision binary64
  (* x 1))
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), $MachinePrecision]
x \cdot 1
Derivation
  1. Initial program 96.8%

    \[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. Step-by-step derivation
    1. lower-exp.f64N/A

      \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    2. lower-*.f64N/A

      \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    3. lower--.f64N/A

      \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
    4. lower-log.f6472.5%

      \[\leadsto x \cdot e^{y \cdot \left(\log z - t\right)} \]
  4. Applied rewrites72.5%

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

    \[\leadsto x \cdot 1 \]
  6. Step-by-step derivation
    1. Applied rewrites19.0%

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

    Reproduce

    ?
    herbie shell --seed 2025271 -o generate:evaluate
    (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 z)) b))))))