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

Percentage Accurate: 89.0% → 99.8%
Time: 12.6s
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{log1p}\left(-y\right) \cdot \left(z + -1\right) - \mathsf{fma}\left(\log y, 1 - x, t\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (- (* (log1p (- y)) (+ z -1.0)) (fma (log y) (- 1.0 x) t)))
double code(double x, double y, double z, double t) {
	return (log1p(-y) * (z + -1.0)) - fma(log(y), (1.0 - x), t);
}
function code(x, y, z, t)
	return Float64(Float64(log1p(Float64(-y)) * Float64(z + -1.0)) - fma(log(y), Float64(1.0 - x), t))
end
code[x_, y_, z_, t_] := N[(N[(N[Log[1 + (-y)], $MachinePrecision] * N[(z + -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(1.0 - x), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\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. associate--l+91.3%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \left(\left(-\color{blue}{\log y \cdot \left(x - 1\right)}\right) + t\right) \]
    13. distribute-rgt-neg-in99.8%

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

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

      \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \mathsf{fma}\left(\log y, \color{blue}{0 - \left(x - 1\right)}, t\right) \]
    16. associate--r-99.8%

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

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

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

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

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

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

Alternative 2: 99.1% accurate, 1.0× speedup?

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

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

    \[\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. associate--l+91.3%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \left(\left(-\color{blue}{\log y \cdot \left(x - 1\right)}\right) + t\right) \]
    13. distribute-rgt-neg-in99.8%

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

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

      \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \mathsf{fma}\left(\log y, \color{blue}{0 - \left(x - 1\right)}, t\right) \]
    16. associate--r-99.8%

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \left(\left(z - 1\right) \cdot y\right)} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
  5. Step-by-step derivation
    1. associate-*r*99.5%

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

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

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

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

      \[\leadsto y \cdot \left(-1 \cdot \color{blue}{\left(-1 + z\right)}\right) - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
    6. distribute-lft-in99.5%

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

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

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

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

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

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

Alternative 3: 95.3% accurate, 1.8× speedup?

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

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

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

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


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

    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 94.0%

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

    if -500 < (-.f64 x 1) < 4e15

    1. Initial program 86.0%

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

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

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

        \[\leadsto \color{blue}{\left(\left(z - 1\right) \cdot \log \left(1 - y\right) - \log y\right)} - t \]
      3. *-commutative85.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(\left(z - 1\right) \cdot y\right) - \log y\right)} - t \]
      3. associate-*r*98.9%

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

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

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

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

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

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

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

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

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

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

    if 4e15 < (-.f64 x 1)

    1. Initial program 99.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.6%

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

      \[\leadsto \color{blue}{\log y \cdot x} - t \]
  3. Recombined 3 regimes into one program.
  4. Final simplification97.6%

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

Alternative 4: 64.2% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := -\log y\\ t_2 := \log y \cdot x\\ t_3 := y \cdot \left(1 - z\right) - t\\ \mathbf{if}\;x \leq -65000000000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-216}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-295}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-140}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{+21}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (log y))) (t_2 (* (log y) x)) (t_3 (- (* y (- 1.0 z)) t)))
   (if (<= x -65000000000000.0)
     t_2
     (if (<= x -1.35e-216)
       t_3
       (if (<= x -1.9e-295)
         t_1
         (if (<= x 2.2e-140)
           t_3
           (if (<= x 1.8e-98) t_1 (if (<= x 1.8e+21) t_3 t_2))))))))
double code(double x, double y, double z, double t) {
	double t_1 = -log(y);
	double t_2 = log(y) * x;
	double t_3 = (y * (1.0 - z)) - t;
	double tmp;
	if (x <= -65000000000000.0) {
		tmp = t_2;
	} else if (x <= -1.35e-216) {
		tmp = t_3;
	} else if (x <= -1.9e-295) {
		tmp = t_1;
	} else if (x <= 2.2e-140) {
		tmp = t_3;
	} else if (x <= 1.8e-98) {
		tmp = t_1;
	} else if (x <= 1.8e+21) {
		tmp = t_3;
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_1 = -log(y)
    t_2 = log(y) * x
    t_3 = (y * (1.0d0 - z)) - t
    if (x <= (-65000000000000.0d0)) then
        tmp = t_2
    else if (x <= (-1.35d-216)) then
        tmp = t_3
    else if (x <= (-1.9d-295)) then
        tmp = t_1
    else if (x <= 2.2d-140) then
        tmp = t_3
    else if (x <= 1.8d-98) then
        tmp = t_1
    else if (x <= 1.8d+21) then
        tmp = t_3
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = -Math.log(y);
	double t_2 = Math.log(y) * x;
	double t_3 = (y * (1.0 - z)) - t;
	double tmp;
	if (x <= -65000000000000.0) {
		tmp = t_2;
	} else if (x <= -1.35e-216) {
		tmp = t_3;
	} else if (x <= -1.9e-295) {
		tmp = t_1;
	} else if (x <= 2.2e-140) {
		tmp = t_3;
	} else if (x <= 1.8e-98) {
		tmp = t_1;
	} else if (x <= 1.8e+21) {
		tmp = t_3;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = -math.log(y)
	t_2 = math.log(y) * x
	t_3 = (y * (1.0 - z)) - t
	tmp = 0
	if x <= -65000000000000.0:
		tmp = t_2
	elif x <= -1.35e-216:
		tmp = t_3
	elif x <= -1.9e-295:
		tmp = t_1
	elif x <= 2.2e-140:
		tmp = t_3
	elif x <= 1.8e-98:
		tmp = t_1
	elif x <= 1.8e+21:
		tmp = t_3
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	t_1 = Float64(-log(y))
	t_2 = Float64(log(y) * x)
	t_3 = Float64(Float64(y * Float64(1.0 - z)) - t)
	tmp = 0.0
	if (x <= -65000000000000.0)
		tmp = t_2;
	elseif (x <= -1.35e-216)
		tmp = t_3;
	elseif (x <= -1.9e-295)
		tmp = t_1;
	elseif (x <= 2.2e-140)
		tmp = t_3;
	elseif (x <= 1.8e-98)
		tmp = t_1;
	elseif (x <= 1.8e+21)
		tmp = t_3;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = -log(y);
	t_2 = log(y) * x;
	t_3 = (y * (1.0 - z)) - t;
	tmp = 0.0;
	if (x <= -65000000000000.0)
		tmp = t_2;
	elseif (x <= -1.35e-216)
		tmp = t_3;
	elseif (x <= -1.9e-295)
		tmp = t_1;
	elseif (x <= 2.2e-140)
		tmp = t_3;
	elseif (x <= 1.8e-98)
		tmp = t_1;
	elseif (x <= 1.8e+21)
		tmp = t_3;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = (-N[Log[y], $MachinePrecision])}, Block[{t$95$2 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -65000000000000.0], t$95$2, If[LessEqual[x, -1.35e-216], t$95$3, If[LessEqual[x, -1.9e-295], t$95$1, If[LessEqual[x, 2.2e-140], t$95$3, If[LessEqual[x, 1.8e-98], t$95$1, If[LessEqual[x, 1.8e+21], t$95$3, t$95$2]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.35 \cdot 10^{-216}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;x \leq -1.9 \cdot 10^{-295}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{-140}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;x \leq 1.8 \cdot 10^{-98}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.8 \cdot 10^{+21}:\\
\;\;\;\;t_3\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.5e13 or 1.8e21 < x

    1. Initial program 96.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 96.2%

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

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

    if -6.5e13 < x < -1.35e-216 or -1.90000000000000009e-295 < x < 2.1999999999999999e-140 or 1.8000000000000001e-98 < x < 1.8e21

    1. Initial program 85.5%

      \[\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. associate--l+85.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \color{blue}{\left(\left(-\left(x - 1\right) \cdot \log y\right) + t\right)} \]
      12. *-commutative100.0%

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \left(\left(-\color{blue}{\log y \cdot \left(x - 1\right)}\right) + t\right) \]
      13. distribute-rgt-neg-in100.0%

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \mathsf{fma}\left(\log y, \color{blue}{0 - \left(x - 1\right)}, t\right) \]
      16. associate--r-100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\left(z - 1\right) \cdot y\right)} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
    5. Step-by-step derivation
      1. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(z - 1\right)\right) \cdot y} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{y \cdot \left(-1 \cdot \left(z - 1\right)\right)} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
      3. sub-neg100.0%

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

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

        \[\leadsto y \cdot \left(-1 \cdot \color{blue}{\left(-1 + z\right)}\right) - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
      6. distribute-lft-in100.0%

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

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

        \[\leadsto y \cdot \left(1 + \color{blue}{\left(-z\right)}\right) - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
      9. unsub-neg100.0%

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

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

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

    if -1.35e-216 < x < -1.90000000000000009e-295 or 2.1999999999999999e-140 < x < 1.8000000000000001e-98

    1. Initial program 91.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 x around 0 91.4%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(-1 \cdot y\right)} \cdot \left(z + -1\right) - \log y\right) - t \]
      9. mul-1-neg100.0%

        \[\leadsto \left(\mathsf{log1p}\left(\color{blue}{-y}\right) \cdot \left(z + -1\right) - \log y\right) - t \]
      10. +-commutative100.0%

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

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

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

        \[\leadsto \color{blue}{\left(-\log y\right)} - t \]
    7. Simplified88.6%

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

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

        \[\leadsto \color{blue}{-\log y} \]
    10. Simplified75.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -65000000000000:\\ \;\;\;\;\log y \cdot x\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-216}:\\ \;\;\;\;y \cdot \left(1 - z\right) - t\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-295}:\\ \;\;\;\;-\log y\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-140}:\\ \;\;\;\;y \cdot \left(1 - z\right) - t\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-98}:\\ \;\;\;\;-\log y\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{+21}:\\ \;\;\;\;y \cdot \left(1 - z\right) - t\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot x\\ \end{array} \]

Alternative 5: 75.8% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 94.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 93.9%

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

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

    if -4e3 < (-.f64 x 1) < 1e17

    1. Initial program 86.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 x around 0 85.1%

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

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

        \[\leadsto \color{blue}{\left(\left(z - 1\right) \cdot \log \left(1 - y\right) - \log y\right)} - t \]
      3. *-commutative85.1%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(-1 \cdot y\right)} \cdot \left(z + -1\right) - \log y\right) - t \]
      9. mul-1-neg98.8%

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

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

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

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

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

        \[\leadsto \left(\left(-\log \color{blue}{\left(1 + \left(-y\right)\right)}\right) - \log y\right) - t \]
      3. log1p-def85.1%

        \[\leadsto \left(\left(-\color{blue}{\mathsf{log1p}\left(-y\right)}\right) - \log y\right) - t \]
    7. Simplified85.1%

      \[\leadsto \color{blue}{\left(\left(-\mathsf{log1p}\left(-y\right)\right) - \log y\right)} - t \]
    8. Taylor expanded in y around 0 84.7%

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

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

        \[\leadsto y + \left(-\color{blue}{\left(\log y + t\right)}\right) \]
      3. unsub-neg84.7%

        \[\leadsto \color{blue}{y - \left(\log y + t\right)} \]
    10. Simplified84.7%

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

    if 1e17 < (-.f64 x 1)

    1. Initial program 99.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.6%

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

      \[\leadsto \color{blue}{\log y \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.2%

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

Alternative 6: 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.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.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 75.1% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;x \leq 2.35 \cdot 10^{-172}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;x \leq 2.8 \cdot 10^{+19}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2e13 or 2.8e19 < x

    1. Initial program 96.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 96.2%

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

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

    if -2e13 < x < 2.34999999999999988e-172 or 4.1e-142 < x < 2.8e19

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

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

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

        \[\leadsto \color{blue}{\left(\left(z - 1\right) \cdot \log \left(1 - y\right) - \log y\right)} - t \]
      3. *-commutative86.9%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(-1 \cdot y\right)} \cdot \left(z + -1\right) - \log y\right) - t \]
      9. mul-1-neg97.3%

        \[\leadsto \left(\mathsf{log1p}\left(\color{blue}{-y}\right) \cdot \left(z + -1\right) - \log y\right) - t \]
      10. +-commutative97.3%

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

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

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

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

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

    if 2.34999999999999988e-172 < x < 4.1e-142

    1. Initial program 52.9%

      \[\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. associate--l+52.9%

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

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

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

        \[\leadsto \color{blue}{\log \left(1 - y\right) \cdot \left(z - 1\right)} - \left(t - \left(x - 1\right) \cdot \log y\right) \]
      5. *-commutative52.9%

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

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

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

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

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \color{blue}{\left(\left(-\left(x - 1\right) \cdot \log y\right) + t\right)} \]
      12. *-commutative100.0%

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \left(\left(-\color{blue}{\log y \cdot \left(x - 1\right)}\right) + t\right) \]
      13. distribute-rgt-neg-in100.0%

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \mathsf{fma}\left(\log y, \color{blue}{0 - \left(x - 1\right)}, t\right) \]
      16. associate--r-100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\left(z - 1\right) \cdot y\right)} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
    5. Step-by-step derivation
      1. associate-*r*100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot \left(z - 1\right)\right) \cdot y} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
      2. *-commutative100.0%

        \[\leadsto \color{blue}{y \cdot \left(-1 \cdot \left(z - 1\right)\right)} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
      3. sub-neg100.0%

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

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

        \[\leadsto y \cdot \left(-1 \cdot \color{blue}{\left(-1 + z\right)}\right) - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
      6. distribute-lft-in100.0%

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

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

        \[\leadsto y \cdot \left(1 + \color{blue}{\left(-z\right)}\right) - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
      9. unsub-neg100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -20000000000000:\\ \;\;\;\;\log y \cdot x\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{-172}:\\ \;\;\;\;\left(-t\right) - \log y\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{-142}:\\ \;\;\;\;y \cdot \left(1 - z\right) - t\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{+19}:\\ \;\;\;\;\left(-t\right) - \log y\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot x\\ \end{array} \]

Alternative 8: 75.7% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 94.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 93.9%

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

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

    if -4e3 < (-.f64 x 1) < 1e17

    1. Initial program 86.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 x around 0 85.1%

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

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

        \[\leadsto \color{blue}{\left(\left(z - 1\right) \cdot \log \left(1 - y\right) - \log y\right)} - t \]
      3. *-commutative85.1%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(-1 \cdot y\right)} \cdot \left(z + -1\right) - \log y\right) - t \]
      9. mul-1-neg98.8%

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

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

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

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

        \[\leadsto \color{blue}{\left(-\log y\right)} - t \]
    7. Simplified84.6%

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

    if 1e17 < (-.f64 x 1)

    1. Initial program 99.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.6%

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

      \[\leadsto \color{blue}{\log y \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.1%

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

Alternative 9: 86.9% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -14000 \lor \neg \left(t \leq 320\right):\\
\;\;\;\;\log y \cdot x - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -14000 or 320 < t

    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 94.8%

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

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

    if -14000 < t < 320

    1. Initial program 88.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -14000 \lor \neg \left(t \leq 320\right):\\ \;\;\;\;\log y \cdot x - t\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot \left(-1 + x\right)\\ \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.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 90.9%

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

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

Alternative 11: 54.2% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.05 \cdot 10^{-53} \lor \neg \left(t \leq 3.5 \cdot 10^{-33}\right):\\
\;\;\;\;y \cdot \left(1 - z\right) - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.04999999999999989e-53 or 3.4999999999999999e-33 < t

    1. Initial program 93.3%

      \[\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. associate--l+93.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \left(\left(-\color{blue}{\log y \cdot \left(x - 1\right)}\right) + t\right) \]
      13. distribute-rgt-neg-in99.8%

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \mathsf{fma}\left(\log y, \color{blue}{0 - \left(x - 1\right)}, t\right) \]
      16. associate--r-99.8%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\left(z - 1\right) \cdot y\right)} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
    5. Step-by-step derivation
      1. associate-*r*99.8%

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

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

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

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

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

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

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

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

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

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

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

    if -1.04999999999999989e-53 < t < 3.4999999999999999e-33

    1. Initial program 89.0%

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

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

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

        \[\leadsto \color{blue}{\left(\left(z - 1\right) \cdot \log \left(1 - y\right) - \log y\right)} - t \]
      3. *-commutative43.6%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\mathsf{log1p}\left(-1 \cdot y\right)} \cdot \left(z + -1\right) - \log y\right) - t \]
      9. mul-1-neg54.3%

        \[\leadsto \left(\mathsf{log1p}\left(\color{blue}{-y}\right) \cdot \left(z + -1\right) - \log y\right) - t \]
      10. +-commutative54.3%

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

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

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

        \[\leadsto \color{blue}{\left(-\log y\right)} - t \]
    7. Simplified42.6%

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

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

        \[\leadsto \color{blue}{-\log y} \]
    10. Simplified42.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.05 \cdot 10^{-53} \lor \neg \left(t \leq 3.5 \cdot 10^{-33}\right):\\ \;\;\;\;y \cdot \left(1 - z\right) - t\\ \mathbf{else}:\\ \;\;\;\;-\log y\\ \end{array} \]

Alternative 12: 43.5% accurate, 23.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -9 \cdot 10^{-35}:\\
\;\;\;\;-t\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -9.0000000000000002e-35 or 320 < t

    1. Initial program 95.0%

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

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

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

        \[\leadsto \color{blue}{-t} \]
    5. Simplified62.5%

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

    if -9.0000000000000002e-35 < t < 320

    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. Step-by-step derivation
      1. associate--l+87.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \left(\left(-\color{blue}{\log y \cdot \left(x - 1\right)}\right) + t\right) \]
      13. distribute-rgt-neg-in99.8%

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \mathsf{fma}\left(\log y, \color{blue}{0 - \left(x - 1\right)}, t\right) \]
      16. associate--r-99.8%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\left(z - 1\right) \cdot y\right)} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
    5. Step-by-step derivation
      1. associate-*r*99.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto y \cdot \left(1 - z\right) - \color{blue}{-1 \cdot \left(\log y \cdot x\right)} \]
    8. Step-by-step derivation
      1. associate-*r*62.0%

        \[\leadsto y \cdot \left(1 - z\right) - \color{blue}{\left(-1 \cdot \log y\right) \cdot x} \]
      2. mul-1-neg62.0%

        \[\leadsto y \cdot \left(1 - z\right) - \color{blue}{\left(-\log y\right)} \cdot x \]
    9. Simplified62.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -9 \cdot 10^{-35}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 320:\\ \;\;\;\;y \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]

Alternative 13: 43.2% accurate, 26.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.42 \cdot 10^{-34}:\\
\;\;\;\;-t\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.42000000000000003e-34 or 320 < t

    1. Initial program 95.0%

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

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

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

        \[\leadsto \color{blue}{-t} \]
    5. Simplified62.5%

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

    if -1.42000000000000003e-34 < t < 320

    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. Step-by-step derivation
      1. associate--l+87.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \left(\left(-\color{blue}{\log y \cdot \left(x - 1\right)}\right) + t\right) \]
      13. distribute-rgt-neg-in99.8%

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

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

        \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \mathsf{fma}\left(\log y, \color{blue}{0 - \left(x - 1\right)}, t\right) \]
      16. associate--r-99.8%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(\left(z - 1\right) \cdot y\right)} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
    5. Step-by-step derivation
      1. associate-*r*99.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto y \cdot \left(1 - z\right) - \color{blue}{-1 \cdot \left(\log y \cdot x\right)} \]
    8. Step-by-step derivation
      1. associate-*r*62.0%

        \[\leadsto y \cdot \left(1 - z\right) - \color{blue}{\left(-1 \cdot \log y\right) \cdot x} \]
      2. mul-1-neg62.0%

        \[\leadsto y \cdot \left(1 - z\right) - \color{blue}{\left(-\log y\right)} \cdot x \]
    9. Simplified62.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.42 \cdot 10^{-34}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 320:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]

Alternative 14: 46.5% accurate, 30.7× speedup?

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

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

    \[\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. associate--l+91.3%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \left(\left(-\color{blue}{\log y \cdot \left(x - 1\right)}\right) + t\right) \]
    13. distribute-rgt-neg-in99.8%

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

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

      \[\leadsto \left(z + -1\right) \cdot \mathsf{log1p}\left(-y\right) - \mathsf{fma}\left(\log y, \color{blue}{0 - \left(x - 1\right)}, t\right) \]
    16. associate--r-99.8%

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \left(\left(z - 1\right) \cdot y\right)} - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
  5. Step-by-step derivation
    1. associate-*r*99.5%

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

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

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

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

      \[\leadsto y \cdot \left(-1 \cdot \color{blue}{\left(-1 + z\right)}\right) - \mathsf{fma}\left(\log y, 1 - x, t\right) \]
    6. distribute-lft-in99.5%

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

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

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

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

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

    \[\leadsto y \cdot \left(1 - z\right) - \color{blue}{t} \]
  8. Final simplification42.9%

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

Alternative 15: 35.8% 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.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 90.9%

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

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

      \[\leadsto \color{blue}{-t} \]
  5. Simplified34.1%

    \[\leadsto \color{blue}{-t} \]
  6. Final simplification34.1%

    \[\leadsto -t \]

Reproduce

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