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

Percentage Accurate: 99.9% → 99.9%
Time: 4.2s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 99.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} \\ \left(\mathsf{fma}\left(\log y, x, \log t\right) - y\right) - z \end{array} \]
(FPCore (x y z t) :precision binary64 (- (- (fma (log y) x (log t)) y) z))
double code(double x, double y, double z, double t) {
	return (fma(log(y), x, log(t)) - y) - z;
}
function code(x, y, z, t)
	return Float64(Float64(fma(log(y), x, log(t)) - y) - z)
end
code[x_, y_, z_, t_] := N[(N[(N[(N[Log[y], $MachinePrecision] * x + N[Log[t], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}

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

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right) + \log t} \]
    2. lift--.f64N/A

      \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right)} + \log t \]
    3. lift--.f64N/A

      \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
    4. lift-*.f64N/A

      \[\leadsto \left(\left(\color{blue}{x \cdot \log y} - y\right) - z\right) + \log t \]
    5. lift-log.f64N/A

      \[\leadsto \left(\left(x \cdot \color{blue}{\log y} - y\right) - z\right) + \log t \]
    6. lift-log.f64N/A

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

      \[\leadsto \color{blue}{\log t + \left(\left(x \cdot \log y - y\right) - z\right)} \]
    8. negate-subN/A

      \[\leadsto \log t + \left(\color{blue}{\left(x \cdot \log y + \left(\mathsf{neg}\left(y\right)\right)\right)} - z\right) \]
    9. +-commutativeN/A

      \[\leadsto \log t + \left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x \cdot \log y\right)} - z\right) \]
    10. mul-1-negN/A

      \[\leadsto \log t + \left(\left(\color{blue}{-1 \cdot y} + x \cdot \log y\right) - z\right) \]
    11. associate--l+N/A

      \[\leadsto \color{blue}{\left(\log t + \left(-1 \cdot y + x \cdot \log y\right)\right) - z} \]
    12. lower--.f64N/A

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

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

Alternative 2: 99.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_1 := \left(\log y \cdot x - y\right) - z\\
\mathbf{if}\;x \leq -0.82:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 0.00017:\\
\;\;\;\;\left(\log t - y\right) - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.819999999999999951 or 1.7e-4 < x

    1. Initial program 99.7%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right) + \log t} \]
      2. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right)} + \log t \]
      3. lift--.f64N/A

        \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(\color{blue}{x \cdot \log y} - y\right) - z\right) + \log t \]
      5. lift-log.f64N/A

        \[\leadsto \left(\left(x \cdot \color{blue}{\log y} - y\right) - z\right) + \log t \]
      6. lift-log.f64N/A

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

        \[\leadsto \color{blue}{\log t + \left(\left(x \cdot \log y - y\right) - z\right)} \]
      8. negate-subN/A

        \[\leadsto \log t + \left(\color{blue}{\left(x \cdot \log y + \left(\mathsf{neg}\left(y\right)\right)\right)} - z\right) \]
      9. +-commutativeN/A

        \[\leadsto \log t + \left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x \cdot \log y\right)} - z\right) \]
      10. mul-1-negN/A

        \[\leadsto \log t + \left(\left(\color{blue}{-1 \cdot y} + x \cdot \log y\right) - z\right) \]
      11. associate--l+N/A

        \[\leadsto \color{blue}{\left(\log t + \left(-1 \cdot y + x \cdot \log y\right)\right) - z} \]
      12. lower--.f64N/A

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

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

      \[\leadsto \left(\color{blue}{x \cdot \log y} - y\right) - z \]
    5. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \left(\log y \cdot \color{blue}{x} - y\right) - z \]
      3. lift-log.f6499.0

        \[\leadsto \left(\log y \cdot x - y\right) - z \]
    6. Applied rewrites99.0%

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

    if -0.819999999999999951 < x < 1.7e-4

    1. Initial program 100.0%

      \[\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. Step-by-step derivation
      1. associate--r+N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      2. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      3. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - z \]
      4. lift-log.f6499.6

        \[\leadsto \left(\log t - y\right) - z \]
    4. Applied rewrites99.6%

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

Alternative 3: 99.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 115:\\
\;\;\;\;\mathsf{fma}\left(\log y, x, \log t\right) - z\\

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


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

    1. Initial program 99.8%

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

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

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

        \[\leadsto \left(x \cdot \log y + \log t\right) - z \]
      3. *-commutativeN/A

        \[\leadsto \left(\log y \cdot x + \log t\right) - z \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      5. lift-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      6. lift-log.f6499.1

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
    4. Applied rewrites99.1%

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

    if 115 < y

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right) + \log t} \]
      2. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right)} + \log t \]
      3. lift--.f64N/A

        \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(\color{blue}{x \cdot \log y} - y\right) - z\right) + \log t \]
      5. lift-log.f64N/A

        \[\leadsto \left(\left(x \cdot \color{blue}{\log y} - y\right) - z\right) + \log t \]
      6. lift-log.f64N/A

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

        \[\leadsto \color{blue}{\log t + \left(\left(x \cdot \log y - y\right) - z\right)} \]
      8. negate-subN/A

        \[\leadsto \log t + \left(\color{blue}{\left(x \cdot \log y + \left(\mathsf{neg}\left(y\right)\right)\right)} - z\right) \]
      9. +-commutativeN/A

        \[\leadsto \log t + \left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x \cdot \log y\right)} - z\right) \]
      10. mul-1-negN/A

        \[\leadsto \log t + \left(\left(\color{blue}{-1 \cdot y} + x \cdot \log y\right) - z\right) \]
      11. associate--l+N/A

        \[\leadsto \color{blue}{\left(\log t + \left(-1 \cdot y + x \cdot \log y\right)\right) - z} \]
      12. lower--.f64N/A

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

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

      \[\leadsto \left(\color{blue}{x \cdot \log y} - y\right) - z \]
    5. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \left(\log y \cdot \color{blue}{x} - y\right) - z \]
      3. lift-log.f6499.3

        \[\leadsto \left(\log y \cdot x - y\right) - z \]
    6. Applied rewrites99.3%

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

Alternative 4: 89.7% accurate, 1.2× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.50000000000000059e88 or 7.4000000000000004e55 < x

    1. Initial program 99.7%

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

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

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

        \[\leadsto \left(x \cdot \log y + \log t\right) - z \]
      3. *-commutativeN/A

        \[\leadsto \left(\log y \cdot x + \log t\right) - z \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      5. lift-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      6. lift-log.f6483.0

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
    4. Applied rewrites83.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, \log t\right) - z} \]
    5. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - \color{blue}{z} \]
      2. lift-fma.f64N/A

        \[\leadsto \left(\log y \cdot x + \log t\right) - z \]
      3. lift-log.f64N/A

        \[\leadsto \left(\log y \cdot x + \log t\right) - z \]
      4. lift-log.f64N/A

        \[\leadsto \left(\log y \cdot x + \log t\right) - z \]
      5. associate--l+N/A

        \[\leadsto \log y \cdot x + \color{blue}{\left(\log t - z\right)} \]
      6. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{x}, \log t - z\right) \]
      7. lift-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t - z\right) \]
      8. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t - z\right) \]
      9. lift-log.f6483.0

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t - z\right) \]
    6. Applied rewrites83.0%

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

      \[\leadsto \mathsf{fma}\left(\log y, x, -1 \cdot z\right) \]
    8. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \mathsf{neg}\left(z\right)\right) \]
      2. lift-neg.f6483.0

        \[\leadsto \mathsf{fma}\left(\log y, x, -z\right) \]
    9. Applied rewrites83.0%

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

    if -9.50000000000000059e88 < x < 7.4000000000000004e55

    1. Initial program 100.0%

      \[\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. Step-by-step derivation
      1. associate--r+N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      2. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      3. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - z \]
      4. lift-log.f6493.7

        \[\leadsto \left(\log t - y\right) - z \]
    4. Applied rewrites93.7%

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

Alternative 5: 89.7% accurate, 1.2× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.50000000000000059e88 or 7.4000000000000004e55 < x

    1. Initial program 99.7%

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

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

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

        \[\leadsto \left(x \cdot \log y + \log t\right) - z \]
      3. *-commutativeN/A

        \[\leadsto \left(\log y \cdot x + \log t\right) - z \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      5. lift-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      6. lift-log.f6483.0

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
    4. Applied rewrites83.0%

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

      \[\leadsto x \cdot \log y - z \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \log y \cdot x - z \]
      2. lower-*.f64N/A

        \[\leadsto \log y \cdot x - z \]
      3. lift-log.f6483.0

        \[\leadsto \log y \cdot x - z \]
    7. Applied rewrites83.0%

      \[\leadsto \log y \cdot x - z \]

    if -9.50000000000000059e88 < x < 7.4000000000000004e55

    1. Initial program 100.0%

      \[\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. Step-by-step derivation
      1. associate--r+N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      2. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      3. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - z \]
      4. lift-log.f6493.7

        \[\leadsto \left(\log t - y\right) - z \]
    4. Applied rewrites93.7%

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

Alternative 6: 84.1% accurate, 1.2× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.8000000000000004e89 or 1.15000000000000002e80 < x

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{x \cdot \log y} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \log y \cdot \color{blue}{x} \]
      2. lower-*.f64N/A

        \[\leadsto \log y \cdot \color{blue}{x} \]
      3. lift-log.f6468.4

        \[\leadsto \log y \cdot x \]
    4. Applied rewrites68.4%

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

    if -6.8000000000000004e89 < x < 1.15000000000000002e80

    1. Initial program 100.0%

      \[\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. Step-by-step derivation
      1. associate--r+N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      2. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      3. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - z \]
      4. lift-log.f6492.7

        \[\leadsto \left(\log t - y\right) - z \]
    4. Applied rewrites92.7%

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

Alternative 7: 79.3% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y - y\\
\mathbf{if}\;t\_1 \leq -20000000000:\\
\;\;\;\;\left(-y\right) - z\\

\mathbf{elif}\;t\_1 \leq 10^{+116}:\\
\;\;\;\;\log t - z\\

\mathbf{else}:\\
\;\;\;\;\log y \cdot x\\


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

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right) + \log t} \]
      2. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right)} + \log t \]
      3. lift--.f64N/A

        \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(\color{blue}{x \cdot \log y} - y\right) - z\right) + \log t \]
      5. lift-log.f64N/A

        \[\leadsto \left(\left(x \cdot \color{blue}{\log y} - y\right) - z\right) + \log t \]
      6. lift-log.f64N/A

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

        \[\leadsto \color{blue}{\log t + \left(\left(x \cdot \log y - y\right) - z\right)} \]
      8. negate-subN/A

        \[\leadsto \log t + \left(\color{blue}{\left(x \cdot \log y + \left(\mathsf{neg}\left(y\right)\right)\right)} - z\right) \]
      9. +-commutativeN/A

        \[\leadsto \log t + \left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x \cdot \log y\right)} - z\right) \]
      10. mul-1-negN/A

        \[\leadsto \log t + \left(\left(\color{blue}{-1 \cdot y} + x \cdot \log y\right) - z\right) \]
      11. associate--l+N/A

        \[\leadsto \color{blue}{\left(\log t + \left(-1 \cdot y + x \cdot \log y\right)\right) - z} \]
      12. lower--.f64N/A

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

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

      \[\leadsto \color{blue}{-1 \cdot y} - z \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(y\right)\right) - z \]
      2. lower-neg.f6474.1

        \[\leadsto \left(-y\right) - z \]
    6. Applied rewrites74.1%

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

    if -2e10 < (-.f64 (*.f64 x (log.f64 y)) y) < 1.00000000000000002e116

    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(\log t + x \cdot \log y\right) - z} \]
    3. Step-by-step derivation
      1. lower--.f64N/A

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

        \[\leadsto \left(x \cdot \log y + \log t\right) - z \]
      3. *-commutativeN/A

        \[\leadsto \left(\log y \cdot x + \log t\right) - z \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      5. lift-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      6. lift-log.f6497.5

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
    4. Applied rewrites97.5%

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

      \[\leadsto \log t - z \]
    6. Step-by-step derivation
      1. lift-log.f6485.7

        \[\leadsto \log t - z \]
    7. Applied rewrites85.7%

      \[\leadsto \log t - z \]

    if 1.00000000000000002e116 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.6%

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

      \[\leadsto \color{blue}{x \cdot \log y} \]
    3. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \log y \cdot \color{blue}{x} \]
      2. lower-*.f64N/A

        \[\leadsto \log y \cdot \color{blue}{x} \]
      3. lift-log.f6485.4

        \[\leadsto \log y \cdot x \]
    4. Applied rewrites85.4%

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

Alternative 8: 70.2% accurate, 1.4× speedup?

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

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

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

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

\mathbf{elif}\;z \leq 380:\\
\;\;\;\;\log t - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.4e18 or 380 < z

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right) + \log t} \]
      2. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right)} + \log t \]
      3. lift--.f64N/A

        \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(\color{blue}{x \cdot \log y} - y\right) - z\right) + \log t \]
      5. lift-log.f64N/A

        \[\leadsto \left(\left(x \cdot \color{blue}{\log y} - y\right) - z\right) + \log t \]
      6. lift-log.f64N/A

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

        \[\leadsto \color{blue}{\log t + \left(\left(x \cdot \log y - y\right) - z\right)} \]
      8. negate-subN/A

        \[\leadsto \log t + \left(\color{blue}{\left(x \cdot \log y + \left(\mathsf{neg}\left(y\right)\right)\right)} - z\right) \]
      9. +-commutativeN/A

        \[\leadsto \log t + \left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x \cdot \log y\right)} - z\right) \]
      10. mul-1-negN/A

        \[\leadsto \log t + \left(\left(\color{blue}{-1 \cdot y} + x \cdot \log y\right) - z\right) \]
      11. associate--l+N/A

        \[\leadsto \color{blue}{\left(\log t + \left(-1 \cdot y + x \cdot \log y\right)\right) - z} \]
      12. lower--.f64N/A

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

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

      \[\leadsto \color{blue}{-1 \cdot y} - z \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(y\right)\right) - z \]
      2. lower-neg.f6478.7

        \[\leadsto \left(-y\right) - z \]
    6. Applied rewrites78.7%

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

    if -7.4e18 < z < 380

    1. Initial program 99.8%

      \[\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. Step-by-step derivation
      1. associate--r+N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      2. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - \color{blue}{z} \]
      3. lower--.f64N/A

        \[\leadsto \left(\log t - y\right) - z \]
      4. lift-log.f6463.5

        \[\leadsto \left(\log t - y\right) - z \]
    4. Applied rewrites63.5%

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

      \[\leadsto \log t - \color{blue}{y} \]
    6. Step-by-step derivation
      1. lift-log.f64N/A

        \[\leadsto \log t - y \]
      2. lift--.f6462.4

        \[\leadsto \log t - y \]
    7. Applied rewrites62.4%

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

Alternative 9: 70.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot \log y - y \leq -20000000000:\\ \;\;\;\;\left(-y\right) - z\\ \mathbf{else}:\\ \;\;\;\;\log t - z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (- (* x (log y)) y) -20000000000.0) (- (- y) z) (- (log t) z)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (((x * log(y)) - y) <= -20000000000.0) {
		tmp = -y - z;
	} else {
		tmp = log(t) - 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 (((x * log(y)) - y) <= (-20000000000.0d0)) then
        tmp = -y - z
    else
        tmp = log(t) - z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (((x * Math.log(y)) - y) <= -20000000000.0) {
		tmp = -y - z;
	} else {
		tmp = Math.log(t) - z;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if ((x * math.log(y)) - y) <= -20000000000.0:
		tmp = -y - z
	else:
		tmp = math.log(t) - z
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(Float64(x * log(y)) - y) <= -20000000000.0)
		tmp = Float64(Float64(-y) - z);
	else
		tmp = Float64(log(t) - z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (((x * log(y)) - y) <= -20000000000.0)
		tmp = -y - z;
	else
		tmp = log(t) - z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision], -20000000000.0], N[((-y) - z), $MachinePrecision], N[(N[Log[t], $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot \log y - y \leq -20000000000:\\
\;\;\;\;\left(-y\right) - z\\

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


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

    1. Initial program 99.9%

      \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right) + \log t} \]
      2. lift--.f64N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right)} + \log t \]
      3. lift--.f64N/A

        \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
      4. lift-*.f64N/A

        \[\leadsto \left(\left(\color{blue}{x \cdot \log y} - y\right) - z\right) + \log t \]
      5. lift-log.f64N/A

        \[\leadsto \left(\left(x \cdot \color{blue}{\log y} - y\right) - z\right) + \log t \]
      6. lift-log.f64N/A

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

        \[\leadsto \color{blue}{\log t + \left(\left(x \cdot \log y - y\right) - z\right)} \]
      8. negate-subN/A

        \[\leadsto \log t + \left(\color{blue}{\left(x \cdot \log y + \left(\mathsf{neg}\left(y\right)\right)\right)} - z\right) \]
      9. +-commutativeN/A

        \[\leadsto \log t + \left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x \cdot \log y\right)} - z\right) \]
      10. mul-1-negN/A

        \[\leadsto \log t + \left(\left(\color{blue}{-1 \cdot y} + x \cdot \log y\right) - z\right) \]
      11. associate--l+N/A

        \[\leadsto \color{blue}{\left(\log t + \left(-1 \cdot y + x \cdot \log y\right)\right) - z} \]
      12. lower--.f64N/A

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

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

      \[\leadsto \color{blue}{-1 \cdot y} - z \]
    5. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(y\right)\right) - z \]
      2. lower-neg.f6474.1

        \[\leadsto \left(-y\right) - z \]
    6. Applied rewrites74.1%

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

    if -2e10 < (-.f64 (*.f64 x (log.f64 y)) y)

    1. Initial program 99.8%

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

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

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

        \[\leadsto \left(x \cdot \log y + \log t\right) - z \]
      3. *-commutativeN/A

        \[\leadsto \left(\log y \cdot x + \log t\right) - z \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      5. lift-log.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
      6. lift-log.f6497.8

        \[\leadsto \mathsf{fma}\left(\log y, x, \log t\right) - z \]
    4. Applied rewrites97.8%

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

      \[\leadsto \log t - z \]
    6. Step-by-step derivation
      1. lift-log.f6465.3

        \[\leadsto \log t - z \]
    7. Applied rewrites65.3%

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

Alternative 10: 58.4% accurate, 5.1× speedup?

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

\\
\left(-y\right) - z
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(x \cdot \log y - y\right) - z\right) + \log t \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right) + \log t} \]
    2. lift--.f64N/A

      \[\leadsto \color{blue}{\left(\left(x \cdot \log y - y\right) - z\right)} + \log t \]
    3. lift--.f64N/A

      \[\leadsto \left(\color{blue}{\left(x \cdot \log y - y\right)} - z\right) + \log t \]
    4. lift-*.f64N/A

      \[\leadsto \left(\left(\color{blue}{x \cdot \log y} - y\right) - z\right) + \log t \]
    5. lift-log.f64N/A

      \[\leadsto \left(\left(x \cdot \color{blue}{\log y} - y\right) - z\right) + \log t \]
    6. lift-log.f64N/A

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

      \[\leadsto \color{blue}{\log t + \left(\left(x \cdot \log y - y\right) - z\right)} \]
    8. negate-subN/A

      \[\leadsto \log t + \left(\color{blue}{\left(x \cdot \log y + \left(\mathsf{neg}\left(y\right)\right)\right)} - z\right) \]
    9. +-commutativeN/A

      \[\leadsto \log t + \left(\color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x \cdot \log y\right)} - z\right) \]
    10. mul-1-negN/A

      \[\leadsto \log t + \left(\left(\color{blue}{-1 \cdot y} + x \cdot \log y\right) - z\right) \]
    11. associate--l+N/A

      \[\leadsto \color{blue}{\left(\log t + \left(-1 \cdot y + x \cdot \log y\right)\right) - z} \]
    12. lower--.f64N/A

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

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

    \[\leadsto \color{blue}{-1 \cdot y} - z \]
  5. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \left(\mathsf{neg}\left(y\right)\right) - z \]
    2. lower-neg.f6458.4

      \[\leadsto \left(-y\right) - z \]
  6. Applied rewrites58.4%

    \[\leadsto \color{blue}{\left(-y\right)} - z \]
  7. Add Preprocessing

Alternative 11: 48.5% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{+75}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+114}:\\ \;\;\;\;-y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -3.4e+75) (- z) (if (<= z 8e+114) (- y) (- z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -3.4e+75) {
		tmp = -z;
	} else if (z <= 8e+114) {
		tmp = -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 <= (-3.4d+75)) then
        tmp = -z
    else if (z <= 8d+114) then
        tmp = -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 <= -3.4e+75) {
		tmp = -z;
	} else if (z <= 8e+114) {
		tmp = -y;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -3.4e+75:
		tmp = -z
	elif z <= 8e+114:
		tmp = -y
	else:
		tmp = -z
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -3.4e+75)
		tmp = Float64(-z);
	elseif (z <= 8e+114)
		tmp = Float64(-y);
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -3.4e+75)
		tmp = -z;
	elseif (z <= 8e+114)
		tmp = -y;
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.4e+75], (-z), If[LessEqual[z, 8e+114], (-y), (-z)]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 8 \cdot 10^{+114}:\\
\;\;\;\;-y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.40000000000000011e75 or 8e114 < 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. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(z\right) \]
      2. lower-neg.f6468.2

        \[\leadsto -z \]
    4. Applied rewrites68.2%

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

    if -3.40000000000000011e75 < z < 8e114

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{-1 \cdot y} \]
    3. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(y\right) \]
      2. lower-neg.f6438.5

        \[\leadsto -y \]
    4. Applied rewrites38.5%

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

Alternative 12: 31.0% accurate, 11.9× speedup?

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

\\
-y
\end{array}
Derivation
  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 \color{blue}{-1 \cdot y} \]
  3. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{neg}\left(y\right) \]
    2. lower-neg.f6431.0

      \[\leadsto -y \]
  4. Applied rewrites31.0%

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

Reproduce

?
herbie shell --seed 2025110 
(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)))