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

Percentage Accurate: 89.0% → 99.8%
Time: 14.6s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 89.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.5% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 x #s(literal 1 binary64)) < -3.99999999999999983e28 or -0.5 < (-.f64 x #s(literal 1 binary64))

    1. Initial program 92.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.99999999999999983e28 < (-.f64 x #s(literal 1 binary64)) < -0.5

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot \log y - y \cdot \left(z - 1\right)\right)} - t \]
    10. Step-by-step derivation
      1. sub-neg97.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-1 + x \leq -4 \cdot 10^{+28} \lor \neg \left(-1 + x \leq -0.5\right):\\ \;\;\;\;\left(\log y \cdot x - y \cdot \left(-1 + z\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(1 - z\right) - \log y\right) - t\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 95.0% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 x #s(literal 1 binary64)) < -1.0000000099999999 or 5.0000000000000001e29 < (-.f64 x #s(literal 1 binary64))

    1. Initial program 93.6%

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

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

    if -1.0000000099999999 < (-.f64 x #s(literal 1 binary64)) < 5.0000000000000001e29

    1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-1 + x \leq -1.00000001 \lor \neg \left(-1 + x \leq 5 \cdot 10^{+29}\right):\\ \;\;\;\;\log y \cdot \left(-1 + x\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \left(1 - z\right) - \log y\right) - t\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 88.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{+176} \lor \neg \left(z \leq 1.55 \cdot 10^{+133}\right):\\ \;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot \left(-1 + x\right) - t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -1.7e+176) (not (<= z 1.55e+133)))
   (- (* (log1p (- y)) z) t)
   (- (* (log y) (+ -1.0 x)) t)))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -1.7e+176) || !(z <= 1.55e+133)) {
		tmp = (log1p(-y) * z) - t;
	} else {
		tmp = (log(y) * (-1.0 + x)) - t;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -1.7e+176) || !(z <= 1.55e+133)) {
		tmp = (Math.log1p(-y) * z) - t;
	} else {
		tmp = (Math.log(y) * (-1.0 + x)) - t;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z <= -1.7e+176) or not (z <= 1.55e+133):
		tmp = (math.log1p(-y) * z) - t
	else:
		tmp = (math.log(y) * (-1.0 + x)) - t
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -1.7e+176) || !(z <= 1.55e+133))
		tmp = Float64(Float64(log1p(Float64(-y)) * z) - t);
	else
		tmp = Float64(Float64(log(y) * Float64(-1.0 + x)) - t);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.7e+176], N[Not[LessEqual[z, 1.55e+133]], $MachinePrecision]], N[(N[(N[Log[1 + (-y)], $MachinePrecision] * z), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * N[(-1.0 + x), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{+176} \lor \neg \left(z \leq 1.55 \cdot 10^{+133}\right):\\
\;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.70000000000000007e176 or 1.55e133 < z

    1. Initial program 53.7%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right)} \cdot z - t \]
    5. Simplified82.2%

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

    if -1.70000000000000007e176 < z < 1.55e133

    1. Initial program 98.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{+176} \lor \neg \left(z \leq 1.55 \cdot 10^{+133}\right):\\ \;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot \left(-1 + x\right) - t\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 99.1% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 46.1% accurate, 2.0× speedup?

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right)} \cdot z - t \]
  5. Simplified49.1%

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

Alternative 8: 45.9% accurate, 12.6× speedup?

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right)} \cdot z - t \]
  5. Simplified49.1%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right) \cdot z} - t \]
  6. Taylor expanded in y around 0 48.9%

    \[\leadsto \color{blue}{y \cdot \left(-1 \cdot z + y \cdot \left(-0.5 \cdot z + -0.3333333333333333 \cdot \left(y \cdot z\right)\right)\right) - t} \]
  7. Final simplification48.9%

    \[\leadsto y \cdot \left(y \cdot \left(z \cdot -0.5 + -0.3333333333333333 \cdot \left(y \cdot z\right)\right) - z\right) - t \]
  8. Add Preprocessing

Alternative 9: 42.2% accurate, 15.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -0.00104999999999999994 or 1.75e7 < t

    1. Initial program 94.1%

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

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

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

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

    if -0.00104999999999999994 < t < 1.75e7

    1. Initial program 80.7%

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

      \[\leadsto \color{blue}{z \cdot \log \left(1 - y\right)} - t \]
    4. Step-by-step derivation
      1. *-commutative4.0%

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right)} \cdot z - t \]
    5. Simplified21.0%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right) \cdot z} - t \]
    6. Taylor expanded in y around 0 20.4%

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

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

        \[\leadsto \color{blue}{y \cdot \left(-z\right)} - t \]
    8. Simplified20.4%

      \[\leadsto \color{blue}{y \cdot \left(-z\right) - t} \]
    9. Taylor expanded in y around inf 20.2%

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

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

        \[\leadsto \color{blue}{y \cdot \left(-z\right)} \]
    11. Simplified20.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -0.00105 \lor \neg \left(t \leq 17500000\right):\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;\left(-y\right) \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 45.8% accurate, 19.5× speedup?

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right)} \cdot z - t \]
  5. Simplified49.1%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right) \cdot z} - t \]
  6. Taylor expanded in y around 0 48.9%

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

    \[\leadsto y \cdot \left(-0.5 \cdot \left(y \cdot z\right) - z\right) - t \]
  8. Add Preprocessing

Alternative 11: 45.7% 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 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 45.5% accurate, 35.8× speedup?

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right)} \cdot z - t \]
  5. Simplified49.1%

    \[\leadsto \color{blue}{\mathsf{log1p}\left(-y\right) \cdot z} - t \]
  6. Taylor expanded in y around 0 48.5%

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

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

      \[\leadsto \color{blue}{y \cdot \left(-z\right)} - t \]
  8. Simplified48.5%

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

    \[\leadsto \left(-y\right) \cdot z - t \]
  10. Add Preprocessing

Alternative 13: 34.9% accurate, 107.5× speedup?

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

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

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

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

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

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

Reproduce

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