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

Percentage Accurate: 89.4% → 99.8%
Time: 19.2s
Alternatives: 9
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 9 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.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 88.2% accurate, 1.7× speedup?

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

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

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


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

    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. Add Preprocessing
    3. Taylor expanded in y around 0 88.6%

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

    if -1 < (-.f64 x 1) < 2e9

    1. Initial program 78.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 86.6% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 94.5%

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

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

        \[\leadsto \color{blue}{\left(x - 1\right) \cdot \log y} - t \]
      2. add-cube-cbrt92.9%

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

        \[\leadsto \color{blue}{{\left(\sqrt[3]{\left(x - 1\right) \cdot \log y}\right)}^{3}} - t \]
      4. sub-neg92.9%

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

        \[\leadsto {\left(\sqrt[3]{\left(x + \color{blue}{-1}\right) \cdot \log y}\right)}^{3} - t \]
    5. Applied egg-rr92.9%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\left(x + -1\right) \cdot \log y}\right)}^{3}} - t \]
    6. Step-by-step derivation
      1. unpow392.9%

        \[\leadsto \color{blue}{\left(\sqrt[3]{\left(x + -1\right) \cdot \log y} \cdot \sqrt[3]{\left(x + -1\right) \cdot \log y}\right) \cdot \sqrt[3]{\left(x + -1\right) \cdot \log y}} - t \]
      2. add-cube-cbrt94.0%

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

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

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

        \[\leadsto \log y \cdot \frac{\color{blue}{{x}^{2}} - -1 \cdot -1}{x - -1} - t \]
      6. metadata-eval52.7%

        \[\leadsto \log y \cdot \frac{{x}^{2} - \color{blue}{1}}{x - -1} - t \]
      7. sub-neg52.7%

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

        \[\leadsto \log y \cdot \frac{{x}^{2} - 1}{x + \color{blue}{1}} - t \]
      9. +-commutative52.7%

        \[\leadsto \log y \cdot \frac{{x}^{2} - 1}{\color{blue}{1 + x}} - t \]
      10. clear-num52.6%

        \[\leadsto \log y \cdot \color{blue}{\frac{1}{\frac{1 + x}{{x}^{2} - 1}}} - t \]
      11. div-inv52.7%

        \[\leadsto \color{blue}{\frac{\log y}{\frac{1 + x}{{x}^{2} - 1}}} - t \]
      12. clear-num52.7%

        \[\leadsto \frac{\log y}{\color{blue}{\frac{1}{\frac{{x}^{2} - 1}{1 + x}}}} - t \]
      13. unpow252.7%

        \[\leadsto \frac{\log y}{\frac{1}{\frac{\color{blue}{x \cdot x} - 1}{1 + x}}} - t \]
      14. metadata-eval52.7%

        \[\leadsto \frac{\log y}{\frac{1}{\frac{x \cdot x - \color{blue}{-1 \cdot -1}}{1 + x}}} - t \]
      15. +-commutative52.7%

        \[\leadsto \frac{\log y}{\frac{1}{\frac{x \cdot x - -1 \cdot -1}{\color{blue}{x + 1}}}} - t \]
      16. metadata-eval52.7%

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

        \[\leadsto \frac{\log y}{\frac{1}{\frac{x \cdot x - -1 \cdot -1}{\color{blue}{x - -1}}}} - t \]
      18. flip-+94.0%

        \[\leadsto \frac{\log y}{\frac{1}{\color{blue}{x + -1}}} - t \]
    7. Applied egg-rr94.0%

      \[\leadsto \color{blue}{\frac{\log y}{\frac{1}{x + -1}}} - t \]
    8. Taylor expanded in x around inf 93.9%

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

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

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

    if -1 < x < 5.7999999999999998e-40

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

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

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

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

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

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

Alternative 4: 76.1% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.25 \cdot 10^{+55} \lor \neg \left(x \leq 4.6 \cdot 10^{+19}\right):\\
\;\;\;\;x \cdot \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.24999999999999999e55 or 4.6e19 < x

    1. Initial program 96.5%

      \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip3--96.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\log \left(1 + \left(y \cdot y\right) \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)}\right) - \log \left(1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)\right)\right)\right) - t \]
      11. add-sqr-sqrt96.5%

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

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

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

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\mathsf{log1p}\left(\left(y \cdot y\right) \cdot y\right) - \color{blue}{\mathsf{log1p}\left(y \cdot y + 1 \cdot y\right)}\right)\right) - t \]
      15. *-un-lft-identity99.6%

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

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

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

        \[\leadsto \color{blue}{\log y \cdot x} \]
    7. Simplified78.4%

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

    if -2.24999999999999999e55 < x < 4.6e19

    1. Initial program 84.5%

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

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

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

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

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

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

Alternative 5: 58.3% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -4 \cdot 10^{+41} \lor \neg \left(t \leq 1.45 \cdot 10^{+15}\right):\\
\;\;\;\;-t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -4.00000000000000002e41 or 1.45e15 < t

    1. Initial program 98.5%

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

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

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

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

    if -4.00000000000000002e41 < t < 1.45e15

    1. Initial program 82.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. Step-by-step derivation
      1. flip3--82.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\log \left(1 + \left(y \cdot y\right) \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)}\right) - \log \left(1 \cdot 1 + \left(y \cdot y + 1 \cdot y\right)\right)\right)\right) - t \]
      11. add-sqr-sqrt81.7%

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

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

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

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\mathsf{log1p}\left(\left(y \cdot y\right) \cdot y\right) - \color{blue}{\mathsf{log1p}\left(y \cdot y + 1 \cdot y\right)}\right)\right) - t \]
      15. *-un-lft-identity99.2%

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

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

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

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

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

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

Alternative 6: 99.2% 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 89.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 y around 0 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 88.4% 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 89.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 y around 0 88.4%

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

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

Alternative 8: 42.4% accurate, 15.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.2 \cdot 10^{+34} \lor \neg \left(t \leq 270\right):\\
\;\;\;\;-t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -7.2000000000000001e34 or 270 < t

    1. Initial program 98.4%

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

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

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

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

    if -7.2000000000000001e34 < t < 270

    1. Initial program 81.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 35.5% 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 89.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 t around inf 38.4%

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

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

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

    \[\leadsto -t \]
  7. Add Preprocessing

Reproduce

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