System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2

Percentage Accurate: 61.6% → 92.4%
Time: 8.2s
Alternatives: 8
Speedup: 31.2×

Specification

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

\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\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 8 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: 61.6% accurate, 1.0× speedup?

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

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

Alternative 1: 92.4% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{expm1}\left(z\right) \cdot y\\
\mathbf{if}\;y \leq -1.95 \cdot 10^{+130}:\\
\;\;\;\;x - \frac{\log t\_1}{t}\\

\mathbf{elif}\;y \leq 1.06 \cdot 10^{+172}:\\
\;\;\;\;x - \frac{t\_1}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.9500000000000001e130

    1. Initial program 48.5%

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

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

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

        \[\leadsto x - \frac{\log \left(\left(e^{z} - 1\right) \cdot \color{blue}{y}\right)}{t} \]
      3. lower-expm1.f6482.1

        \[\leadsto x - \frac{\log \left(\mathsf{expm1}\left(z\right) \cdot y\right)}{t} \]
    4. Applied rewrites82.1%

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

    if -1.9500000000000001e130 < y < 1.05999999999999996e172

    1. Initial program 67.5%

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

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

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

        \[\leadsto x - \frac{\left(e^{z} - 1\right) \cdot \color{blue}{y}}{t} \]
      3. lower-expm1.f6493.3

        \[\leadsto x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t} \]
    4. Applied rewrites93.3%

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

    if 1.05999999999999996e172 < y

    1. Initial program 5.2%

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

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

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

        \[\leadsto x - \frac{\log \left(z \cdot y + 1\right)}{t} \]
      3. lower-fma.f6486.7

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

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

Alternative 2: 91.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{expm1}\left(z\right) \cdot y\\
\mathbf{if}\;y \leq -1.95 \cdot 10^{+130}:\\
\;\;\;\;x - \frac{\log t\_1}{t}\\

\mathbf{elif}\;y \leq 1.06 \cdot 10^{+172}:\\
\;\;\;\;x - \frac{t\_1}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.9500000000000001e130

    1. Initial program 48.5%

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

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

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

        \[\leadsto x - \frac{\log \left(\left(e^{z} - 1\right) \cdot \color{blue}{y}\right)}{t} \]
      3. lower-expm1.f6482.1

        \[\leadsto x - \frac{\log \left(\mathsf{expm1}\left(z\right) \cdot y\right)}{t} \]
    4. Applied rewrites82.1%

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

    if -1.9500000000000001e130 < y < 1.05999999999999996e172

    1. Initial program 67.5%

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

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

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

        \[\leadsto x - \frac{\left(e^{z} - 1\right) \cdot \color{blue}{y}}{t} \]
      3. lower-expm1.f6493.3

        \[\leadsto x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t} \]
    4. Applied rewrites93.3%

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

    if 1.05999999999999996e172 < y

    1. Initial program 5.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \frac{\log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{6}, z \cdot y, \frac{1}{2} \cdot y\right), z, y\right), z, 1\right)\right)}{t} \]
      10. lower-*.f6487.0

        \[\leadsto x - \frac{\log \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, 0.5 \cdot y\right), z, y\right), z, 1\right)\right)}{t} \]
    4. Applied rewrites87.0%

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

Alternative 3: 91.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := \log \left(\left(1 - y\right) + y \cdot e^{z}\right)\\
\mathbf{if}\;t\_1 \leq 10^{-8}:\\
\;\;\;\;x - \left(-\frac{\mathsf{fma}\left(\left(\mathsf{expm1}\left(z\right) \cdot \mathsf{expm1}\left(z\right)\right) \cdot y, 0.5, -\mathsf{expm1}\left(z\right)\right)}{t}\right) \cdot y\\

\mathbf{else}:\\
\;\;\;\;x - \frac{t\_1}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 1e-8

    1. Initial program 56.9%

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

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

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

        \[\leadsto x - \left(\left(\frac{-1}{2} \cdot \frac{y \cdot {\left(e^{z} - 1\right)}^{2}}{t} + \frac{e^{z}}{t}\right) - \frac{1}{t}\right) \cdot \color{blue}{y} \]
    4. Applied rewrites92.0%

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

      \[\leadsto x - \left(-1 \cdot \frac{-1 \cdot \left(e^{z} - 1\right) + \frac{1}{2} \cdot \left(y \cdot {\left(e^{z} - 1\right)}^{2}\right)}{t}\right) \cdot y \]
    6. Step-by-step derivation
      1. mul-1-negN/A

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

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

        \[\leadsto x - \left(-\frac{-1 \cdot \left(e^{z} - 1\right) + \frac{1}{2} \cdot \left(y \cdot {\left(e^{z} - 1\right)}^{2}\right)}{t}\right) \cdot y \]
    7. Applied rewrites92.0%

      \[\leadsto x - \left(-\frac{\mathsf{fma}\left(\left(\mathsf{expm1}\left(z\right) \cdot \mathsf{expm1}\left(z\right)\right) \cdot y, 0.5, -\mathsf{expm1}\left(z\right)\right)}{t}\right) \cdot y \]

    if 1e-8 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z))))

    1. Initial program 95.6%

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

Alternative 4: 89.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\log \left(\left(1 - y\right) + y \cdot e^{z}\right) \leq 200:\\ \;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{t \cdot x - \log \left(1 - y\right)}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (log (+ (- 1.0 y) (* y (exp z)))) 200.0)
   (- x (/ (* (expm1 z) y) t))
   (/ (- (* t x) (log (- 1.0 y))) t)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (log(((1.0 - y) + (y * exp(z)))) <= 200.0) {
		tmp = x - ((expm1(z) * y) / t);
	} else {
		tmp = ((t * x) - log((1.0 - y))) / t;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (Math.log(((1.0 - y) + (y * Math.exp(z)))) <= 200.0) {
		tmp = x - ((Math.expm1(z) * y) / t);
	} else {
		tmp = ((t * x) - Math.log((1.0 - y))) / t;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if math.log(((1.0 - y) + (y * math.exp(z)))) <= 200.0:
		tmp = x - ((math.expm1(z) * y) / t)
	else:
		tmp = ((t * x) - math.log((1.0 - y))) / t
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) <= 200.0)
		tmp = Float64(x - Float64(Float64(expm1(z) * y) / t));
	else
		tmp = Float64(Float64(Float64(t * x) - log(Float64(1.0 - y))) / t);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 200.0], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t * x), $MachinePrecision] - N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\log \left(\left(1 - y\right) + y \cdot e^{z}\right) \leq 200:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z)))) < 200

    1. Initial program 58.5%

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

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

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

        \[\leadsto x - \frac{\left(e^{z} - 1\right) \cdot \color{blue}{y}}{t} \]
      3. lower-expm1.f6490.3

        \[\leadsto x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t} \]
    4. Applied rewrites90.3%

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

    if 200 < (log.f64 (+.f64 (-.f64 #s(literal 1 binary64) y) (*.f64 y (exp.f64 z))))

    1. Initial program 94.6%

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

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

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

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

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

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

        \[\leadsto \frac{t \cdot x - \log \left(\left(1 + y \cdot e^{z}\right) - y\right)}{t} \]
      6. +-commutativeN/A

        \[\leadsto \frac{t \cdot x - \log \left(\left(y \cdot e^{z} + 1\right) - y\right)}{t} \]
      7. *-commutativeN/A

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

        \[\leadsto \frac{t \cdot x - \log \left(\mathsf{fma}\left(e^{z}, y, 1\right) - y\right)}{t} \]
      9. lift-exp.f6481.1

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

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

      \[\leadsto \frac{t \cdot x - \log \left(1 - y\right)}{t} \]
    6. Step-by-step derivation
      1. Applied rewrites77.1%

        \[\leadsto \frac{t \cdot x - \log \left(1 - y\right)}{t} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 5: 86.7% accurate, 1.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.06 \cdot 10^{+172}:\\ \;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(z, y, 1\right)\right)}{t}\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (if (<= y 1.06e+172)
       (- x (/ (* (expm1 z) y) t))
       (- x (/ (log (fma z y 1.0)) t))))
    double code(double x, double y, double z, double t) {
    	double tmp;
    	if (y <= 1.06e+172) {
    		tmp = x - ((expm1(z) * y) / t);
    	} else {
    		tmp = x - (log(fma(z, y, 1.0)) / t);
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	tmp = 0.0
    	if (y <= 1.06e+172)
    		tmp = Float64(x - Float64(Float64(expm1(z) * y) / t));
    	else
    		tmp = Float64(x - Float64(log(fma(z, y, 1.0)) / t));
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := If[LessEqual[y, 1.06e+172], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(z * y + 1.0), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;y \leq 1.06 \cdot 10^{+172}:\\
    \;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\
    
    \mathbf{else}:\\
    \;\;\;\;x - \frac{\log \left(\mathsf{fma}\left(z, y, 1\right)\right)}{t}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < 1.05999999999999996e172

      1. Initial program 64.7%

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

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

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

          \[\leadsto x - \frac{\left(e^{z} - 1\right) \cdot \color{blue}{y}}{t} \]
        3. lower-expm1.f6486.7

          \[\leadsto x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t} \]
      4. Applied rewrites86.7%

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

      if 1.05999999999999996e172 < y

      1. Initial program 5.2%

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

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

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

          \[\leadsto x - \frac{\log \left(z \cdot y + 1\right)}{t} \]
        3. lower-fma.f6486.7

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

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

    Alternative 6: 86.0% accurate, 1.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 1.1 \cdot 10^{+172}:\\ \;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{\log \left(z \cdot y\right)}{t}\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (if (<= y 1.1e+172) (- x (/ (* (expm1 z) y) t)) (- x (/ (log (* z y)) t))))
    double code(double x, double y, double z, double t) {
    	double tmp;
    	if (y <= 1.1e+172) {
    		tmp = x - ((expm1(z) * y) / t);
    	} else {
    		tmp = x - (log((z * y)) / t);
    	}
    	return tmp;
    }
    
    public static double code(double x, double y, double z, double t) {
    	double tmp;
    	if (y <= 1.1e+172) {
    		tmp = x - ((Math.expm1(z) * y) / t);
    	} else {
    		tmp = x - (Math.log((z * y)) / t);
    	}
    	return tmp;
    }
    
    def code(x, y, z, t):
    	tmp = 0
    	if y <= 1.1e+172:
    		tmp = x - ((math.expm1(z) * y) / t)
    	else:
    		tmp = x - (math.log((z * y)) / t)
    	return tmp
    
    function code(x, y, z, t)
    	tmp = 0.0
    	if (y <= 1.1e+172)
    		tmp = Float64(x - Float64(Float64(expm1(z) * y) / t));
    	else
    		tmp = Float64(x - Float64(log(Float64(z * y)) / t));
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := If[LessEqual[y, 1.1e+172], N[(x - N[(N[(N[(Exp[z] - 1), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(z * y), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;y \leq 1.1 \cdot 10^{+172}:\\
    \;\;\;\;x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t}\\
    
    \mathbf{else}:\\
    \;\;\;\;x - \frac{\log \left(z \cdot y\right)}{t}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < 1.1000000000000001e172

      1. Initial program 64.7%

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

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

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

          \[\leadsto x - \frac{\left(e^{z} - 1\right) \cdot \color{blue}{y}}{t} \]
        3. lower-expm1.f6486.7

          \[\leadsto x - \frac{\mathsf{expm1}\left(z\right) \cdot y}{t} \]
      4. Applied rewrites86.7%

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

      if 1.1000000000000001e172 < y

      1. Initial program 5.2%

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

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

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

          \[\leadsto x - \frac{\log \left(\left(e^{z} - 1\right) \cdot \color{blue}{y}\right)}{t} \]
        3. lower-expm1.f6473.6

          \[\leadsto x - \frac{\log \left(\mathsf{expm1}\left(z\right) \cdot y\right)}{t} \]
      4. Applied rewrites73.6%

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

        \[\leadsto x - \frac{\log \left(z \cdot y\right)}{t} \]
      6. Step-by-step derivation
        1. Applied rewrites74.5%

          \[\leadsto x - \frac{\log \left(z \cdot y\right)}{t} \]
      7. Recombined 2 regimes into one program.
      8. Add Preprocessing

      Alternative 7: 81.9% accurate, 1.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x - \frac{z}{t} \cdot y\\ \end{array} \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (if (<= (exp z) 0.0) x (- x (* (/ z t) y))))
      double code(double x, double y, double z, double t) {
      	double tmp;
      	if (exp(z) <= 0.0) {
      		tmp = x;
      	} else {
      		tmp = x - ((z / t) * y);
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x, y, z, t)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8), intent (in) :: t
          real(8) :: tmp
          if (exp(z) <= 0.0d0) then
              tmp = x
          else
              tmp = x - ((z / t) * y)
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z, double t) {
      	double tmp;
      	if (Math.exp(z) <= 0.0) {
      		tmp = x;
      	} else {
      		tmp = x - ((z / t) * y);
      	}
      	return tmp;
      }
      
      def code(x, y, z, t):
      	tmp = 0
      	if math.exp(z) <= 0.0:
      		tmp = x
      	else:
      		tmp = x - ((z / t) * y)
      	return tmp
      
      function code(x, y, z, t)
      	tmp = 0.0
      	if (exp(z) <= 0.0)
      		tmp = x;
      	else
      		tmp = Float64(x - Float64(Float64(z / t) * y));
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z, t)
      	tmp = 0.0;
      	if (exp(z) <= 0.0)
      		tmp = x;
      	else
      		tmp = x - ((z / t) * y);
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.0], x, N[(x - N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;e^{z} \leq 0:\\
      \;\;\;\;x\\
      
      \mathbf{else}:\\
      \;\;\;\;x - \frac{z}{t} \cdot y\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (exp.f64 z) < 0.0

        1. Initial program 81.8%

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

          \[\leadsto \color{blue}{x} \]
        3. Step-by-step derivation
          1. Applied rewrites63.8%

            \[\leadsto \color{blue}{x} \]

          if 0.0 < (exp.f64 z)

          1. Initial program 53.0%

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

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

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

              \[\leadsto x - \left(\left(\frac{-1}{2} \cdot \frac{y \cdot {\left(e^{z} - 1\right)}^{2}}{t} + \frac{e^{z}}{t}\right) - \frac{1}{t}\right) \cdot \color{blue}{y} \]
          4. Applied rewrites88.2%

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

            \[\leadsto x - \frac{z}{t} \cdot y \]
          6. Step-by-step derivation
            1. lower-/.f6489.6

              \[\leadsto x - \frac{z}{t} \cdot y \]
          7. Applied rewrites89.6%

            \[\leadsto x - \frac{z}{t} \cdot y \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 8: 71.3% accurate, 31.2× speedup?

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

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

          \[\leadsto \color{blue}{x} \]
        3. Step-by-step derivation
          1. Applied rewrites71.3%

            \[\leadsto \color{blue}{x} \]
          2. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2025119 
          (FPCore (x y z t)
            :name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
            :precision binary64
            (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))