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

Percentage Accurate: 89.0% → 99.8%
Time: 17.3s
Alternatives: 15
Speedup: 1.9×

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;
}
real(8) function code(x, y, z, t)
    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}

Sampling outcomes in binary64 precision:

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 15 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;
}
real(8) function code(x, y, z, t)
    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.8% accurate, 0.7× speedup?

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

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

    \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
  2. Step-by-step derivation
    1. sub-neg91.2%

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

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

      \[\leadsto \color{blue}{\left(z - 1\right) \cdot \log \left(1 - y\right) + \left(\left(x - 1\right) \cdot \log y + \left(-t\right)\right)} \]
    4. fma-def91.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z - 1, \log \left(1 - y\right), \left(x - 1\right) \cdot \log y + \left(-t\right)\right)} \]
    5. sub-neg91.2%

      \[\leadsto \mathsf{fma}\left(\color{blue}{z + \left(-1\right)}, \log \left(1 - y\right), \left(x - 1\right) \cdot \log y + \left(-t\right)\right) \]
    6. metadata-eval91.2%

      \[\leadsto \mathsf{fma}\left(z + \color{blue}{-1}, \log \left(1 - y\right), \left(x - 1\right) \cdot \log y + \left(-t\right)\right) \]
    7. sub-neg91.2%

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

      \[\leadsto \mathsf{fma}\left(z + -1, \color{blue}{\mathsf{log1p}\left(-y\right)}, \left(x - 1\right) \cdot \log y + \left(-t\right)\right) \]
    9. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \color{blue}{\left(x - 1\right) \cdot \log y - t}\right) \]
    10. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \color{blue}{\left(x + \left(-1\right)\right)} \cdot \log y - t\right) \]
    11. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \left(x + \color{blue}{-1}\right) \cdot \log y - t\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \left(x + -1\right) \cdot \log y - t\right)} \]
  4. Final simplification99.8%

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

Alternative 2: 95.9% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;-1 + x \leq -0.5:\\
\;\;\;\;\left(-t\right) - \left(\log y + y \cdot \left(z + -1\right)\right)\\

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


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

    1. Initial program 95.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 98.5%

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-1 \cdot y\right)}\right) - t \]
    3. Step-by-step derivation
      1. mul-1-neg98.5%

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

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

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

    if -1.0002 < (-.f64 x 1) < -0.5

    1. Initial program 86.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 99.3%

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

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot \log y + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t} \]
    6. Step-by-step derivation
      1. mul-1-neg99.2%

        \[\leadsto \left(-1 \cdot \log y + \color{blue}{\left(-y \cdot \left(z - 1\right)\right)}\right) - t \]
      2. sub-neg99.2%

        \[\leadsto \left(-1 \cdot \log y + \left(-y \cdot \color{blue}{\left(z + \left(-1\right)\right)}\right)\right) - t \]
      3. metadata-eval99.2%

        \[\leadsto \left(-1 \cdot \log y + \left(-y \cdot \left(z + \color{blue}{-1}\right)\right)\right) - t \]
      4. unsub-neg99.2%

        \[\leadsto \color{blue}{\left(-1 \cdot \log y - y \cdot \left(z + -1\right)\right)} - t \]
      5. mul-1-neg99.2%

        \[\leadsto \left(\color{blue}{\left(-\log y\right)} - y \cdot \left(z + -1\right)\right) - t \]
      6. +-commutative99.2%

        \[\leadsto \left(\left(-\log y\right) - y \cdot \color{blue}{\left(-1 + z\right)}\right) - t \]
    7. Simplified99.2%

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

    if -0.5 < (-.f64 x 1)

    1. Initial program 95.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 94.4%

      \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right) - t} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;-1 + x \leq -1.0002:\\ \;\;\;\;\left(y + \log y \cdot \left(-1 + x\right)\right) - t\\ \mathbf{elif}\;-1 + x \leq -0.5:\\ \;\;\;\;\left(-t\right) - \left(\log y + y \cdot \left(z + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot \left(-1 + x\right) - t\\ \end{array} \]

Alternative 3: 95.7% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;-1 + x \leq -1.0002 \lor \neg \left(-1 + x \leq -0.5\right):\\ \;\;\;\;\log y \cdot \left(-1 + x\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(-t\right) - \left(\log y + z \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= (+ -1.0 x) -1.0002) (not (<= (+ -1.0 x) -0.5)))
   (- (* (log y) (+ -1.0 x)) t)
   (- (- t) (+ (log y) (* z y)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (((-1.0 + x) <= -1.0002) || !((-1.0 + x) <= -0.5)) {
		tmp = (log(y) * (-1.0 + x)) - t;
	} else {
		tmp = -t - (log(y) + (z * y));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((((-1.0d0) + x) <= (-1.0002d0)) .or. (.not. (((-1.0d0) + x) <= (-0.5d0)))) then
        tmp = (log(y) * ((-1.0d0) + x)) - t
    else
        tmp = -t - (log(y) + (z * y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (((-1.0 + x) <= -1.0002) || !((-1.0 + x) <= -0.5)) {
		tmp = (Math.log(y) * (-1.0 + x)) - t;
	} else {
		tmp = -t - (Math.log(y) + (z * y));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if ((-1.0 + x) <= -1.0002) or not ((-1.0 + x) <= -0.5):
		tmp = (math.log(y) * (-1.0 + x)) - t
	else:
		tmp = -t - (math.log(y) + (z * y))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((Float64(-1.0 + x) <= -1.0002) || !(Float64(-1.0 + x) <= -0.5))
		tmp = Float64(Float64(log(y) * Float64(-1.0 + x)) - t);
	else
		tmp = Float64(Float64(-t) - Float64(log(y) + Float64(z * y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (((-1.0 + x) <= -1.0002) || ~(((-1.0 + x) <= -0.5)))
		tmp = (log(y) * (-1.0 + x)) - t;
	else
		tmp = -t - (log(y) + (z * y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(-1.0 + x), $MachinePrecision], -1.0002], N[Not[LessEqual[N[(-1.0 + x), $MachinePrecision], -0.5]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * N[(-1.0 + x), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[((-t) - N[(N[Log[y], $MachinePrecision] + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;-1 + x \leq -1.0002 \lor \neg \left(-1 + x \leq -0.5\right):\\
\;\;\;\;\log y \cdot \left(-1 + x\right) - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 x 1) < -1.0002 or -0.5 < (-.f64 x 1)

    1. Initial program 95.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 94.2%

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

    if -1.0002 < (-.f64 x 1) < -0.5

    1. Initial program 86.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 99.3%

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

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-y\right)}\right) - t \]
    5. Step-by-step derivation
      1. sub-neg99.3%

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

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

        \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    6. Applied egg-rr98.8%

      \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    7. Taylor expanded in x around 0 99.2%

      \[\leadsto \color{blue}{\left(-1 \cdot \log y + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t} \]
    8. Step-by-step derivation
      1. mul-1-neg99.2%

        \[\leadsto \left(\color{blue}{\left(-\log y\right)} + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t \]
      2. log-rec99.2%

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) + \log \left(\frac{1}{y}\right)\right)} - t \]
      4. log-rec99.2%

        \[\leadsto \left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) + \color{blue}{\left(-\log y\right)}\right) - t \]
      5. unsub-neg99.2%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) - \log y\right)} - t \]
      6. mul-1-neg99.2%

        \[\leadsto \left(\color{blue}{\left(-y \cdot \left(z - 1\right)\right)} - \log y\right) - t \]
      7. sub-neg99.2%

        \[\leadsto \left(\left(-y \cdot \color{blue}{\left(z + \left(-1\right)\right)}\right) - \log y\right) - t \]
      8. metadata-eval99.2%

        \[\leadsto \left(\left(-y \cdot \left(z + \color{blue}{-1}\right)\right) - \log y\right) - t \]
      9. +-commutative99.2%

        \[\leadsto \left(\left(-y \cdot \color{blue}{\left(-1 + z\right)}\right) - \log y\right) - t \]
      10. *-commutative99.2%

        \[\leadsto \left(\left(-\color{blue}{\left(-1 + z\right) \cdot y}\right) - \log y\right) - t \]
      11. distribute-rgt-neg-in99.2%

        \[\leadsto \left(\color{blue}{\left(-1 + z\right) \cdot \left(-y\right)} - \log y\right) - t \]
    9. Simplified99.2%

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

      \[\leadsto \left(\color{blue}{-1 \cdot \left(y \cdot z\right)} - \log y\right) - t \]
    11. Step-by-step derivation
      1. mul-1-neg98.7%

        \[\leadsto \left(\color{blue}{\left(-y \cdot z\right)} - \log y\right) - t \]
      2. distribute-rgt-neg-in98.7%

        \[\leadsto \left(\color{blue}{y \cdot \left(-z\right)} - \log y\right) - t \]
    12. Simplified98.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-1 + x \leq -1.0002 \lor \neg \left(-1 + x \leq -0.5\right):\\ \;\;\;\;\log y \cdot \left(-1 + x\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(-t\right) - \left(\log y + z \cdot y\right)\\ \end{array} \]

Alternative 4: 95.7% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;-1 + x \leq -0.5:\\
\;\;\;\;\left(-t\right) - \left(\log y + z \cdot y\right)\\

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


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

    1. Initial program 95.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 98.5%

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-1 \cdot y\right)}\right) - t \]
    3. Step-by-step derivation
      1. mul-1-neg98.5%

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

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

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

    if -1.0002 < (-.f64 x 1) < -0.5

    1. Initial program 86.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 99.3%

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

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-y\right)}\right) - t \]
    5. Step-by-step derivation
      1. sub-neg99.3%

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

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

        \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    6. Applied egg-rr98.8%

      \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    7. Taylor expanded in x around 0 99.2%

      \[\leadsto \color{blue}{\left(-1 \cdot \log y + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t} \]
    8. Step-by-step derivation
      1. mul-1-neg99.2%

        \[\leadsto \left(\color{blue}{\left(-\log y\right)} + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t \]
      2. log-rec99.2%

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) + \log \left(\frac{1}{y}\right)\right)} - t \]
      4. log-rec99.2%

        \[\leadsto \left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) + \color{blue}{\left(-\log y\right)}\right) - t \]
      5. unsub-neg99.2%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) - \log y\right)} - t \]
      6. mul-1-neg99.2%

        \[\leadsto \left(\color{blue}{\left(-y \cdot \left(z - 1\right)\right)} - \log y\right) - t \]
      7. sub-neg99.2%

        \[\leadsto \left(\left(-y \cdot \color{blue}{\left(z + \left(-1\right)\right)}\right) - \log y\right) - t \]
      8. metadata-eval99.2%

        \[\leadsto \left(\left(-y \cdot \left(z + \color{blue}{-1}\right)\right) - \log y\right) - t \]
      9. +-commutative99.2%

        \[\leadsto \left(\left(-y \cdot \color{blue}{\left(-1 + z\right)}\right) - \log y\right) - t \]
      10. *-commutative99.2%

        \[\leadsto \left(\left(-\color{blue}{\left(-1 + z\right) \cdot y}\right) - \log y\right) - t \]
      11. distribute-rgt-neg-in99.2%

        \[\leadsto \left(\color{blue}{\left(-1 + z\right) \cdot \left(-y\right)} - \log y\right) - t \]
    9. Simplified99.2%

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

      \[\leadsto \left(\color{blue}{-1 \cdot \left(y \cdot z\right)} - \log y\right) - t \]
    11. Step-by-step derivation
      1. mul-1-neg98.7%

        \[\leadsto \left(\color{blue}{\left(-y \cdot z\right)} - \log y\right) - t \]
      2. distribute-rgt-neg-in98.7%

        \[\leadsto \left(\color{blue}{y \cdot \left(-z\right)} - \log y\right) - t \]
    12. Simplified98.7%

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

    if -0.5 < (-.f64 x 1)

    1. Initial program 95.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 94.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-1 + x \leq -1.0002:\\ \;\;\;\;\left(y + \log y \cdot \left(-1 + x\right)\right) - t\\ \mathbf{elif}\;-1 + x \leq -0.5:\\ \;\;\;\;\left(-t\right) - \left(\log y + z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot \left(-1 + x\right) - t\\ \end{array} \]

Alternative 5: 99.1% accurate, 1.9× speedup?

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

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

    \[\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 99.1%

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

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

    \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-y\right)}\right) - t \]
  5. Final simplification99.1%

    \[\leadsto \left(\log y \cdot \left(-1 + x\right) - y \cdot \left(z + -1\right)\right) - t \]

Alternative 6: 55.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;t \leq -3.3 \cdot 10^{+72}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq -4.4 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{-302}:\\ \;\;\;\;-\log y\\ \mathbf{elif}\;t \leq 6 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))))
   (if (<= t -3.3e+72)
     (- t)
     (if (<= t -4.4e-101)
       t_1
       (if (<= t 8.2e-302) (- (log y)) (if (<= t 6e+126) t_1 (- t)))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double tmp;
	if (t <= -3.3e+72) {
		tmp = -t;
	} else if (t <= -4.4e-101) {
		tmp = t_1;
	} else if (t <= 8.2e-302) {
		tmp = -log(y);
	} else if (t <= 6e+126) {
		tmp = t_1;
	} else {
		tmp = -t;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x * log(y)
    if (t <= (-3.3d+72)) then
        tmp = -t
    else if (t <= (-4.4d-101)) then
        tmp = t_1
    else if (t <= 8.2d-302) then
        tmp = -log(y)
    else if (t <= 6d+126) then
        tmp = t_1
    else
        tmp = -t
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * Math.log(y);
	double tmp;
	if (t <= -3.3e+72) {
		tmp = -t;
	} else if (t <= -4.4e-101) {
		tmp = t_1;
	} else if (t <= 8.2e-302) {
		tmp = -Math.log(y);
	} else if (t <= 6e+126) {
		tmp = t_1;
	} else {
		tmp = -t;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	tmp = 0
	if t <= -3.3e+72:
		tmp = -t
	elif t <= -4.4e-101:
		tmp = t_1
	elif t <= 8.2e-302:
		tmp = -math.log(y)
	elif t <= 6e+126:
		tmp = t_1
	else:
		tmp = -t
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	tmp = 0.0
	if (t <= -3.3e+72)
		tmp = Float64(-t);
	elseif (t <= -4.4e-101)
		tmp = t_1;
	elseif (t <= 8.2e-302)
		tmp = Float64(-log(y));
	elseif (t <= 6e+126)
		tmp = t_1;
	else
		tmp = Float64(-t);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	tmp = 0.0;
	if (t <= -3.3e+72)
		tmp = -t;
	elseif (t <= -4.4e-101)
		tmp = t_1;
	elseif (t <= 8.2e-302)
		tmp = -log(y);
	elseif (t <= 6e+126)
		tmp = t_1;
	else
		tmp = -t;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -3.3e+72], (-t), If[LessEqual[t, -4.4e-101], t$95$1, If[LessEqual[t, 8.2e-302], (-N[Log[y], $MachinePrecision]), If[LessEqual[t, 6e+126], t$95$1, (-t)]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t \leq -4.4 \cdot 10^{-101}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq 8.2 \cdot 10^{-302}:\\
\;\;\;\;-\log y\\

\mathbf{elif}\;t \leq 6 \cdot 10^{+126}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -3.3e72 or 6.0000000000000005e126 < t

    1. Initial program 97.8%

      \[\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 79.6%

      \[\leadsto \color{blue}{-1 \cdot t} \]
    3. Step-by-step derivation
      1. neg-mul-179.6%

        \[\leadsto \color{blue}{-t} \]
    4. Simplified79.6%

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

    if -3.3e72 < t < -4.3999999999999998e-101 or 8.1999999999999996e-302 < t < 6.0000000000000005e126

    1. Initial program 86.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 99.5%

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-1 \cdot y\right)}\right) - t \]
    3. Step-by-step derivation
      1. mul-1-neg99.5%

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

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

      \[\leadsto \color{blue}{x \cdot \log y} \]
    6. Step-by-step derivation
      1. *-commutative57.0%

        \[\leadsto \color{blue}{\log y \cdot x} \]
    7. Simplified57.0%

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

    if -4.3999999999999998e-101 < t < 8.1999999999999996e-302

    1. Initial program 88.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 85.8%

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

      \[\leadsto \color{blue}{-1 \cdot \log y} - t \]
    4. Step-by-step derivation
      1. mul-1-neg55.0%

        \[\leadsto \color{blue}{\left(-\log y\right)} - t \]
    5. Simplified55.0%

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

      \[\leadsto \color{blue}{-1 \cdot \log y} \]
    7. Step-by-step derivation
      1. mul-1-neg55.0%

        \[\leadsto \color{blue}{-\log y} \]
    8. Simplified55.0%

      \[\leadsto \color{blue}{-\log y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -3.3 \cdot 10^{+72}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq -4.4 \cdot 10^{-101}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{-302}:\\ \;\;\;\;-\log y\\ \mathbf{elif}\;t \leq 6 \cdot 10^{+126}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]

Alternative 7: 86.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 2.1 \cdot 10^{-14}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\left(-t\right) - \log y\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= x -1.0) (not (<= x 2.1e-14)))
   (- (* x (log y)) t)
   (- (- t) (log y))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -1.0) || !(x <= 2.1e-14)) {
		tmp = (x * log(y)) - t;
	} else {
		tmp = -t - log(y);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x <= (-1.0d0)) .or. (.not. (x <= 2.1d-14))) then
        tmp = (x * log(y)) - t
    else
        tmp = -t - log(y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -1.0) || !(x <= 2.1e-14)) {
		tmp = (x * Math.log(y)) - t;
	} else {
		tmp = -t - Math.log(y);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x <= -1.0) or not (x <= 2.1e-14):
		tmp = (x * math.log(y)) - t
	else:
		tmp = -t - math.log(y)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((x <= -1.0) || !(x <= 2.1e-14))
		tmp = Float64(Float64(x * log(y)) - t);
	else
		tmp = Float64(Float64(-t) - log(y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((x <= -1.0) || ~((x <= 2.1e-14)))
		tmp = (x * log(y)) - t;
	else
		tmp = -t - log(y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 2.1e-14]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 2.1 \cdot 10^{-14}\right):\\
\;\;\;\;x \cdot \log y - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1 or 2.0999999999999999e-14 < x

    1. Initial program 94.8%

      \[\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 93.6%

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

        \[\leadsto \color{blue}{\left(x - 1\right) \cdot \log y} - t \]
      2. sub-neg93.6%

        \[\leadsto \color{blue}{\left(x + \left(-1\right)\right)} \cdot \log y - t \]
      3. metadata-eval93.6%

        \[\leadsto \left(x + \color{blue}{-1}\right) \cdot \log y - t \]
      4. flip-+46.7%

        \[\leadsto \color{blue}{\frac{x \cdot x - -1 \cdot -1}{x - -1}} \cdot \log y - t \]
      5. associate-*l/46.6%

        \[\leadsto \color{blue}{\frac{\left(x \cdot x - -1 \cdot -1\right) \cdot \log y}{x - -1}} - t \]
      6. metadata-eval46.6%

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, x, -1\right)} \cdot \log y}{x - -1} - t \]
      8. metadata-eval46.6%

        \[\leadsto \frac{\mathsf{fma}\left(x, x, \color{blue}{-1}\right) \cdot \log y}{x - -1} - t \]
      9. sub-neg46.6%

        \[\leadsto \frac{\mathsf{fma}\left(x, x, -1\right) \cdot \log y}{\color{blue}{x + \left(--1\right)}} - t \]
      10. metadata-eval46.6%

        \[\leadsto \frac{\mathsf{fma}\left(x, x, -1\right) \cdot \log y}{x + \color{blue}{1}} - t \]
    4. Applied egg-rr46.6%

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

      \[\leadsto \color{blue}{x \cdot \log y} - t \]
    6. Step-by-step derivation
      1. *-commutative93.1%

        \[\leadsto \color{blue}{\log y \cdot x} - t \]
    7. Simplified93.1%

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

    if -1 < x < 2.0999999999999999e-14

    1. Initial program 87.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 y around 0 85.9%

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

      \[\leadsto \color{blue}{-1 \cdot \log y} - t \]
    4. Step-by-step derivation
      1. mul-1-neg85.4%

        \[\leadsto \color{blue}{\left(-\log y\right)} - t \]
    5. Simplified85.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 2.1 \cdot 10^{-14}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\left(-t\right) - \log y\\ \end{array} \]

Alternative 8: 86.9% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 2.1 \cdot 10^{-14}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\left(y - \log y\right) - t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= x -1.0) (not (<= x 2.1e-14)))
   (- (* x (log y)) t)
   (- (- y (log y)) t)))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -1.0) || !(x <= 2.1e-14)) {
		tmp = (x * log(y)) - t;
	} else {
		tmp = (y - log(y)) - t;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x <= (-1.0d0)) .or. (.not. (x <= 2.1d-14))) then
        tmp = (x * log(y)) - t
    else
        tmp = (y - log(y)) - t
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -1.0) || !(x <= 2.1e-14)) {
		tmp = (x * Math.log(y)) - t;
	} else {
		tmp = (y - Math.log(y)) - t;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x <= -1.0) or not (x <= 2.1e-14):
		tmp = (x * math.log(y)) - t
	else:
		tmp = (y - math.log(y)) - t
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((x <= -1.0) || !(x <= 2.1e-14))
		tmp = Float64(Float64(x * log(y)) - t);
	else
		tmp = Float64(Float64(y - log(y)) - t);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((x <= -1.0) || ~((x <= 2.1e-14)))
		tmp = (x * log(y)) - t;
	else
		tmp = (y - log(y)) - t;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 2.1e-14]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(y - N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 2.1 \cdot 10^{-14}\right):\\
\;\;\;\;x \cdot \log y - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1 or 2.0999999999999999e-14 < x

    1. Initial program 94.8%

      \[\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 93.6%

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

        \[\leadsto \color{blue}{\left(x - 1\right) \cdot \log y} - t \]
      2. sub-neg93.6%

        \[\leadsto \color{blue}{\left(x + \left(-1\right)\right)} \cdot \log y - t \]
      3. metadata-eval93.6%

        \[\leadsto \left(x + \color{blue}{-1}\right) \cdot \log y - t \]
      4. flip-+46.7%

        \[\leadsto \color{blue}{\frac{x \cdot x - -1 \cdot -1}{x - -1}} \cdot \log y - t \]
      5. associate-*l/46.6%

        \[\leadsto \color{blue}{\frac{\left(x \cdot x - -1 \cdot -1\right) \cdot \log y}{x - -1}} - t \]
      6. metadata-eval46.6%

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, x, -1\right)} \cdot \log y}{x - -1} - t \]
      8. metadata-eval46.6%

        \[\leadsto \frac{\mathsf{fma}\left(x, x, \color{blue}{-1}\right) \cdot \log y}{x - -1} - t \]
      9. sub-neg46.6%

        \[\leadsto \frac{\mathsf{fma}\left(x, x, -1\right) \cdot \log y}{\color{blue}{x + \left(--1\right)}} - t \]
      10. metadata-eval46.6%

        \[\leadsto \frac{\mathsf{fma}\left(x, x, -1\right) \cdot \log y}{x + \color{blue}{1}} - t \]
    4. Applied egg-rr46.6%

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

      \[\leadsto \color{blue}{x \cdot \log y} - t \]
    6. Step-by-step derivation
      1. *-commutative93.1%

        \[\leadsto \color{blue}{\log y \cdot x} - t \]
    7. Simplified93.1%

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

    if -1 < x < 2.0999999999999999e-14

    1. Initial program 87.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 y around 0 99.3%

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

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-y\right)}\right) - t \]
    5. Step-by-step derivation
      1. sub-neg99.3%

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

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

        \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    6. Applied egg-rr98.8%

      \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    7. Taylor expanded in x around 0 98.7%

      \[\leadsto \color{blue}{\left(-1 \cdot \log y + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t} \]
    8. Step-by-step derivation
      1. mul-1-neg98.7%

        \[\leadsto \left(\color{blue}{\left(-\log y\right)} + -1 \cdot \left(y \cdot \left(z - 1\right)\right)\right) - t \]
      2. log-rec98.7%

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) + \log \left(\frac{1}{y}\right)\right)} - t \]
      4. log-rec98.7%

        \[\leadsto \left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) + \color{blue}{\left(-\log y\right)}\right) - t \]
      5. unsub-neg98.7%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) - \log y\right)} - t \]
      6. mul-1-neg98.7%

        \[\leadsto \left(\color{blue}{\left(-y \cdot \left(z - 1\right)\right)} - \log y\right) - t \]
      7. sub-neg98.7%

        \[\leadsto \left(\left(-y \cdot \color{blue}{\left(z + \left(-1\right)\right)}\right) - \log y\right) - t \]
      8. metadata-eval98.7%

        \[\leadsto \left(\left(-y \cdot \left(z + \color{blue}{-1}\right)\right) - \log y\right) - t \]
      9. +-commutative98.7%

        \[\leadsto \left(\left(-y \cdot \color{blue}{\left(-1 + z\right)}\right) - \log y\right) - t \]
      10. *-commutative98.7%

        \[\leadsto \left(\left(-\color{blue}{\left(-1 + z\right) \cdot y}\right) - \log y\right) - t \]
      11. distribute-rgt-neg-in98.7%

        \[\leadsto \left(\color{blue}{\left(-1 + z\right) \cdot \left(-y\right)} - \log y\right) - t \]
    9. Simplified98.7%

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

      \[\leadsto \left(\color{blue}{y} - \log y\right) - t \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 2.1 \cdot 10^{-14}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\left(y - \log y\right) - t\\ \end{array} \]

Alternative 9: 75.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+48} \lor \neg \left(x \leq 1.65 \cdot 10^{+14}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;\left(-t\right) - \log y\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= x -1.55e+48) (not (<= x 1.65e+14)))
   (* x (log y))
   (- (- t) (log y))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -1.55e+48) || !(x <= 1.65e+14)) {
		tmp = x * log(y);
	} else {
		tmp = -t - log(y);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x <= (-1.55d+48)) .or. (.not. (x <= 1.65d+14))) then
        tmp = x * log(y)
    else
        tmp = -t - log(y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -1.55e+48) || !(x <= 1.65e+14)) {
		tmp = x * Math.log(y);
	} else {
		tmp = -t - Math.log(y);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x <= -1.55e+48) or not (x <= 1.65e+14):
		tmp = x * math.log(y)
	else:
		tmp = -t - math.log(y)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((x <= -1.55e+48) || !(x <= 1.65e+14))
		tmp = Float64(x * log(y));
	else
		tmp = Float64(Float64(-t) - log(y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((x <= -1.55e+48) || ~((x <= 1.65e+14)))
		tmp = x * log(y);
	else
		tmp = -t - log(y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.55e+48], N[Not[LessEqual[x, 1.65e+14]], $MachinePrecision]], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{+48} \lor \neg \left(x \leq 1.65 \cdot 10^{+14}\right):\\
\;\;\;\;x \cdot \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.55000000000000003e48 or 1.65e14 < x

    1. Initial program 95.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 y around 0 98.7%

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-1 \cdot y\right)}\right) - t \]
    3. Step-by-step derivation
      1. mul-1-neg98.7%

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

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

      \[\leadsto \color{blue}{x \cdot \log y} \]
    6. Step-by-step derivation
      1. *-commutative76.9%

        \[\leadsto \color{blue}{\log y \cdot x} \]
    7. Simplified76.9%

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

    if -1.55000000000000003e48 < x < 1.65e14

    1. Initial program 87.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 86.1%

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

      \[\leadsto \color{blue}{-1 \cdot \log y} - t \]
    4. Step-by-step derivation
      1. mul-1-neg83.1%

        \[\leadsto \color{blue}{\left(-\log y\right)} - t \]
    5. Simplified83.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+48} \lor \neg \left(x \leq 1.65 \cdot 10^{+14}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;\left(-t\right) - \log y\\ \end{array} \]

Alternative 10: 87.8% accurate, 2.0× speedup?

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

\\
\log y \cdot \left(-1 + x\right) - t
\end{array}
Derivation
  1. Initial program 91.2%

    \[\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 89.9%

    \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right) - t} \]
  3. Final simplification89.9%

    \[\leadsto \log y \cdot \left(-1 + x\right) - t \]

Alternative 11: 52.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -0.00245 \lor \neg \left(t \leq 5.2 \cdot 10^{-9}\right):\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;-\log y\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= t -0.00245) (not (<= t 5.2e-9))) (- t) (- (log y))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -0.00245) || !(t <= 5.2e-9)) {
		tmp = -t;
	} else {
		tmp = -log(y);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    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 <= (-0.00245d0)) .or. (.not. (t <= 5.2d-9))) then
        tmp = -t
    else
        tmp = -log(y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -0.00245) || !(t <= 5.2e-9)) {
		tmp = -t;
	} else {
		tmp = -Math.log(y);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (t <= -0.00245) or not (t <= 5.2e-9):
		tmp = -t
	else:
		tmp = -math.log(y)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((t <= -0.00245) || !(t <= 5.2e-9))
		tmp = Float64(-t);
	else
		tmp = Float64(-log(y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((t <= -0.00245) || ~((t <= 5.2e-9)))
		tmp = -t;
	else
		tmp = -log(y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -0.00245], N[Not[LessEqual[t, 5.2e-9]], $MachinePrecision]], (-t), (-N[Log[y], $MachinePrecision])]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -0.00245 \lor \neg \left(t \leq 5.2 \cdot 10^{-9}\right):\\
\;\;\;\;-t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -0.0024499999999999999 or 5.2000000000000002e-9 < t

    1. Initial program 92.8%

      \[\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 61.0%

      \[\leadsto \color{blue}{-1 \cdot t} \]
    3. Step-by-step derivation
      1. neg-mul-161.0%

        \[\leadsto \color{blue}{-t} \]
    4. Simplified61.0%

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

    if -0.0024499999999999999 < t < 5.2000000000000002e-9

    1. Initial program 89.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 y around 0 87.7%

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

      \[\leadsto \color{blue}{-1 \cdot \log y} - t \]
    4. Step-by-step derivation
      1. mul-1-neg43.2%

        \[\leadsto \color{blue}{\left(-\log y\right)} - t \]
    5. Simplified43.2%

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

      \[\leadsto \color{blue}{-1 \cdot \log y} \]
    7. Step-by-step derivation
      1. mul-1-neg43.1%

        \[\leadsto \color{blue}{-\log y} \]
    8. Simplified43.1%

      \[\leadsto \color{blue}{-\log y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification52.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -0.00245 \lor \neg \left(t \leq 5.2 \cdot 10^{-9}\right):\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;-\log y\\ \end{array} \]

Alternative 12: 43.6% accurate, 23.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -37000 \lor \neg \left(t \leq 30000000000000\right):\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;y - z \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= t -37000.0) (not (<= t 30000000000000.0))) (- t) (- y (* z y))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -37000.0) || !(t <= 30000000000000.0)) {
		tmp = -t;
	} else {
		tmp = y - (z * y);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    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 <= (-37000.0d0)) .or. (.not. (t <= 30000000000000.0d0))) then
        tmp = -t
    else
        tmp = y - (z * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -37000.0) || !(t <= 30000000000000.0)) {
		tmp = -t;
	} else {
		tmp = y - (z * y);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (t <= -37000.0) or not (t <= 30000000000000.0):
		tmp = -t
	else:
		tmp = y - (z * y)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((t <= -37000.0) || !(t <= 30000000000000.0))
		tmp = Float64(-t);
	else
		tmp = Float64(y - Float64(z * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((t <= -37000.0) || ~((t <= 30000000000000.0)))
		tmp = -t;
	else
		tmp = y - (z * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -37000.0], N[Not[LessEqual[t, 30000000000000.0]], $MachinePrecision]], (-t), N[(y - N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -37000 \lor \neg \left(t \leq 30000000000000\right):\\
\;\;\;\;-t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -37000 or 3e13 < t

    1. Initial program 95.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 t around inf 64.6%

      \[\leadsto \color{blue}{-1 \cdot t} \]
    3. Step-by-step derivation
      1. neg-mul-164.6%

        \[\leadsto \color{blue}{-t} \]
    4. Simplified64.6%

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

    if -37000 < t < 3e13

    1. Initial program 87.2%

      \[\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 99.0%

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-1 \cdot y\right)}\right) - t \]
    3. Step-by-step derivation
      1. mul-1-neg99.0%

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-y\right)}\right) - t \]
    5. Step-by-step derivation
      1. sub-neg99.0%

        \[\leadsto \left(\color{blue}{\left(x + \left(-1\right)\right)} \cdot \log y + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
      2. metadata-eval99.0%

        \[\leadsto \left(\left(x + \color{blue}{-1}\right) \cdot \log y + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
      3. expm1-log1p-u73.5%

        \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    6. Applied egg-rr73.5%

      \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    7. Taylor expanded in y around inf 15.9%

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot \left(z - 1\right)\right)} \]
    8. Step-by-step derivation
      1. mul-1-neg15.9%

        \[\leadsto \color{blue}{-y \cdot \left(z - 1\right)} \]
      2. sub-neg15.9%

        \[\leadsto -y \cdot \color{blue}{\left(z + \left(-1\right)\right)} \]
      3. metadata-eval15.9%

        \[\leadsto -y \cdot \left(z + \color{blue}{-1}\right) \]
      4. +-commutative15.9%

        \[\leadsto -y \cdot \color{blue}{\left(-1 + z\right)} \]
      5. *-commutative15.9%

        \[\leadsto -\color{blue}{\left(-1 + z\right) \cdot y} \]
      6. distribute-rgt-neg-in15.9%

        \[\leadsto \color{blue}{\left(-1 + z\right) \cdot \left(-y\right)} \]
    9. Simplified15.9%

      \[\leadsto \color{blue}{\left(-1 + z\right) \cdot \left(-y\right)} \]
    10. Taylor expanded in z around 0 15.9%

      \[\leadsto \color{blue}{y + -1 \cdot \left(y \cdot z\right)} \]
    11. Step-by-step derivation
      1. mul-1-neg15.9%

        \[\leadsto y + \color{blue}{\left(-y \cdot z\right)} \]
      2. unsub-neg15.9%

        \[\leadsto \color{blue}{y - y \cdot z} \]
    12. Simplified15.9%

      \[\leadsto \color{blue}{y - y \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -37000 \lor \neg \left(t \leq 30000000000000\right):\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;y - z \cdot y\\ \end{array} \]

Alternative 13: 43.3% accurate, 26.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -10200 \lor \neg \left(t \leq 30000000000000\right):\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= t -10200.0) (not (<= t 30000000000000.0))) (- t) (* z (- y))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -10200.0) || !(t <= 30000000000000.0)) {
		tmp = -t;
	} else {
		tmp = z * -y;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    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 <= (-10200.0d0)) .or. (.not. (t <= 30000000000000.0d0))) then
        tmp = -t
    else
        tmp = z * -y
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -10200.0) || !(t <= 30000000000000.0)) {
		tmp = -t;
	} else {
		tmp = z * -y;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (t <= -10200.0) or not (t <= 30000000000000.0):
		tmp = -t
	else:
		tmp = z * -y
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((t <= -10200.0) || !(t <= 30000000000000.0))
		tmp = Float64(-t);
	else
		tmp = Float64(z * Float64(-y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((t <= -10200.0) || ~((t <= 30000000000000.0)))
		tmp = -t;
	else
		tmp = z * -y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -10200.0], N[Not[LessEqual[t, 30000000000000.0]], $MachinePrecision]], (-t), N[(z * (-y)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -10200 \lor \neg \left(t \leq 30000000000000\right):\\
\;\;\;\;-t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -10200 or 3e13 < t

    1. Initial program 95.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 t around inf 64.6%

      \[\leadsto \color{blue}{-1 \cdot t} \]
    3. Step-by-step derivation
      1. neg-mul-164.6%

        \[\leadsto \color{blue}{-t} \]
    4. Simplified64.6%

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

    if -10200 < t < 3e13

    1. Initial program 87.2%

      \[\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 99.0%

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-1 \cdot y\right)}\right) - t \]
    3. Step-by-step derivation
      1. mul-1-neg99.0%

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg15.3%

        \[\leadsto \color{blue}{-y \cdot z} \]
      2. *-commutative15.3%

        \[\leadsto -\color{blue}{z \cdot y} \]
      3. distribute-rgt-neg-in15.3%

        \[\leadsto \color{blue}{z \cdot \left(-y\right)} \]
    7. Simplified15.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -10200 \lor \neg \left(t \leq 30000000000000\right):\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \end{array} \]

Alternative 14: 35.9% accurate, 107.5× 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;
}
real(8) function code(x, y, z, t)
    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 91.2%

    \[\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 34.3%

    \[\leadsto \color{blue}{-1 \cdot t} \]
  3. Step-by-step derivation
    1. neg-mul-134.3%

      \[\leadsto \color{blue}{-t} \]
  4. Simplified34.3%

    \[\leadsto \color{blue}{-t} \]
  5. Final simplification34.3%

    \[\leadsto -t \]

Alternative 15: 2.9% accurate, 215.0× speedup?

\[\begin{array}{l} \\ y \end{array} \]
(FPCore (x y z t) :precision binary64 y)
double code(double x, double y, double z, double t) {
	return y;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = y
end function
public static double code(double x, double y, double z, double t) {
	return y;
}
def code(x, y, z, t):
	return y
function code(x, y, z, t)
	return y
end
function tmp = code(x, y, z, t)
	tmp = y;
end
code[x_, y_, z_, t_] := y
\begin{array}{l}

\\
y
\end{array}
Derivation
  1. Initial program 91.2%

    \[\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 99.1%

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

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

    \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(-y\right)}\right) - t \]
  5. Step-by-step derivation
    1. sub-neg99.1%

      \[\leadsto \left(\color{blue}{\left(x + \left(-1\right)\right)} \cdot \log y + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    2. metadata-eval99.1%

      \[\leadsto \left(\left(x + \color{blue}{-1}\right) \cdot \log y + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
    3. expm1-log1p-u72.6%

      \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
  6. Applied egg-rr72.6%

    \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(x + -1\right) \cdot \log y\right)\right)} + \left(z - 1\right) \cdot \left(-y\right)\right) - t \]
  7. Taylor expanded in y around inf 11.4%

    \[\leadsto \color{blue}{-1 \cdot \left(y \cdot \left(z - 1\right)\right)} \]
  8. Step-by-step derivation
    1. mul-1-neg11.4%

      \[\leadsto \color{blue}{-y \cdot \left(z - 1\right)} \]
    2. sub-neg11.4%

      \[\leadsto -y \cdot \color{blue}{\left(z + \left(-1\right)\right)} \]
    3. metadata-eval11.4%

      \[\leadsto -y \cdot \left(z + \color{blue}{-1}\right) \]
    4. +-commutative11.4%

      \[\leadsto -y \cdot \color{blue}{\left(-1 + z\right)} \]
    5. *-commutative11.4%

      \[\leadsto -\color{blue}{\left(-1 + z\right) \cdot y} \]
    6. distribute-rgt-neg-in11.4%

      \[\leadsto \color{blue}{\left(-1 + z\right) \cdot \left(-y\right)} \]
  9. Simplified11.4%

    \[\leadsto \color{blue}{\left(-1 + z\right) \cdot \left(-y\right)} \]
  10. Taylor expanded in z around 0 2.8%

    \[\leadsto \color{blue}{y} \]
  11. Final simplification2.8%

    \[\leadsto y \]

Reproduce

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