Statistics.Distribution.Beta:$cdensity from math-functions-0.1.5.2

Percentage Accurate: 89.0% → 99.4%
Time: 12.5s
Alternatives: 14
Speedup: 1.5×

Specification

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

\\
\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - 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 14 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: 89.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.4% accurate, 1.0× speedup?

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

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

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

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

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

      \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) + y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
    3. log-recN/A

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

      \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) + y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
    5. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(-1 \cdot \log \left(\frac{1}{y}\right), \color{blue}{x - 1}, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
    6. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right), \color{blue}{x} - 1, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
    7. log-recN/A

      \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right), x - 1, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
    8. remove-double-negN/A

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

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

      \[\leadsto \mathsf{fma}\left(\log y, x - \color{blue}{1}, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\log y, x - 1, \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right) \cdot y\right) - t \]
    12. lower-*.f64N/A

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

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

Alternative 2: 99.1% accurate, 1.4× speedup?

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

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

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

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

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

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

      \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(\color{blue}{z} - 1\right)\right) - t \]
    4. fp-cancel-sub-signN/A

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

      \[\leadsto \left(\log y \cdot \left(x - 1\right) - \color{blue}{y \cdot \left(z - 1\right)}\right) - t \]
    6. remove-double-negN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    7. log-recN/A

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

      \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    9. lower-*.f64N/A

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

      \[\leadsto \left(\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    11. log-recN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    12. remove-double-negN/A

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

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

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

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

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

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

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

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

      \[\leadsto \left(\log y \cdot \left(x - 1\right) + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t \]
    2. associate-*r*N/A

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

      \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(z - 1\right)\right) - t \]
    4. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.9% accurate, 1.2× speedup?

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

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

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

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

\mathbf{elif}\;t \leq 0.00076:\\
\;\;\;\;t\_1 - z \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -400 or 7.6000000000000004e-4 < t

    1. Initial program 94.6%

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

      \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right)} - t \]
    3. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      2. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - t \]
      3. mul-1-negN/A

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

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \color{blue}{\left(x - 1\right)} - t \]
      5. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      6. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - t \]
      7. remove-double-negN/A

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

        \[\leadsto \log y \cdot \left(\color{blue}{x} - 1\right) - t \]
      9. lift--.f6494.0

        \[\leadsto \log y \cdot \left(x - \color{blue}{1}\right) - t \]
    4. Applied rewrites94.0%

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

    if -400 < t < 7.6000000000000004e-4

    1. Initial program 83.4%

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(\color{blue}{z} - 1\right)\right) - t \]
      4. fp-cancel-sub-signN/A

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \color{blue}{y \cdot \left(z - 1\right)}\right) - t \]
      6. remove-double-negN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      7. log-recN/A

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

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      9. lower-*.f64N/A

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      11. log-recN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      12. remove-double-negN/A

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \left(z - 1\right) \cdot \color{blue}{y}\right) - t \]
      17. lift--.f6498.7

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \left(z - 1\right) \cdot y\right) - t \]
    4. Applied rewrites98.7%

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t \]
      2. associate-*r*N/A

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(z - 1\right)\right) - t \]
      4. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

        \[\leadsto \log y \cdot \left(x - 1\right) - \mathsf{fma}\left(z - 1, \color{blue}{y}, t\right) \]
      12. lift--.f6498.7

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

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

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

        \[\leadsto \log y \cdot \left(x - 1\right) - z \cdot y \]
      2. lower-*.f6497.9

        \[\leadsto \log y \cdot \left(x - 1\right) - z \cdot y \]
    10. Applied rewrites97.9%

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

Alternative 4: 89.1% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.85 \cdot 10^{+214}:\\
\;\;\;\;\left(\left(-0.5 \cdot y - 1\right) \cdot z\right) \cdot y - t\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\log y, x - 1, y\right) - t\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.8500000000000001e214

    1. Initial program 57.5%

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) + y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      3. log-recN/A

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

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) + y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      5. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(-1 \cdot \log \left(\frac{1}{y}\right), \color{blue}{x - 1}, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      6. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right), \color{blue}{x} - 1, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      7. log-recN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right), x - 1, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      8. remove-double-negN/A

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

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

        \[\leadsto \mathsf{fma}\left(\log y, x - \color{blue}{1}, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\log y, x - 1, \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right) \cdot y\right) - t \]
      12. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x - 1, \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right) \cdot y\right) - t \]
    4. Applied rewrites98.8%

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

      \[\leadsto y \cdot \color{blue}{\left(z \cdot \left(\frac{-1}{2} \cdot y - 1\right)\right)} - t \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(z \cdot \left(\frac{-1}{2} \cdot y - 1\right)\right) \cdot y - t \]
      2. lower-*.f64N/A

        \[\leadsto \left(z \cdot \left(\frac{-1}{2} \cdot y - 1\right)\right) \cdot y - t \]
      3. *-commutativeN/A

        \[\leadsto \left(\left(\frac{-1}{2} \cdot y - 1\right) \cdot z\right) \cdot y - t \]
      4. lower-*.f64N/A

        \[\leadsto \left(\left(\frac{-1}{2} \cdot y - 1\right) \cdot z\right) \cdot y - t \]
      5. lower--.f64N/A

        \[\leadsto \left(\left(\frac{-1}{2} \cdot y - 1\right) \cdot z\right) \cdot y - t \]
      6. lower-*.f6469.6

        \[\leadsto \left(\left(-0.5 \cdot y - 1\right) \cdot z\right) \cdot y - t \]
    7. Applied rewrites69.6%

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

    if -3.8500000000000001e214 < z

    1. Initial program 91.6%

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(\color{blue}{z} - 1\right)\right) - t \]
      4. fp-cancel-sub-signN/A

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \color{blue}{y \cdot \left(z - 1\right)}\right) - t \]
      6. remove-double-negN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      7. log-recN/A

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

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      9. lower-*.f64N/A

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      11. log-recN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      12. remove-double-negN/A

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

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \left(z - 1\right) \cdot y\right) - t \]
    4. Applied rewrites99.2%

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - y \cdot -1\right) - t \]
      2. fp-cancel-sub-sign-invN/A

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(-y\right) \cdot -1\right) - t \]
      4. remove-double-divN/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \frac{1}{\frac{1}{-y}} \cdot -1\right) - t \]
      5. metadata-evalN/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \frac{1}{\frac{\mathsf{neg}\left(-1\right)}{-y}} \cdot -1\right) - t \]
      6. lift-neg.f64N/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \frac{1}{\frac{\mathsf{neg}\left(-1\right)}{\mathsf{neg}\left(y\right)}} \cdot -1\right) - t \]
      7. frac-2negN/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \frac{1}{\frac{-1}{y}} \cdot -1\right) - t \]
      8. associate-/r/N/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \frac{1}{\frac{\frac{-1}{y}}{\color{blue}{-1}}}\right) - t \]
      9. associate-/r*N/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \frac{1}{\frac{-1}{y \cdot \color{blue}{-1}}}\right) - t \]
      10. *-commutativeN/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \frac{1}{\frac{-1}{-1 \cdot y}}\right) - t \]
      11. associate-/r*N/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \frac{1}{\frac{\frac{-1}{-1}}{y}}\right) - t \]
      12. metadata-evalN/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \frac{1}{\frac{1}{y}}\right) - t \]
      13. remove-double-divN/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + y\right) - t \]
      14. *-rgt-identityN/A

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + y \cdot 1\right) - t \]
      15. remove-double-negN/A

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

        \[\leadsto \left(\left(-1 \cdot \left(\mathsf{neg}\left(\log y\right)\right)\right) \cdot \left(x - 1\right) + y \cdot 1\right) - t \]
      17. neg-logN/A

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) + y \cdot 1\right) - t \]
      18. *-rgt-identityN/A

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) + y\right) - t \]
      19. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(-1 \cdot \log \left(\frac{1}{y}\right), x - \color{blue}{1}, y\right) - t \]
    7. Applied rewrites90.7%

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

Alternative 5: 89.0% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.85 \cdot 10^{+214}:\\
\;\;\;\;\left(\left(-0.5 \cdot y - 1\right) \cdot z\right) \cdot y - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.8500000000000001e214

    1. Initial program 57.5%

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

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

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) + y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      3. log-recN/A

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

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) + y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      5. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(-1 \cdot \log \left(\frac{1}{y}\right), \color{blue}{x - 1}, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      6. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right), \color{blue}{x} - 1, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      7. log-recN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right), x - 1, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      8. remove-double-negN/A

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

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

        \[\leadsto \mathsf{fma}\left(\log y, x - \color{blue}{1}, y \cdot \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) - t \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\log y, x - 1, \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right) \cdot y\right) - t \]
      12. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, x - 1, \left(-1 \cdot \left(z - 1\right) + \frac{-1}{2} \cdot \left(y \cdot \left(z - 1\right)\right)\right) \cdot y\right) - t \]
    4. Applied rewrites98.8%

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

      \[\leadsto y \cdot \color{blue}{\left(z \cdot \left(\frac{-1}{2} \cdot y - 1\right)\right)} - t \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(z \cdot \left(\frac{-1}{2} \cdot y - 1\right)\right) \cdot y - t \]
      2. lower-*.f64N/A

        \[\leadsto \left(z \cdot \left(\frac{-1}{2} \cdot y - 1\right)\right) \cdot y - t \]
      3. *-commutativeN/A

        \[\leadsto \left(\left(\frac{-1}{2} \cdot y - 1\right) \cdot z\right) \cdot y - t \]
      4. lower-*.f64N/A

        \[\leadsto \left(\left(\frac{-1}{2} \cdot y - 1\right) \cdot z\right) \cdot y - t \]
      5. lower--.f64N/A

        \[\leadsto \left(\left(\frac{-1}{2} \cdot y - 1\right) \cdot z\right) \cdot y - t \]
      6. lower-*.f6469.6

        \[\leadsto \left(\left(-0.5 \cdot y - 1\right) \cdot z\right) \cdot y - t \]
    7. Applied rewrites69.6%

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

    if -3.8500000000000001e214 < z

    1. Initial program 91.6%

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

      \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right)} - t \]
    3. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      2. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - t \]
      3. mul-1-negN/A

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

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \color{blue}{\left(x - 1\right)} - t \]
      5. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      6. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - t \]
      7. remove-double-negN/A

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

        \[\leadsto \log y \cdot \left(\color{blue}{x} - 1\right) - t \]
      9. lift--.f6490.5

        \[\leadsto \log y \cdot \left(x - \color{blue}{1}\right) - t \]
    4. Applied rewrites90.5%

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

Alternative 6: 88.9% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.85 \cdot 10^{+214}:\\
\;\;\;\;\left(-y\right) \cdot z - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.8500000000000001e214

    1. Initial program 57.5%

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(\color{blue}{z} - 1\right)\right) - t \]
      4. fp-cancel-sub-signN/A

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \color{blue}{y \cdot \left(z - 1\right)}\right) - t \]
      6. remove-double-negN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      7. log-recN/A

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

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      9. lower-*.f64N/A

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      11. log-recN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      12. remove-double-negN/A

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \left(z - 1\right) \cdot \color{blue}{y}\right) - t \]
      17. lift--.f6498.1

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \left(z - 1\right) \cdot y\right) - t \]
    4. Applied rewrites98.1%

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

      \[\leadsto -1 \cdot \color{blue}{\left(y \cdot z\right)} - t \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(-1 \cdot y\right) \cdot z - t \]
      2. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(y\right)\right) \cdot z - t \]
      3. lift-neg.f64N/A

        \[\leadsto \left(-y\right) \cdot z - t \]
      4. lower-*.f6469.0

        \[\leadsto \left(-y\right) \cdot z - t \]
    7. Applied rewrites69.0%

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

    if -3.8500000000000001e214 < z

    1. Initial program 91.6%

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

      \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right)} - t \]
    3. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      2. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - t \]
      3. mul-1-negN/A

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

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \color{blue}{\left(x - 1\right)} - t \]
      5. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      6. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - t \]
      7. remove-double-negN/A

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

        \[\leadsto \log y \cdot \left(\color{blue}{x} - 1\right) - t \]
      9. lift--.f6490.5

        \[\leadsto \log y \cdot \left(x - \color{blue}{1}\right) - t \]
    4. Applied rewrites90.5%

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

Alternative 7: 86.4% accurate, 0.4× speedup?

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

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

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

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

\mathbf{elif}\;t\_2 \leq 500000:\\
\;\;\;\;\left(-\log y\right) - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t) < -2e21 or 5e5 < (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t)

    1. Initial program 93.7%

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

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

        \[\leadsto \log y \cdot \color{blue}{x} - t \]
      2. remove-double-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot x - t \]
      3. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot x - t \]
      4. mul-1-negN/A

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot x - t \]
      5. lower-*.f64N/A

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \color{blue}{x} - t \]
      6. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot x - t \]
      7. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot x - t \]
      8. remove-double-negN/A

        \[\leadsto \log y \cdot x - t \]
      9. lift-log.f6492.1

        \[\leadsto \log y \cdot x - t \]
    4. Applied rewrites92.1%

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

    if -2e21 < (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t) < 5e5

    1. Initial program 76.1%

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

      \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right)} - t \]
    3. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      2. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - t \]
      3. mul-1-negN/A

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

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \color{blue}{\left(x - 1\right)} - t \]
      5. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      6. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - t \]
      7. remove-double-negN/A

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

        \[\leadsto \log y \cdot \left(\color{blue}{x} - 1\right) - t \]
      9. lift--.f6474.8

        \[\leadsto \log y \cdot \left(x - \color{blue}{1}\right) - t \]
    4. Applied rewrites74.8%

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

      \[\leadsto -1 \cdot \color{blue}{\log y} - t \]
    6. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot \left(-1 \cdot \color{blue}{\log y}\right) - t \]
      2. metadata-evalN/A

        \[\leadsto \left(\mathsf{neg}\left(-1\right)\right) \cdot \left(-1 \cdot \log \color{blue}{y}\right) - t \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(-1 \cdot \log y\right)\right)\right) - t \]
      4. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(\mathsf{neg}\left(\log y\right)\right)\right)\right) - t \]
      5. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \log \left(\frac{1}{y}\right)\right)\right) - t \]
      6. lower-neg.f64N/A

        \[\leadsto \left(--1 \cdot \log \left(\frac{1}{y}\right)\right) - t \]
      7. log-recN/A

        \[\leadsto \left(--1 \cdot \left(\mathsf{neg}\left(\log y\right)\right)\right) - t \]
      8. distribute-rgt-neg-outN/A

        \[\leadsto \left(-\left(\mathsf{neg}\left(-1 \cdot \log y\right)\right)\right) - t \]
      9. mul-1-negN/A

        \[\leadsto \left(-\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right)\right) - t \]
      10. remove-double-negN/A

        \[\leadsto \left(-\log y\right) - t \]
      11. lift-log.f6470.4

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

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

Alternative 8: 75.4% accurate, 1.5× speedup?

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

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

real(8) function code(x, y, z, t)
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 <= (-8.5d+114)) then
        tmp = t_1
    else if (x <= (-2.5d-6)) then
        tmp = ((1.0d0 - z) * y) - t
    else if (x <= 6d+87) then
        tmp = -log(y) - t
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.log(y) * x;
	double tmp;
	if (x <= -8.5e+114) {
		tmp = t_1;
	} else if (x <= -2.5e-6) {
		tmp = ((1.0 - z) * y) - t;
	} else if (x <= 6e+87) {
		tmp = -Math.log(y) - t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = math.log(y) * x
	tmp = 0
	if x <= -8.5e+114:
		tmp = t_1
	elif x <= -2.5e-6:
		tmp = ((1.0 - z) * y) - t
	elif x <= 6e+87:
		tmp = -math.log(y) - t
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(log(y) * x)
	tmp = 0.0
	if (x <= -8.5e+114)
		tmp = t_1;
	elseif (x <= -2.5e-6)
		tmp = Float64(Float64(Float64(1.0 - z) * y) - t);
	elseif (x <= 6e+87)
		tmp = Float64(Float64(-log(y)) - t);
	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 <= -8.5e+114)
		tmp = t_1;
	elseif (x <= -2.5e-6)
		tmp = ((1.0 - z) * y) - t;
	elseif (x <= 6e+87)
		tmp = -log(y) - t;
	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, -8.5e+114], t$95$1, If[LessEqual[x, -2.5e-6], N[(N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[x, 6e+87], N[((-N[Log[y], $MachinePrecision]) - t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.5 \cdot 10^{-6}:\\
\;\;\;\;\left(1 - z\right) \cdot y - t\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -8.5000000000000001e114 or 5.9999999999999998e87 < x

    1. Initial program 97.3%

      \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - 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. remove-double-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot x \]
      3. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot x \]
      4. mul-1-negN/A

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot x \]
      5. lower-*.f64N/A

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \color{blue}{x} \]
      6. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot x \]
      7. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot x \]
      8. remove-double-negN/A

        \[\leadsto \log y \cdot x \]
      9. lift-log.f6481.1

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

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

    if -8.5000000000000001e114 < x < -2.5000000000000002e-6

    1. Initial program 87.9%

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(\color{blue}{z} - 1\right)\right) - t \]
      4. fp-cancel-sub-signN/A

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \color{blue}{y \cdot \left(z - 1\right)}\right) - t \]
      6. remove-double-negN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      7. log-recN/A

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

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      9. lower-*.f64N/A

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      11. log-recN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      12. remove-double-negN/A

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \left(z - 1\right) \cdot \color{blue}{y}\right) - t \]
      17. lift--.f6498.8

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \left(z - 1\right) \cdot y\right) - t \]
    4. Applied rewrites98.8%

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

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

        \[\leadsto \left(1 - z\right) \cdot y - t \]
      2. lower-*.f64N/A

        \[\leadsto \left(1 - z\right) \cdot y - t \]
      3. lower--.f6448.8

        \[\leadsto \left(1 - z\right) \cdot y - t \]
    7. Applied rewrites48.8%

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

    if -2.5000000000000002e-6 < x < 5.9999999999999998e87

    1. Initial program 84.4%

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

      \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right)} - t \]
    3. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      2. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - t \]
      3. mul-1-negN/A

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

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \color{blue}{\left(x - 1\right)} - t \]
      5. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(\color{blue}{x} - 1\right) - t \]
      6. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - t \]
      7. remove-double-negN/A

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

        \[\leadsto \log y \cdot \left(\color{blue}{x} - 1\right) - t \]
      9. lift--.f6482.9

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

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

      \[\leadsto -1 \cdot \color{blue}{\log y} - t \]
    6. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot \left(-1 \cdot \color{blue}{\log y}\right) - t \]
      2. metadata-evalN/A

        \[\leadsto \left(\mathsf{neg}\left(-1\right)\right) \cdot \left(-1 \cdot \log \color{blue}{y}\right) - t \]
      3. distribute-lft-neg-outN/A

        \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(-1 \cdot \log y\right)\right)\right) - t \]
      4. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \left(\mathsf{neg}\left(\log y\right)\right)\right)\right) - t \]
      5. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(-1 \cdot \log \left(\frac{1}{y}\right)\right)\right) - t \]
      6. lower-neg.f64N/A

        \[\leadsto \left(--1 \cdot \log \left(\frac{1}{y}\right)\right) - t \]
      7. log-recN/A

        \[\leadsto \left(--1 \cdot \left(\mathsf{neg}\left(\log y\right)\right)\right) - t \]
      8. distribute-rgt-neg-outN/A

        \[\leadsto \left(-\left(\mathsf{neg}\left(-1 \cdot \log y\right)\right)\right) - t \]
      9. mul-1-negN/A

        \[\leadsto \left(-\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right)\right) - t \]
      10. remove-double-negN/A

        \[\leadsto \left(-\log y\right) - t \]
      11. lift-log.f6476.7

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

      \[\leadsto \left(-\log y\right) - t \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 66.9% accurate, 1.8× speedup?

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

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

real(8) function code(x, y, z, t)
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 <= (-8.5d+114)) then
        tmp = t_1
    else if (x <= 6d+87) then
        tmp = ((1.0d0 - z) * y) - t
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.log(y) * x;
	double tmp;
	if (x <= -8.5e+114) {
		tmp = t_1;
	} else if (x <= 6e+87) {
		tmp = ((1.0 - z) * y) - t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = math.log(y) * x
	tmp = 0
	if x <= -8.5e+114:
		tmp = t_1
	elif x <= 6e+87:
		tmp = ((1.0 - z) * y) - t
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(log(y) * x)
	tmp = 0.0
	if (x <= -8.5e+114)
		tmp = t_1;
	elseif (x <= 6e+87)
		tmp = Float64(Float64(Float64(1.0 - z) * y) - t);
	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 <= -8.5e+114)
		tmp = t_1;
	elseif (x <= 6e+87)
		tmp = ((1.0 - z) * y) - t;
	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, -8.5e+114], t$95$1, If[LessEqual[x, 6e+87], N[(N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 6 \cdot 10^{+87}:\\
\;\;\;\;\left(1 - z\right) \cdot y - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.5000000000000001e114 or 5.9999999999999998e87 < x

    1. Initial program 97.3%

      \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - 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. remove-double-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot x \]
      3. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot x \]
      4. mul-1-negN/A

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot x \]
      5. lower-*.f64N/A

        \[\leadsto \left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \color{blue}{x} \]
      6. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot x \]
      7. log-recN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot x \]
      8. remove-double-negN/A

        \[\leadsto \log y \cdot x \]
      9. lift-log.f6481.1

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

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

    if -8.5000000000000001e114 < x < 5.9999999999999998e87

    1. Initial program 84.9%

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(\color{blue}{z} - 1\right)\right) - t \]
      4. fp-cancel-sub-signN/A

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \color{blue}{y \cdot \left(z - 1\right)}\right) - t \]
      6. remove-double-negN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      7. log-recN/A

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

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      9. lower-*.f64N/A

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      11. log-recN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      12. remove-double-negN/A

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 - z\right) \cdot y - t \]
      2. lower-*.f64N/A

        \[\leadsto \left(1 - z\right) \cdot y - t \]
      3. lower--.f6459.8

        \[\leadsto \left(1 - z\right) \cdot y - t \]
    7. Applied rewrites59.8%

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

Alternative 10: 46.2% accurate, 3.4× speedup?

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

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

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

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

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

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

      \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(\color{blue}{z} - 1\right)\right) - t \]
    4. fp-cancel-sub-signN/A

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

      \[\leadsto \left(\log y \cdot \left(x - 1\right) - \color{blue}{y \cdot \left(z - 1\right)}\right) - t \]
    6. remove-double-negN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    7. log-recN/A

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

      \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    9. lower-*.f64N/A

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

      \[\leadsto \left(\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    11. log-recN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    12. remove-double-negN/A

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

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

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

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

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

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

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

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

      \[\leadsto \left(1 - z\right) \cdot y - t \]
    2. lower-*.f64N/A

      \[\leadsto \left(1 - z\right) \cdot y - t \]
    3. lower--.f6446.2

      \[\leadsto \left(1 - z\right) \cdot y - t \]
  7. Applied rewrites46.2%

    \[\leadsto \left(1 - z\right) \cdot \color{blue}{y} - t \]
  8. Add Preprocessing

Alternative 11: 46.0% accurate, 4.2× speedup?

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

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

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

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

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

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

      \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(\color{blue}{z} - 1\right)\right) - t \]
    4. fp-cancel-sub-signN/A

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

      \[\leadsto \left(\log y \cdot \left(x - 1\right) - \color{blue}{y \cdot \left(z - 1\right)}\right) - t \]
    6. remove-double-negN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    7. log-recN/A

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

      \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    9. lower-*.f64N/A

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

      \[\leadsto \left(\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    11. log-recN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
    12. remove-double-negN/A

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

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

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

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

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

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

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

    \[\leadsto -1 \cdot \color{blue}{\left(y \cdot z\right)} - t \]
  6. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \left(-1 \cdot y\right) \cdot z - t \]
    2. mul-1-negN/A

      \[\leadsto \left(\mathsf{neg}\left(y\right)\right) \cdot z - t \]
    3. lift-neg.f64N/A

      \[\leadsto \left(-y\right) \cdot z - t \]
    4. lower-*.f6446.0

      \[\leadsto \left(-y\right) \cdot z - t \]
  7. Applied rewrites46.0%

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

Alternative 12: 43.6% accurate, 2.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -720:\\
\;\;\;\;-t\\

\mathbf{elif}\;t \leq 520000000:\\
\;\;\;\;\left(1 - z\right) \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -720 or 5.2e8 < t

    1. Initial program 94.6%

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

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

        \[\leadsto \mathsf{neg}\left(t\right) \]
      2. lower-neg.f6469.1

        \[\leadsto -t \]
    4. Applied rewrites69.1%

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

    if -720 < t < 5.2e8

    1. Initial program 83.5%

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(\color{blue}{z} - 1\right)\right) - t \]
      4. fp-cancel-sub-signN/A

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \color{blue}{y \cdot \left(z - 1\right)}\right) - t \]
      6. remove-double-negN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      7. log-recN/A

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

        \[\leadsto \left(\left(-1 \cdot \log \left(\frac{1}{y}\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      9. lower-*.f64N/A

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

        \[\leadsto \left(\left(\mathsf{neg}\left(\log \left(\frac{1}{y}\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      11. log-recN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log y\right)\right)\right)\right) \cdot \left(x - 1\right) - y \cdot \left(z - 1\right)\right) - t \]
      12. remove-double-negN/A

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

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

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \left(z - 1\right) \cdot \color{blue}{y}\right) - t \]
      17. lift--.f6498.7

        \[\leadsto \left(\log y \cdot \left(x - 1\right) - \left(z - 1\right) \cdot y\right) - t \]
    4. Applied rewrites98.7%

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

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t \]
      2. associate-*r*N/A

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

        \[\leadsto \left(\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot \left(z - 1\right)\right) - t \]
      4. fp-cancel-sub-sign-invN/A

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

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

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

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

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

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

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

        \[\leadsto \log y \cdot \left(x - 1\right) - \mathsf{fma}\left(z - 1, \color{blue}{y}, t\right) \]
      12. lift--.f6498.7

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

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

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

        \[\leadsto \left(1 - z\right) \cdot y \]
      2. lower-*.f64N/A

        \[\leadsto \left(1 - z\right) \cdot y \]
      3. lower--.f6418.7

        \[\leadsto \left(1 - z\right) \cdot y \]
    10. Applied rewrites18.7%

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

Alternative 13: 43.3% accurate, 2.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -720:\\
\;\;\;\;-t\\

\mathbf{elif}\;t \leq 520000000:\\
\;\;\;\;\left(-y\right) \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -720 or 5.2e8 < t

    1. Initial program 94.6%

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

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

        \[\leadsto \mathsf{neg}\left(t\right) \]
      2. lower-neg.f6469.1

        \[\leadsto -t \]
    4. Applied rewrites69.1%

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

    if -720 < t < 5.2e8

    1. Initial program 83.5%

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

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

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

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

        \[\leadsto \log \left(1 - y\right) \cdot z \]
      4. lift--.f643.7

        \[\leadsto \log \left(1 - y\right) \cdot z \]
    4. Applied rewrites3.7%

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

      \[\leadsto \left(-1 \cdot y\right) \cdot z \]
    6. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto \left(-1 \cdot y\right) \cdot z \]
      2. cancel-sign-sub-invN/A

        \[\leadsto \left(-1 \cdot y\right) \cdot z \]
      3. metadata-evalN/A

        \[\leadsto \left(-1 \cdot y\right) \cdot z \]
      4. mul-1-negN/A

        \[\leadsto \left(-1 \cdot y\right) \cdot z \]
      5. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(y\right)\right) \cdot z \]
      6. lift-neg.f6418.1

        \[\leadsto \left(-y\right) \cdot z \]
    7. Applied rewrites18.1%

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

Alternative 14: 35.7% accurate, 16.1× speedup?

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

\\
-t
\end{array}
Derivation
  1. Initial program 89.0%

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

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

      \[\leadsto \mathsf{neg}\left(t\right) \]
    2. lower-neg.f6435.7

      \[\leadsto -t \]
  4. Applied rewrites35.7%

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

Reproduce

?
herbie shell --seed 2025130 
(FPCore (x y z t)
  :name "Statistics.Distribution.Beta:$cdensity from math-functions-0.1.5.2"
  :precision binary64
  (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t))