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

Percentage Accurate: 89.3% → 99.8%
Time: 18.2s
Alternatives: 13
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 13 alternatives:

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

Initial Program: 89.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.7× speedup?

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

\\
\mathsf{fma}\left(x + -1, \log y, \mathsf{log1p}\left(-y\right) \cdot \left(-1 + z\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. Step-by-step derivation
    1. fma-def90.5%

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

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

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

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

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

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

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

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

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

Alternative 2: 99.0% accurate, 1.0× speedup?

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

\\
\mathsf{fma}\left(\log y, x + -1, y \cdot \left(1 - z\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 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.7% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 97.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. fma-def97.8%

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

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

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

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

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

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

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

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

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

    if -1e7 < (-.f64 x 1) < 1e5

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 95.6% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 97.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. fma-def97.8%

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

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

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

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

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

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

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

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

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

    if -1e7 < (-.f64 x 1) < 1e5

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 87.0% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.99999999999999966e-18 or 1 < 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 y around 0 98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\log y \cdot x} - t \]
    8. Simplified94.0%

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

    if -5.99999999999999966e-18 < x < 1

    1. Initial program 84.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 61.0% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+117} \lor \neg \left(z \leq 1.35 \cdot 10^{+177}\right):\\
\;\;\;\;z \cdot \left(-y\right) - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -9.50000000000000041e117 or 1.34999999999999995e177 < z

    1. Initial program 69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-\color{blue}{z \cdot y}\right) - t \]
      3. distribute-rgt-neg-in61.0%

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

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

    if -9.50000000000000041e117 < z < 1.34999999999999995e177

    1. Initial program 98.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. fma-def98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 99.0% accurate, 1.9× speedup?

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

\\
\left(\log y \cdot \left(x + -1\right) - y \cdot \left(-1 + z\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 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 98.8% accurate, 1.9× speedup?

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

\\
\left(\log y \cdot \left(x + -1\right) - y \cdot z\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 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 88.0% accurate, 2.0× speedup?

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

\\
\log y \cdot \left(x + -1\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. Step-by-step derivation
    1. fma-def90.5%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 41.9% accurate, 15.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.5e52 or 1.65e15 < t

    1. Initial program 96.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. fma-def96.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-t} \]
    7. Simplified66.9%

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

    if -1.5e52 < t < 1.65e15

    1. Initial program 85.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 46.2% 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 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 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 46.0% 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 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 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 35.8% accurate, 107.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-t} \]
  7. Simplified33.8%

    \[\leadsto \color{blue}{-t} \]
  8. Final simplification33.8%

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

Reproduce

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