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

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

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

    \[\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. +-commutative91.1%

      \[\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-def91.1%

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

      \[\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-eval91.1%

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

      \[\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.9%

      \[\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.9%

      \[\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.9%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \left(x + -1\right) \cdot \log y\right) - t} \]
  4. Step-by-step derivation
    1. fma-udef99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 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 91.1%

    \[\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. +-commutative91.1%

      \[\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-def91.1%

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

      \[\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-eval91.1%

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

      \[\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.9%

      \[\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.9%

      \[\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.9%

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

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

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

Alternative 3: 99.8% accurate, 1.0× speedup?

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

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

    \[\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. *-commutative91.1%

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

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

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \mathsf{log1p}\left(-y\right) \cdot \color{blue}{\frac{{z}^{3} - {1}^{3}}{z \cdot z + \left(1 \cdot 1 + z \cdot 1\right)}}\right) - t \]
    5. clear-num66.6%

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \mathsf{log1p}\left(-y\right) \cdot \color{blue}{\frac{1}{\frac{z \cdot z + \left(1 \cdot 1 + z \cdot 1\right)}{{z}^{3} - {1}^{3}}}}\right) - t \]
    6. un-div-inv66.6%

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \color{blue}{\frac{\mathsf{log1p}\left(-y\right)}{\frac{z \cdot z + \left(1 \cdot 1 + z \cdot 1\right)}{{z}^{3} - {1}^{3}}}}\right) - t \]
    7. clear-num66.6%

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \frac{\mathsf{log1p}\left(-y\right)}{\color{blue}{\frac{1}{\frac{{z}^{3} - {1}^{3}}{z \cdot z + \left(1 \cdot 1 + z \cdot 1\right)}}}}\right) - t \]
    8. flip3--99.8%

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

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

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

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

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

Alternative 4: 94.5% accurate, 1.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 z 1) < -2e208 or 1.00000000000000006e84 < (-.f64 z 1)

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2e208 < (-.f64 z 1) < 1.00000000000000006e84

    1. Initial program 99.4%

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

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

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

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

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

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

Alternative 5: 90.0% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z + -1 \leq -2 \cdot 10^{+208}:\\
\;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\

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

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


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

    1. Initial program 58.0%

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

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

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

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

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

    if -2e208 < (-.f64 z 1) < 4.9999999999999998e210

    1. Initial program 97.4%

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

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

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

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

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

    if 4.9999999999999998e210 < (-.f64 z 1)

    1. Initial program 46.0%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right)} - t \]
    6. Step-by-step derivation
      1. associate-*r*82.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z + -1 \leq -2 \cdot 10^{+208}:\\ \;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\ \mathbf{elif}\;z + -1 \leq 5 \cdot 10^{+210}:\\ \;\;\;\;\left(y + \log y \cdot \left(-1 + x\right)\right) - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \end{array} \]

Alternative 6: 89.9% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z + -1 \leq -2 \cdot 10^{+208}:\\
\;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\

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

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


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

    1. Initial program 58.0%

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

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

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

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

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

    if -2e208 < (-.f64 z 1) < 4.9999999999999998e210

    1. Initial program 97.4%

      \[\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. +-commutative97.4%

        \[\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-def97.4%

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

        \[\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-eval97.4%

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

        \[\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.9%

        \[\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.9%

        \[\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.9%

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

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

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

    if 4.9999999999999998e210 < (-.f64 z 1)

    1. Initial program 46.0%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right)} - t \]
    6. Step-by-step derivation
      1. associate-*r*82.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z + -1 \leq -2 \cdot 10^{+208}:\\ \;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\ \mathbf{elif}\;z + -1 \leq 5 \cdot 10^{+210}:\\ \;\;\;\;\log y \cdot \left(-1 + x\right) - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \end{array} \]

Alternative 7: 99.1% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 61.1% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z + -1 \leq -2 \cdot 10^{+208} \lor \neg \left(z + -1 \leq 10^{+84}\right):\\
\;\;\;\;z \cdot \left(-y\right) - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 z 1) < -2e208 or 1.00000000000000006e84 < (-.f64 z 1)

    1. Initial program 66.0%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right)} - t \]
    6. Step-by-step derivation
      1. associate-*r*62.2%

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

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

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

    if -2e208 < (-.f64 z 1) < 1.00000000000000006e84

    1. Initial program 99.4%

      \[\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. +-commutative99.4%

        \[\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-def99.4%

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

        \[\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-eval99.4%

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

        \[\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.9%

        \[\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.9%

        \[\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.9%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \left(x + -1\right) \cdot \log y\right) - t} \]
    4. Step-by-step derivation
      1. flip3--42.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z + -1 \leq -2 \cdot 10^{+208} \lor \neg \left(z + -1 \leq 10^{+84}\right):\\ \;\;\;\;z \cdot \left(-y\right) - t\\ \mathbf{else}:\\ \;\;\;\;\left(-t\right) - \log y\\ \end{array} \]

Alternative 9: 99.0% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 86.6% accurate, 2.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.25e29 or 19 < x

    1. Initial program 93.2%

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

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

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

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

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \mathsf{log1p}\left(-y\right) \cdot \color{blue}{\frac{{z}^{3} - {1}^{3}}{z \cdot z + \left(1 \cdot 1 + z \cdot 1\right)}}\right) - t \]
      5. clear-num61.8%

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \mathsf{log1p}\left(-y\right) \cdot \color{blue}{\frac{1}{\frac{z \cdot z + \left(1 \cdot 1 + z \cdot 1\right)}{{z}^{3} - {1}^{3}}}}\right) - t \]
      6. un-div-inv61.8%

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \color{blue}{\frac{\mathsf{log1p}\left(-y\right)}{\frac{z \cdot z + \left(1 \cdot 1 + z \cdot 1\right)}{{z}^{3} - {1}^{3}}}}\right) - t \]
      7. clear-num61.8%

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \frac{\mathsf{log1p}\left(-y\right)}{\color{blue}{\frac{1}{\frac{{z}^{3} - {1}^{3}}{z \cdot z + \left(1 \cdot 1 + z \cdot 1\right)}}}}\right) - t \]
      8. flip3--99.8%

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

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

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

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

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

    if -1.25e29 < x < 19

    1. Initial program 89.0%

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

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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.0%

        \[\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-def100.0%

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

        \[\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-eval100.0%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \left(x + -1\right) \cdot \log y\right) - t} \]
    4. Step-by-step derivation
      1. flip3--58.7%

        \[\leadsto \color{blue}{\frac{{\left(\mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \left(x + -1\right) \cdot \log y\right)\right)}^{3} - {t}^{3}}{\mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \left(x + -1\right) \cdot \log y\right) \cdot \mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \left(x + -1\right) \cdot \log y\right) + \left(t \cdot t + \mathsf{fma}\left(z + -1, \mathsf{log1p}\left(-y\right), \left(x + -1\right) \cdot \log y\right) \cdot t\right)}} \]
      2. clear-num58.6%

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

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

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

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

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

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

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

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

Alternative 11: 43.4% accurate, 26.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{-7}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 4.6 \cdot 10^{+23}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= t -5e-7) (- t) (if (<= t 4.6e+23) (* z (- y)) (- t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -5e-7) {
		tmp = -t;
	} else if (t <= 4.6e+23) {
		tmp = z * -y;
	} else {
		tmp = -t;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (t <= (-5d-7)) then
        tmp = -t
    else if (t <= 4.6d+23) then
        tmp = z * -y
    else
        tmp = -t
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -5e-7) {
		tmp = -t;
	} else if (t <= 4.6e+23) {
		tmp = z * -y;
	} else {
		tmp = -t;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if t <= -5e-7:
		tmp = -t
	elif t <= 4.6e+23:
		tmp = z * -y
	else:
		tmp = -t
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -5e-7)
		tmp = Float64(-t);
	elseif (t <= 4.6e+23)
		tmp = Float64(z * Float64(-y));
	else
		tmp = Float64(-t);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -5e-7)
		tmp = -t;
	elseif (t <= 4.6e+23)
		tmp = z * -y;
	else
		tmp = -t;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[t, -5e-7], (-t), If[LessEqual[t, 4.6e+23], N[(z * (-y)), $MachinePrecision], (-t)]]
\begin{array}{l}

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

\mathbf{elif}\;t \leq 4.6 \cdot 10^{+23}:\\
\;\;\;\;z \cdot \left(-y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -4.99999999999999977e-7 or 4.6000000000000001e23 < t

    1. Initial program 96.8%

      \[\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. +-commutative96.8%

        \[\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-def96.8%

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

        \[\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-eval96.8%

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

        \[\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.9%

        \[\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.9%

        \[\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.9%

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

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

      \[\leadsto \color{blue}{-1 \cdot t} \]
    5. Step-by-step derivation
      1. mul-1-neg73.2%

        \[\leadsto \color{blue}{-t} \]
    6. Simplified73.2%

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

    if -4.99999999999999977e-7 < t < 4.6000000000000001e23

    1. Initial program 85.4%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right)} - t \]
    6. Step-by-step derivation
      1. associate-*r*18.1%

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(-z\right)} \]
    10. Simplified17.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{-7}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 4.6 \cdot 10^{+23}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]

Alternative 12: 46.9% accurate, 30.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 46.7% accurate, 35.8× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right)} - t \]
  6. Step-by-step derivation
    1. associate-*r*46.8%

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

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

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

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

Alternative 14: 36.1% accurate, 107.5× speedup?

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

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

    \[\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. +-commutative91.1%

      \[\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-def91.1%

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

      \[\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-eval91.1%

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

      \[\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.9%

      \[\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.9%

      \[\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.9%

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

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

    \[\leadsto \color{blue}{-1 \cdot t} \]
  5. Step-by-step derivation
    1. mul-1-neg38.0%

      \[\leadsto \color{blue}{-t} \]
  6. Simplified38.0%

    \[\leadsto \color{blue}{-t} \]
  7. Final simplification38.0%

    \[\leadsto -t \]

Reproduce

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