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

Percentage Accurate: 99.9% → 99.9%
Time: 16.0s
Alternatives: 10
Speedup: 1.0×

Specification

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

\\
\left(\left(x \cdot \log y - y\right) - z\right) + \log t
\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 10 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Applied rewrites99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \log t - z\right) - y} \]
  3. Add Preprocessing

Alternative 2: 89.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+53}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, -z\right) + \log t\\

\mathbf{else}:\\
\;\;\;\;\left(\log t - z\right) - y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 2.1000000000000002e53

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\left(x \cdot \log y - z\right)} + \log t \]
    3. Applied rewrites70.9%

      \[\leadsto \color{blue}{\left(x \cdot \log y - z\right)} + \log t \]
    4. Applied rewrites70.9%

      \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{x}, -z\right) + \log t \]

    if 2.1000000000000002e53 < y

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{\left(\log t - z\right)} - y \]
    4. Applied rewrites71.6%

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

Alternative 3: 89.3% accurate, 1.0× speedup?

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

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

real(8) function code(x, y, z, t)
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) :: tmp
    if (y <= 2.1d+53) then
        tmp = ((x * log(y)) - z) + log(t)
    else
        tmp = (log(t) - z) - y
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 2.1e+53) {
		tmp = ((x * Math.log(y)) - z) + Math.log(t);
	} else {
		tmp = (Math.log(t) - z) - y;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= 2.1e+53:
		tmp = ((x * math.log(y)) - z) + math.log(t)
	else:
		tmp = (math.log(t) - z) - y
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 2.1e+53)
		tmp = Float64(Float64(Float64(x * log(y)) - z) + log(t));
	else
		tmp = Float64(Float64(log(t) - z) - y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 2.1e+53)
		tmp = ((x * log(y)) - z) + log(t);
	else
		tmp = (log(t) - z) - y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.1e+53], N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] + N[Log[t], $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+53}:\\
\;\;\;\;\left(x \cdot \log y - z\right) + \log t\\

\mathbf{else}:\\
\;\;\;\;\left(\log t - z\right) - y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 2.1000000000000002e53

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\left(x \cdot \log y - z\right)} + \log t \]
    3. Applied rewrites70.9%

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

    if 2.1000000000000002e53 < y

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{\left(\log t - z\right)} - y \]
    4. Applied rewrites71.6%

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

Alternative 4: 89.3% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 2.2 \cdot 10^{+54}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.5000000000000001e92 or 2.1999999999999999e54 < z

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{\left(\log t - z\right)} - y \]
    4. Applied rewrites71.6%

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

    if -8.5000000000000001e92 < z < 2.1999999999999999e54

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
    3. Applied rewrites69.7%

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
    4. Applied rewrites69.7%

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

Alternative 5: 84.4% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -4.9 \cdot 10^{+165}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.55 \cdot 10^{+114}:\\
\;\;\;\;\left(\log t - z\right) - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.89999999999999986e165 or 1.55e114 < x

    1. Initial program 99.9%

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

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

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

      \[\leadsto \color{blue}{x \cdot \log y} \]
    5. Applied rewrites29.5%

      \[\leadsto \color{blue}{x \cdot \log y} \]

    if -4.89999999999999986e165 < x < 1.55e114

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{\left(\log t - z\right)} - y \]
    4. Applied rewrites71.6%

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

Alternative 6: 64.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ t_2 := t\_1 - y\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+277}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq -5 \cdot 10^{+79}:\\ \;\;\;\;-y\\ \mathbf{elif}\;t\_2 \leq 10^{+142}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))) (t_2 (- t_1 y)))
   (if (<= t_2 -5e+277)
     t_1
     (if (<= t_2 -5e+79) (- y) (if (<= t_2 1e+142) (- (log t) z) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double t_2 = t_1 - y;
	double tmp;
	if (t_2 <= -5e+277) {
		tmp = t_1;
	} else if (t_2 <= -5e+79) {
		tmp = -y;
	} else if (t_2 <= 1e+142) {
		tmp = log(t) - z;
	} 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)
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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x * log(y)
    t_2 = t_1 - y
    if (t_2 <= (-5d+277)) then
        tmp = t_1
    else if (t_2 <= (-5d+79)) then
        tmp = -y
    else if (t_2 <= 1d+142) then
        tmp = log(t) - z
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * Math.log(y);
	double t_2 = t_1 - y;
	double tmp;
	if (t_2 <= -5e+277) {
		tmp = t_1;
	} else if (t_2 <= -5e+79) {
		tmp = -y;
	} else if (t_2 <= 1e+142) {
		tmp = Math.log(t) - z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	t_2 = t_1 - y
	tmp = 0
	if t_2 <= -5e+277:
		tmp = t_1
	elif t_2 <= -5e+79:
		tmp = -y
	elif t_2 <= 1e+142:
		tmp = math.log(t) - z
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	t_2 = Float64(t_1 - y)
	tmp = 0.0
	if (t_2 <= -5e+277)
		tmp = t_1;
	elseif (t_2 <= -5e+79)
		tmp = Float64(-y);
	elseif (t_2 <= 1e+142)
		tmp = Float64(log(t) - z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	t_2 = t_1 - y;
	tmp = 0.0;
	if (t_2 <= -5e+277)
		tmp = t_1;
	elseif (t_2 <= -5e+79)
		tmp = -y;
	elseif (t_2 <= 1e+142)
		tmp = log(t) - z;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - y), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+277], t$95$1, If[LessEqual[t$95$2, -5e+79], (-y), If[LessEqual[t$95$2, 1e+142], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := t\_1 - y\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+277}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{+79}:\\
\;\;\;\;-y\\

\mathbf{elif}\;t\_2 \leq 10^{+142}:\\
\;\;\;\;\log t - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (*.f64 x (log.f64 y)) y) < -4.99999999999999982e277 or 1.00000000000000005e142 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.9%

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

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

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

      \[\leadsto \color{blue}{x \cdot \log y} \]
    5. Applied rewrites29.5%

      \[\leadsto \color{blue}{x \cdot \log y} \]

    if -4.99999999999999982e277 < (-.f64 (*.f64 x (log.f64 y)) y) < -5e79

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{-1 \cdot y} \]
    4. Applied rewrites29.9%

      \[\leadsto \color{blue}{-1 \cdot y} \]
    5. Applied rewrites29.9%

      \[\leadsto -y \]

    if -5e79 < (-.f64 (*.f64 x (log.f64 y)) y) < 1.00000000000000005e142

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\log t - \left(y + z\right)} \]
    3. Applied rewrites71.6%

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

      \[\leadsto \log t - z \]
    5. Applied rewrites43.1%

      \[\leadsto \log t - z \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 61.1% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4.1 \cdot 10^{+64}:\\ \;\;\;\;\log t - z\\ \mathbf{else}:\\ \;\;\;\;\log t - y\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= y 4.1e+64) (- (log t) z) (- (log t) y)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 4.1e+64) {
		tmp = log(t) - z;
	} else {
		tmp = log(t) - y;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t)
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) :: tmp
    if (y <= 4.1d+64) then
        tmp = log(t) - z
    else
        tmp = log(t) - y
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 4.1e+64) {
		tmp = Math.log(t) - z;
	} else {
		tmp = Math.log(t) - y;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= 4.1e+64:
		tmp = math.log(t) - z
	else:
		tmp = math.log(t) - y
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 4.1e+64)
		tmp = Float64(log(t) - z);
	else
		tmp = Float64(log(t) - y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 4.1e+64)
		tmp = log(t) - z;
	else
		tmp = log(t) - y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.1e+64], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{+64}:\\
\;\;\;\;\log t - z\\

\mathbf{else}:\\
\;\;\;\;\log t - y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.09999999999999978e64

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\log t - \left(y + z\right)} \]
    3. Applied rewrites71.6%

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

      \[\leadsto \log t - z \]
    5. Applied rewrites43.1%

      \[\leadsto \log t - z \]

    if 4.09999999999999978e64 < y

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
    3. Applied rewrites69.7%

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

      \[\leadsto \log t - y \]
    5. Applied rewrites42.0%

      \[\leadsto \log t - y \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 60.5% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{+91}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+99}:\\ \;\;\;\;\log t - y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -8.5e+91) (- z) (if (<= z 1.15e+99) (- (log t) y) (- z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -8.5e+91) {
		tmp = -z;
	} else if (z <= 1.15e+99) {
		tmp = log(t) - y;
	} else {
		tmp = -z;
	}
	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)
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) :: tmp
    if (z <= (-8.5d+91)) then
        tmp = -z
    else if (z <= 1.15d+99) then
        tmp = log(t) - y
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -8.5e+91) {
		tmp = -z;
	} else if (z <= 1.15e+99) {
		tmp = Math.log(t) - y;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -8.5e+91:
		tmp = -z
	elif z <= 1.15e+99:
		tmp = math.log(t) - y
	else:
		tmp = -z
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -8.5e+91)
		tmp = Float64(-z);
	elseif (z <= 1.15e+99)
		tmp = Float64(log(t) - y);
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -8.5e+91)
		tmp = -z;
	elseif (z <= 1.15e+99)
		tmp = log(t) - y;
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.5e+91], (-z), If[LessEqual[z, 1.15e+99], N[(N[Log[t], $MachinePrecision] - y), $MachinePrecision], (-z)]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{+91}:\\
\;\;\;\;-z\\

\mathbf{elif}\;z \leq 1.15 \cdot 10^{+99}:\\
\;\;\;\;\log t - y\\

\mathbf{else}:\\
\;\;\;\;-z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.4999999999999995e91 or 1.1500000000000001e99 < z

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Applied rewrites31.1%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Applied rewrites31.1%

      \[\leadsto \color{blue}{-z} \]

    if -8.4999999999999995e91 < z < 1.1500000000000001e99

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\left(\log t + x \cdot \log y\right) - y} \]
    3. Applied rewrites69.7%

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

      \[\leadsto \log t - y \]
    5. Applied rewrites42.0%

      \[\leadsto \log t - y \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 49.2% accurate, 4.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4.1 \cdot 10^{+64}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \end{array} \]
(FPCore (x y z t) :precision binary64 (if (<= y 4.1e+64) (- z) (- y)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 4.1e+64) {
		tmp = -z;
	} else {
		tmp = -y;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t)
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) :: tmp
    if (y <= 4.1d+64) then
        tmp = -z
    else
        tmp = -y
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= 4.1e+64) {
		tmp = -z;
	} else {
		tmp = -y;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if y <= 4.1e+64:
		tmp = -z
	else:
		tmp = -y
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (y <= 4.1e+64)
		tmp = Float64(-z);
	else
		tmp = Float64(-y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (y <= 4.1e+64)
		tmp = -z;
	else
		tmp = -y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.1e+64], (-z), (-y)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{+64}:\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;-y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.09999999999999978e64

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Applied rewrites31.1%

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Applied rewrites31.1%

      \[\leadsto \color{blue}{-z} \]

    if 4.09999999999999978e64 < y

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Applied rewrites99.9%

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

      \[\leadsto \color{blue}{-1 \cdot y} \]
    4. Applied rewrites29.9%

      \[\leadsto \color{blue}{-1 \cdot y} \]
    5. Applied rewrites29.9%

      \[\leadsto -y \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 31.1% accurate, 11.9× speedup?

\[\begin{array}{l} \\ -z \end{array} \]
(FPCore (x y z t) :precision binary64 (- z))
double code(double x, double y, double z, double t) {
	return -z;
}
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)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = -z
end function
public static double code(double x, double y, double z, double t) {
	return -z;
}
def code(x, y, z, t):
	return -z
function code(x, y, z, t)
	return Float64(-z)
end
function tmp = code(x, y, z, t)
	tmp = -z;
end
code[x_, y_, z_, t_] := (-z)
\begin{array}{l}

\\
-z
\end{array}
Derivation
  1. Initial program 99.9%

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

    \[\leadsto \color{blue}{-1 \cdot z} \]
  3. Applied rewrites31.1%

    \[\leadsto \color{blue}{-1 \cdot z} \]
  4. Applied rewrites31.1%

    \[\leadsto \color{blue}{-z} \]
  5. Add Preprocessing

Reproduce

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