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

Percentage Accurate: 89.5% → 99.6%
Time: 12.6s
Alternatives: 11
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 11 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.5% 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.6% accurate, 1.6× speedup?

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

\\
\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot y\right) \cdot \left(z - 1\right) + \log y \cdot \left(x - 1\right)\right) - t
\end{array}
Derivation
  1. Initial program 90.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

    \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(y \cdot \left(y \cdot \left(\frac{-1}{3} \cdot y - \frac{1}{2}\right) - 1\right)\right)}\right) - t \]
  4. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \color{blue}{\left(\left(y \cdot \left(\frac{-1}{3} \cdot y - \frac{1}{2}\right) - 1\right) \cdot y\right)}\right) - t \]
    2. lower-*.f64N/A

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\color{blue}{\left(y \cdot \left(\frac{-1}{3} \cdot y - \frac{1}{2}\right) + \left(\mathsf{neg}\left(1\right)\right)\right)} \cdot y\right)\right) - t \]
    4. *-commutativeN/A

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\left(\color{blue}{\left(\frac{-1}{3} \cdot y - \frac{1}{2}\right) \cdot y} + \left(\mathsf{neg}\left(1\right)\right)\right) \cdot y\right)\right) - t \]
    5. metadata-evalN/A

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\left(\left(\frac{-1}{3} \cdot y - \frac{1}{2}\right) \cdot y + \color{blue}{-1}\right) \cdot y\right)\right) - t \]
    6. lower-fma.f64N/A

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\mathsf{fma}\left(\color{blue}{\frac{-1}{3} \cdot y + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}, y, -1\right) \cdot y\right)\right) - t \]
    8. metadata-evalN/A

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(\mathsf{fma}\left(\frac{-1}{3} \cdot y + \color{blue}{\frac{-1}{2}}, y, -1\right) \cdot y\right)\right) - t \]
    9. lower-fma.f6499.7

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

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

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

Alternative 2: 95.6% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log y \cdot \left(x - 1\right) - t\\ \mathbf{if}\;x - 1 \leq -1.0000000000002:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x - 1 \leq -1:\\ \;\;\;\;\mathsf{fma}\left(-z, y, -\log y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* (log y) (- x 1.0)) t)))
   (if (<= (- x 1.0) -1.0000000000002)
     t_1
     (if (<= (- x 1.0) -1.0) (- (fma (- z) y (- (log y))) t) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = (log(y) * (x - 1.0)) - t;
	double tmp;
	if ((x - 1.0) <= -1.0000000000002) {
		tmp = t_1;
	} else if ((x - 1.0) <= -1.0) {
		tmp = fma(-z, y, -log(y)) - t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(Float64(log(y) * Float64(x - 1.0)) - t)
	tmp = 0.0
	if (Float64(x - 1.0) <= -1.0000000000002)
		tmp = t_1;
	elseif (Float64(x - 1.0) <= -1.0)
		tmp = Float64(fma(Float64(-z), y, Float64(-log(y))) - t);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[N[(x - 1.0), $MachinePrecision], -1.0000000000002], t$95$1, If[LessEqual[N[(x - 1.0), $MachinePrecision], -1.0], N[(N[((-z) * y + (-N[Log[y], $MachinePrecision])), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}

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

\mathbf{elif}\;x - 1 \leq -1:\\
\;\;\;\;\mathsf{fma}\left(-z, y, -\log y\right) - t\\

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


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

    1. Initial program 95.9%

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

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

        \[\leadsto \color{blue}{\left(x - 1\right) \cdot \log y} - t \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x - 1\right) \cdot \log y} - t \]
      3. lower--.f64N/A

        \[\leadsto \color{blue}{\left(x - 1\right)} \cdot \log y - t \]
      4. lower-log.f6494.9

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

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

    if -1.00000000000020006 < (-.f64 x #s(literal 1 binary64)) < -1

    1. Initial program 85.7%

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

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

        \[\leadsto \left(-1 \cdot \color{blue}{\left(\left(z - 1\right) \cdot y\right)} + \log y \cdot \left(x - 1\right)\right) - t \]
      2. associate-*r*N/A

        \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(z - 1\right)\right) \cdot y} + \log y \cdot \left(x - 1\right)\right) - t \]
      3. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \left(z - 1\right), y, \log y \cdot \left(x - 1\right)\right)} - t \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\left(z - 1\right)\right)}, y, \log y \cdot \left(x - 1\right)\right) - t \]
      5. neg-sub0N/A

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

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

        \[\leadsto \mathsf{fma}\left(0 - \left(z + \color{blue}{-1}\right), y, \log y \cdot \left(x - 1\right)\right) - t \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(0 - \color{blue}{\left(-1 + z\right)}, y, \log y \cdot \left(x - 1\right)\right) - t \]
      9. associate--r+N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0 - -1\right) - z}, y, \log y \cdot \left(x - 1\right)\right) - t \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{1} - z, y, \log y \cdot \left(x - 1\right)\right) - t \]
      11. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{1 - z}, y, \log y \cdot \left(x - 1\right)\right) - t \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right) \cdot \log y}\right) - t \]
      13. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right) \cdot \log y}\right) - t \]
      14. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]
      15. lower-log.f6498.9

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

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

        \[\leadsto \mathsf{fma}\left(1 - z, y, \mathsf{fma}\left(\log y, x, -\log y\right)\right) - t \]
      2. Taylor expanded in x around 0

        \[\leadsto \mathsf{fma}\left(1 - z, y, -1 \cdot \log y\right) - t \]
      3. Step-by-step derivation
        1. Applied rewrites98.9%

          \[\leadsto \mathsf{fma}\left(1 - z, y, -\log y\right) - t \]
        2. Taylor expanded in z around inf

          \[\leadsto \mathsf{fma}\left(-1 \cdot z, y, -\log y\right) - t \]
        3. Step-by-step derivation
          1. Applied rewrites98.9%

            \[\leadsto \mathsf{fma}\left(-z, y, -\log y\right) - t \]
        4. Recombined 2 regimes into one program.
        5. Final simplification97.0%

          \[\leadsto \begin{array}{l} \mathbf{if}\;x - 1 \leq -1.0000000000002:\\ \;\;\;\;\log y \cdot \left(x - 1\right) - t\\ \mathbf{elif}\;x - 1 \leq -1:\\ \;\;\;\;\mathsf{fma}\left(-z, y, -\log y\right) - t\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot \left(x - 1\right) - t\\ \end{array} \]
        6. Add Preprocessing

        Alternative 3: 89.6% accurate, 1.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z - 1 \leq -4 \cdot 10^{+198}:\\ \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t\\ \mathbf{elif}\;z - 1 \leq 5 \cdot 10^{+204}:\\ \;\;\;\;\log y \cdot \left(x - 1\right) - t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\ \end{array} \end{array} \]
        (FPCore (x y z t)
         :precision binary64
         (if (<= (- z 1.0) -4e+198)
           (- (* (* (fma (fma -0.3333333333333333 y -0.5) y -1.0) z) y) t)
           (if (<= (- z 1.0) 5e+204)
             (- (* (log y) (- x 1.0)) t)
             (- (* (log1p (- y)) z) t))))
        double code(double x, double y, double z, double t) {
        	double tmp;
        	if ((z - 1.0) <= -4e+198) {
        		tmp = ((fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * z) * y) - t;
        	} else if ((z - 1.0) <= 5e+204) {
        		tmp = (log(y) * (x - 1.0)) - t;
        	} else {
        		tmp = (log1p(-y) * z) - t;
        	}
        	return tmp;
        }
        
        function code(x, y, z, t)
        	tmp = 0.0
        	if (Float64(z - 1.0) <= -4e+198)
        		tmp = Float64(Float64(Float64(fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * z) * y) - t);
        	elseif (Float64(z - 1.0) <= 5e+204)
        		tmp = Float64(Float64(log(y) * Float64(x - 1.0)) - t);
        	else
        		tmp = Float64(Float64(log1p(Float64(-y)) * z) - t);
        	end
        	return tmp
        end
        
        code[x_, y_, z_, t_] := If[LessEqual[N[(z - 1.0), $MachinePrecision], -4e+198], N[(N[(N[(N[(N[(-0.3333333333333333 * y + -0.5), $MachinePrecision] * y + -1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], If[LessEqual[N[(z - 1.0), $MachinePrecision], 5e+204], N[(N[(N[Log[y], $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[(N[Log[1 + (-y)], $MachinePrecision] * z), $MachinePrecision] - t), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;z - 1 \leq -4 \cdot 10^{+198}:\\
        \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t\\
        
        \mathbf{elif}\;z - 1 \leq 5 \cdot 10^{+204}:\\
        \;\;\;\;\log y \cdot \left(x - 1\right) - t\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (-.f64 z #s(literal 1 binary64)) < -4.00000000000000007e198

          1. Initial program 54.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

            \[\leadsto \color{blue}{\left(y \cdot \left(-1 \cdot \left(z - 1\right) + y \cdot \left(\frac{-1}{2} \cdot \left(z - 1\right) + \frac{-1}{3} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) + \log y \cdot \left(x - 1\right)\right)} - t \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(z - 1\right) + y \cdot \left(\frac{-1}{2} \cdot \left(z - 1\right) + \frac{-1}{3} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) \cdot y} + \log y \cdot \left(x - 1\right)\right) - t \]
            2. lower-fma.f64N/A

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

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

            \[\leadsto y \cdot \color{blue}{\left(z \cdot \left(y \cdot \left(\frac{-1}{3} \cdot y - \frac{1}{2}\right) - 1\right)\right)} - t \]
          7. Step-by-step derivation
            1. Applied rewrites69.3%

              \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot \color{blue}{y} - t \]

            if -4.00000000000000007e198 < (-.f64 z #s(literal 1 binary64)) < 5.00000000000000008e204

            1. Initial program 97.6%

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

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

                \[\leadsto \color{blue}{\left(x - 1\right) \cdot \log y} - t \]
              2. lower-*.f64N/A

                \[\leadsto \color{blue}{\left(x - 1\right) \cdot \log y} - t \]
              3. lower--.f64N/A

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

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

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

            if 5.00000000000000008e204 < (-.f64 z #s(literal 1 binary64))

            1. Initial program 61.0%

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

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

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

                \[\leadsto z \cdot \log \color{blue}{\left(1 + \left(\mathsf{neg}\left(y\right)\right)\right)} - t \]
              3. lower-log1p.f64N/A

                \[\leadsto z \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(y\right)\right)} - t \]
              4. lower-neg.f6481.5

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;z - 1 \leq -4 \cdot 10^{+198}:\\ \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t\\ \mathbf{elif}\;z - 1 \leq 5 \cdot 10^{+204}:\\ \;\;\;\;\log y \cdot \left(x - 1\right) - t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\ \end{array} \]
          10. Add Preprocessing

          Alternative 4: 77.3% accurate, 1.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_1 := \log y \cdot x - t\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{-34}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 74000000:\\ \;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
          (FPCore (x y z t)
           :precision binary64
           (let* ((t_1 (- (* (log y) x) t)))
             (if (<= x -6.5e-34)
               t_1
               (if (<= x 74000000.0) (- (* (log1p (- y)) z) t) t_1))))
          double code(double x, double y, double z, double t) {
          	double t_1 = (log(y) * x) - t;
          	double tmp;
          	if (x <= -6.5e-34) {
          		tmp = t_1;
          	} else if (x <= 74000000.0) {
          		tmp = (log1p(-y) * z) - t;
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          public static double code(double x, double y, double z, double t) {
          	double t_1 = (Math.log(y) * x) - t;
          	double tmp;
          	if (x <= -6.5e-34) {
          		tmp = t_1;
          	} else if (x <= 74000000.0) {
          		tmp = (Math.log1p(-y) * z) - t;
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          def code(x, y, z, t):
          	t_1 = (math.log(y) * x) - t
          	tmp = 0
          	if x <= -6.5e-34:
          		tmp = t_1
          	elif x <= 74000000.0:
          		tmp = (math.log1p(-y) * z) - t
          	else:
          		tmp = t_1
          	return tmp
          
          function code(x, y, z, t)
          	t_1 = Float64(Float64(log(y) * x) - t)
          	tmp = 0.0
          	if (x <= -6.5e-34)
          		tmp = t_1;
          	elseif (x <= 74000000.0)
          		tmp = Float64(Float64(log1p(Float64(-y)) * z) - t);
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -6.5e-34], t$95$1, If[LessEqual[x, 74000000.0], N[(N[(N[Log[1 + (-y)], $MachinePrecision] * z), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_1 := \log y \cdot x - t\\
          \mathbf{if}\;x \leq -6.5 \cdot 10^{-34}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;x \leq 74000000:\\
          \;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -6.49999999999999985e-34 or 7.4e7 < x

            1. Initial program 96.7%

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

              \[\leadsto \color{blue}{x \cdot \log y} - t \]
            4. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \color{blue}{x \cdot \log y} - t \]
              2. lower-log.f6492.4

                \[\leadsto x \cdot \color{blue}{\log y} - t \]
            5. Applied rewrites92.4%

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

            if -6.49999999999999985e-34 < x < 7.4e7

            1. Initial program 85.0%

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

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

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

                \[\leadsto z \cdot \log \color{blue}{\left(1 + \left(\mathsf{neg}\left(y\right)\right)\right)} - t \]
              3. lower-log1p.f64N/A

                \[\leadsto z \cdot \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(y\right)\right)} - t \]
              4. lower-neg.f6460.8

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-34}:\\ \;\;\;\;\log y \cdot x - t\\ \mathbf{elif}\;x \leq 74000000:\\ \;\;\;\;\mathsf{log1p}\left(-y\right) \cdot z - t\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot x - t\\ \end{array} \]
          5. Add Preprocessing

          Alternative 5: 77.2% accurate, 1.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_1 := \log y \cdot x - t\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{-34}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 74000000:\\ \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
          (FPCore (x y z t)
           :precision binary64
           (let* ((t_1 (- (* (log y) x) t)))
             (if (<= x -6.5e-34)
               t_1
               (if (<= x 74000000.0)
                 (- (* (* (fma (fma -0.3333333333333333 y -0.5) y -1.0) z) y) t)
                 t_1))))
          double code(double x, double y, double z, double t) {
          	double t_1 = (log(y) * x) - t;
          	double tmp;
          	if (x <= -6.5e-34) {
          		tmp = t_1;
          	} else if (x <= 74000000.0) {
          		tmp = ((fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * z) * y) - t;
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          function code(x, y, z, t)
          	t_1 = Float64(Float64(log(y) * x) - t)
          	tmp = 0.0
          	if (x <= -6.5e-34)
          		tmp = t_1;
          	elseif (x <= 74000000.0)
          		tmp = Float64(Float64(Float64(fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * z) * y) - t);
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[x, -6.5e-34], t$95$1, If[LessEqual[x, 74000000.0], N[(N[(N[(N[(N[(-0.3333333333333333 * y + -0.5), $MachinePrecision] * y + -1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_1 := \log y \cdot x - t\\
          \mathbf{if}\;x \leq -6.5 \cdot 10^{-34}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;x \leq 74000000:\\
          \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -6.49999999999999985e-34 or 7.4e7 < x

            1. Initial program 96.7%

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

              \[\leadsto \color{blue}{x \cdot \log y} - t \]
            4. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \color{blue}{x \cdot \log y} - t \]
              2. lower-log.f6492.4

                \[\leadsto x \cdot \color{blue}{\log y} - t \]
            5. Applied rewrites92.4%

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

            if -6.49999999999999985e-34 < x < 7.4e7

            1. Initial program 85.0%

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

              \[\leadsto \color{blue}{\left(y \cdot \left(-1 \cdot \left(z - 1\right) + y \cdot \left(\frac{-1}{2} \cdot \left(z - 1\right) + \frac{-1}{3} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) + \log y \cdot \left(x - 1\right)\right)} - t \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(z - 1\right) + y \cdot \left(\frac{-1}{2} \cdot \left(z - 1\right) + \frac{-1}{3} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) \cdot y} + \log y \cdot \left(x - 1\right)\right) - t \]
              2. lower-fma.f64N/A

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

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

              \[\leadsto y \cdot \color{blue}{\left(z \cdot \left(y \cdot \left(\frac{-1}{3} \cdot y - \frac{1}{2}\right) - 1\right)\right)} - t \]
            7. Step-by-step derivation
              1. Applied rewrites60.5%

                \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot \color{blue}{y} - t \]
            8. Recombined 2 regimes into one program.
            9. Final simplification75.6%

              \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-34}:\\ \;\;\;\;\log y \cdot x - t\\ \mathbf{elif}\;x \leq 74000000:\\ \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot x - t\\ \end{array} \]
            10. Add Preprocessing

            Alternative 6: 99.1% accurate, 1.9× speedup?

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

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

                \[\leadsto \left(-1 \cdot \color{blue}{\left(\left(z - 1\right) \cdot y\right)} + \log y \cdot \left(x - 1\right)\right) - t \]
              2. associate-*r*N/A

                \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(z - 1\right)\right) \cdot y} + \log y \cdot \left(x - 1\right)\right) - t \]
              3. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \left(z - 1\right), y, \log y \cdot \left(x - 1\right)\right)} - t \]
              4. mul-1-negN/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\left(z - 1\right)\right)}, y, \log y \cdot \left(x - 1\right)\right) - t \]
              5. neg-sub0N/A

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

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

                \[\leadsto \mathsf{fma}\left(0 - \left(z + \color{blue}{-1}\right), y, \log y \cdot \left(x - 1\right)\right) - t \]
              8. +-commutativeN/A

                \[\leadsto \mathsf{fma}\left(0 - \color{blue}{\left(-1 + z\right)}, y, \log y \cdot \left(x - 1\right)\right) - t \]
              9. associate--r+N/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0 - -1\right) - z}, y, \log y \cdot \left(x - 1\right)\right) - t \]
              10. metadata-evalN/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{1} - z, y, \log y \cdot \left(x - 1\right)\right) - t \]
              11. lower--.f64N/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{1 - z}, y, \log y \cdot \left(x - 1\right)\right) - t \]
              12. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right) \cdot \log y}\right) - t \]
              13. lower-*.f64N/A

                \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right) \cdot \log y}\right) - t \]
              14. lower--.f64N/A

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

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

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

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

            Alternative 7: 66.3% accurate, 1.9× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_1 := \log y \cdot x\\ \mathbf{if}\;x \leq -1.12 \cdot 10^{+18}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+76}:\\ \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
            (FPCore (x y z t)
             :precision binary64
             (let* ((t_1 (* (log y) x)))
               (if (<= x -1.12e+18)
                 t_1
                 (if (<= x 1.1e+76)
                   (- (* (* (fma (fma -0.3333333333333333 y -0.5) y -1.0) z) y) t)
                   t_1))))
            double code(double x, double y, double z, double t) {
            	double t_1 = log(y) * x;
            	double tmp;
            	if (x <= -1.12e+18) {
            		tmp = t_1;
            	} else if (x <= 1.1e+76) {
            		tmp = ((fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * z) * y) - t;
            	} else {
            		tmp = t_1;
            	}
            	return tmp;
            }
            
            function code(x, y, z, t)
            	t_1 = Float64(log(y) * x)
            	tmp = 0.0
            	if (x <= -1.12e+18)
            		tmp = t_1;
            	elseif (x <= 1.1e+76)
            		tmp = Float64(Float64(Float64(fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * z) * y) - t);
            	else
            		tmp = t_1;
            	end
            	return tmp
            end
            
            code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -1.12e+18], t$95$1, If[LessEqual[x, 1.1e+76], N[(N[(N[(N[(N[(-0.3333333333333333 * y + -0.5), $MachinePrecision] * y + -1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_1 := \log y \cdot x\\
            \mathbf{if}\;x \leq -1.12 \cdot 10^{+18}:\\
            \;\;\;\;t\_1\\
            
            \mathbf{elif}\;x \leq 1.1 \cdot 10^{+76}:\\
            \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_1\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -1.12e18 or 1.1e76 < x

              1. Initial program 96.0%

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

                \[\leadsto \color{blue}{x \cdot \log y} \]
              4. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto \color{blue}{x \cdot \log y} \]
                2. lower-log.f6475.3

                  \[\leadsto x \cdot \color{blue}{\log y} \]
              5. Applied rewrites75.3%

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

              if -1.12e18 < x < 1.1e76

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

                \[\leadsto \color{blue}{\left(y \cdot \left(-1 \cdot \left(z - 1\right) + y \cdot \left(\frac{-1}{2} \cdot \left(z - 1\right) + \frac{-1}{3} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) + \log y \cdot \left(x - 1\right)\right)} - t \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(z - 1\right) + y \cdot \left(\frac{-1}{2} \cdot \left(z - 1\right) + \frac{-1}{3} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) \cdot y} + \log y \cdot \left(x - 1\right)\right) - t \]
                2. lower-fma.f64N/A

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

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

                \[\leadsto y \cdot \color{blue}{\left(z \cdot \left(y \cdot \left(\frac{-1}{3} \cdot y - \frac{1}{2}\right) - 1\right)\right)} - t \]
              7. Step-by-step derivation
                1. Applied rewrites59.6%

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot \color{blue}{y} - t \]
              8. Recombined 2 regimes into one program.
              9. Final simplification65.7%

                \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.12 \cdot 10^{+18}:\\ \;\;\;\;\log y \cdot x\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+76}:\\ \;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t\\ \mathbf{else}:\\ \;\;\;\;\log y \cdot x\\ \end{array} \]
              10. Add Preprocessing

              Alternative 8: 46.2% accurate, 8.7× speedup?

              \[\begin{array}{l} \\ \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t \end{array} \]
              (FPCore (x y z t)
               :precision binary64
               (- (* (* (fma (fma -0.3333333333333333 y -0.5) y -1.0) z) y) t))
              double code(double x, double y, double z, double t) {
              	return ((fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * z) * y) - t;
              }
              
              function code(x, y, z, t)
              	return Float64(Float64(Float64(fma(fma(-0.3333333333333333, y, -0.5), y, -1.0) * z) * y) - t)
              end
              
              code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(-0.3333333333333333 * y + -0.5), $MachinePrecision] * y + -1.0), $MachinePrecision] * z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot y - t
              \end{array}
              
              Derivation
              1. Initial program 90.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

                \[\leadsto \color{blue}{\left(y \cdot \left(-1 \cdot \left(z - 1\right) + y \cdot \left(\frac{-1}{2} \cdot \left(z - 1\right) + \frac{-1}{3} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) + \log y \cdot \left(x - 1\right)\right)} - t \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(z - 1\right) + y \cdot \left(\frac{-1}{2} \cdot \left(z - 1\right) + \frac{-1}{3} \cdot \left(y \cdot \left(z - 1\right)\right)\right)\right) \cdot y} + \log y \cdot \left(x - 1\right)\right) - t \]
                2. lower-fma.f64N/A

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

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

                \[\leadsto y \cdot \color{blue}{\left(z \cdot \left(y \cdot \left(\frac{-1}{3} \cdot y - \frac{1}{2}\right) - 1\right)\right)} - t \]
              7. Step-by-step derivation
                1. Applied rewrites46.0%

                  \[\leadsto \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, y, -0.5\right), y, -1\right) \cdot z\right) \cdot \color{blue}{y} - t \]
                2. Add Preprocessing

                Alternative 9: 46.0% accurate, 18.8× speedup?

                \[\begin{array}{l} \\ \mathsf{fma}\left(-y, z, y\right) - t \end{array} \]
                (FPCore (x y z t) :precision binary64 (- (fma (- y) z y) t))
                double code(double x, double y, double z, double t) {
                	return fma(-y, z, y) - t;
                }
                
                function code(x, y, z, t)
                	return Float64(fma(Float64(-y), z, y) - t)
                end
                
                code[x_, y_, z_, t_] := N[(N[((-y) * z + y), $MachinePrecision] - t), $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                \mathsf{fma}\left(-y, z, y\right) - t
                \end{array}
                
                Derivation
                1. Initial program 90.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

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

                    \[\leadsto \left(-1 \cdot \color{blue}{\left(\left(z - 1\right) \cdot y\right)} + \log y \cdot \left(x - 1\right)\right) - t \]
                  2. associate-*r*N/A

                    \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(z - 1\right)\right) \cdot y} + \log y \cdot \left(x - 1\right)\right) - t \]
                  3. lower-fma.f64N/A

                    \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \left(z - 1\right), y, \log y \cdot \left(x - 1\right)\right)} - t \]
                  4. mul-1-negN/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\left(z - 1\right)\right)}, y, \log y \cdot \left(x - 1\right)\right) - t \]
                  5. neg-sub0N/A

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

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

                    \[\leadsto \mathsf{fma}\left(0 - \left(z + \color{blue}{-1}\right), y, \log y \cdot \left(x - 1\right)\right) - t \]
                  8. +-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(0 - \color{blue}{\left(-1 + z\right)}, y, \log y \cdot \left(x - 1\right)\right) - t \]
                  9. associate--r+N/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0 - -1\right) - z}, y, \log y \cdot \left(x - 1\right)\right) - t \]
                  10. metadata-evalN/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{1} - z, y, \log y \cdot \left(x - 1\right)\right) - t \]
                  11. lower--.f64N/A

                    \[\leadsto \mathsf{fma}\left(\color{blue}{1 - z}, y, \log y \cdot \left(x - 1\right)\right) - t \]
                  12. *-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right) \cdot \log y}\right) - t \]
                  13. lower-*.f64N/A

                    \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right) \cdot \log y}\right) - t \]
                  14. lower--.f64N/A

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(-y, \color{blue}{z}, y\right) - t \]
                  2. Add Preprocessing

                  Alternative 10: 45.8% accurate, 20.5× speedup?

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

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

                      \[\leadsto \left(-1 \cdot \color{blue}{\left(\left(z - 1\right) \cdot y\right)} + \log y \cdot \left(x - 1\right)\right) - t \]
                    2. associate-*r*N/A

                      \[\leadsto \left(\color{blue}{\left(-1 \cdot \left(z - 1\right)\right) \cdot y} + \log y \cdot \left(x - 1\right)\right) - t \]
                    3. lower-fma.f64N/A

                      \[\leadsto \color{blue}{\mathsf{fma}\left(-1 \cdot \left(z - 1\right), y, \log y \cdot \left(x - 1\right)\right)} - t \]
                    4. mul-1-negN/A

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\left(z - 1\right)\right)}, y, \log y \cdot \left(x - 1\right)\right) - t \]
                    5. neg-sub0N/A

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

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

                      \[\leadsto \mathsf{fma}\left(0 - \left(z + \color{blue}{-1}\right), y, \log y \cdot \left(x - 1\right)\right) - t \]
                    8. +-commutativeN/A

                      \[\leadsto \mathsf{fma}\left(0 - \color{blue}{\left(-1 + z\right)}, y, \log y \cdot \left(x - 1\right)\right) - t \]
                    9. associate--r+N/A

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(0 - -1\right) - z}, y, \log y \cdot \left(x - 1\right)\right) - t \]
                    10. metadata-evalN/A

                      \[\leadsto \mathsf{fma}\left(\color{blue}{1} - z, y, \log y \cdot \left(x - 1\right)\right) - t \]
                    11. lower--.f64N/A

                      \[\leadsto \mathsf{fma}\left(\color{blue}{1 - z}, y, \log y \cdot \left(x - 1\right)\right) - t \]
                    12. *-commutativeN/A

                      \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right) \cdot \log y}\right) - t \]
                    13. lower-*.f64N/A

                      \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right) \cdot \log y}\right) - t \]
                    14. lower--.f64N/A

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

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

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

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

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

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

                    Alternative 11: 35.7% accurate, 75.3× 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 90.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

                      \[\leadsto \color{blue}{-1 \cdot t} \]
                    4. Step-by-step derivation
                      1. mul-1-negN/A

                        \[\leadsto \color{blue}{\mathsf{neg}\left(t\right)} \]
                      2. lower-neg.f6435.8

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

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

                    Reproduce

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