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

Percentage Accurate: 89.3% → 99.8%
Time: 17.8s
Alternatives: 14
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 89.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(z + -1\right)\right) - t \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (- (fma (- x 1.0) (log y) (* (log1p (- y)) (+ z -1.0))) t))
double code(double x, double y, double z, double t) {
	return fma((x - 1.0), log(y), (log1p(-y) * (z + -1.0))) - t;
}
function code(x, y, z, t)
	return Float64(fma(Float64(x - 1.0), log(y), Float64(log1p(Float64(-y)) * Float64(z + -1.0))) - 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[(z + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]
\begin{array}{l}

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

    \[\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. cancel-sign-sub91.6%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x - 1, \log y, \left(z - 1\right) \cdot \log \color{blue}{\left(1 + \left(-y\right)\right)}\right) - t \]
    6. 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. Final simplification99.9%

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

Alternative 2: 99.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 95.8% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x - 1 \leq -10 \lor \neg \left(x - 1 \leq -0.99999998\right):\\ \;\;\;\;\left(x - 1\right) \cdot \log y - 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) -10.0) (not (<= (- x 1.0) -0.99999998)))
   (- (* (- x 1.0) (log y)) t)
   (- (- (- (log y)) (* y z)) t)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (((x - 1.0) <= -10.0) || !((x - 1.0) <= -0.99999998)) {
		tmp = ((x - 1.0) * log(y)) - 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) <= (-10.0d0)) .or. (.not. ((x - 1.0d0) <= (-0.99999998d0)))) then
        tmp = ((x - 1.0d0) * log(y)) - 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) <= -10.0) || !((x - 1.0) <= -0.99999998)) {
		tmp = ((x - 1.0) * Math.log(y)) - t;
	} else {
		tmp = (-Math.log(y) - (y * z)) - t;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if ((x - 1.0) <= -10.0) or not ((x - 1.0) <= -0.99999998):
		tmp = ((x - 1.0) * math.log(y)) - 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) <= -10.0) || !(Float64(x - 1.0) <= -0.99999998))
		tmp = Float64(Float64(Float64(x - 1.0) * log(y)) - 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) <= -10.0) || ~(((x - 1.0) <= -0.99999998)))
		tmp = ((x - 1.0) * log(y)) - 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], -10.0], N[Not[LessEqual[N[(x - 1.0), $MachinePrecision], -0.99999998]], $MachinePrecision]], N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $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 -10 \lor \neg \left(x - 1 \leq -0.99999998\right):\\
\;\;\;\;\left(x - 1\right) \cdot \log y - 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) < -10 or -0.999999980000000011 < (-.f64 x 1)

    1. Initial program 95.1%

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

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

    if -10 < (-.f64 x 1) < -0.999999980000000011

    1. Initial program 87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 89.1% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 93.8%

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

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

    if 9.9999999999999994e253 < (-.f64 z 1)

    1. Initial program 43.0%

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

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

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

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

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

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

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

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

Alternative 6: 99.0% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 77.5% accurate, 2.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.3500000000000001e-62 or 440 < x

    1. Initial program 95.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \mathsf{fma}\left(-\left(-1 + z\right), y, \color{blue}{\left(-0.5 \cdot {y}^{2}\right) \cdot \left(z + -1\right)}\right)\right) - t \]
      12. unpow299.0%

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

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

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

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

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

    if -1.3500000000000001e-62 < x < 440

    1. Initial program 86.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \mathsf{fma}\left(-\left(-1 + z\right), y, \color{blue}{\left(-0.5 \cdot {y}^{2}\right) \cdot \left(z + -1\right)}\right)\right) - t \]
      12. unpow2100.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 46.0% accurate, 12.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(-0.5 \cdot \left(\left(z - 1\right) \cdot {y}^{2}\right) + y \cdot \left(1 - z\right)\right)} - t \]
  6. Step-by-step derivation
    1. +-commutative47.1%

      \[\leadsto \color{blue}{\left(y \cdot \left(1 - z\right) + -0.5 \cdot \left(\left(z - 1\right) \cdot {y}^{2}\right)\right)} - t \]
    2. fma-def47.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 1 - z, -0.5 \cdot \left(\left(z - 1\right) \cdot {y}^{2}\right)\right)} - t \]
    3. *-commutative47.1%

      \[\leadsto \mathsf{fma}\left(y, 1 - z, -0.5 \cdot \color{blue}{\left({y}^{2} \cdot \left(z - 1\right)\right)}\right) - t \]
    4. unpow247.1%

      \[\leadsto \mathsf{fma}\left(y, 1 - z, -0.5 \cdot \left(\color{blue}{\left(y \cdot y\right)} \cdot \left(z - 1\right)\right)\right) - t \]
    5. associate-*r*47.1%

      \[\leadsto \mathsf{fma}\left(y, 1 - z, -0.5 \cdot \color{blue}{\left(y \cdot \left(y \cdot \left(z - 1\right)\right)\right)}\right) - t \]
    6. associate-*l*47.1%

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{\left(-0.5 \cdot y\right) \cdot \left(y \cdot \left(z - 1\right)\right)}\right) - t \]
    7. *-lft-identity47.1%

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \left(-0.5 \cdot y\right) \cdot \color{blue}{\left(1 \cdot \left(y \cdot \left(z - 1\right)\right)\right)}\right) - t \]
    8. *-lft-identity47.1%

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \left(-0.5 \cdot y\right) \cdot \color{blue}{\left(y \cdot \left(z - 1\right)\right)}\right) - t \]
    9. *-commutative47.1%

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \left(-0.5 \cdot y\right) \cdot \color{blue}{\left(\left(z - 1\right) \cdot y\right)}\right) - t \]
    10. sub-neg47.1%

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \left(-0.5 \cdot y\right) \cdot \left(\color{blue}{\left(z + \left(-1\right)\right)} \cdot y\right)\right) - t \]
    11. metadata-eval47.1%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, 1 - z, \left(-0.5 \cdot y\right) \cdot \left(\left(z + -1\right) \cdot y\right)\right)} - t \]
  8. Step-by-step derivation
    1. fma-udef47.1%

      \[\leadsto \color{blue}{\left(y \cdot \left(1 - z\right) + \left(-0.5 \cdot y\right) \cdot \left(\left(z + -1\right) \cdot y\right)\right)} - t \]
    2. associate-*l*47.1%

      \[\leadsto \left(y \cdot \left(1 - z\right) + \color{blue}{-0.5 \cdot \left(y \cdot \left(\left(z + -1\right) \cdot y\right)\right)}\right) - t \]
    3. *-commutative47.1%

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

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

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

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

Alternative 9: 45.9% accurate, 19.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(-0.5 \cdot {y}^{2} + -1 \cdot y\right) \cdot z} - t \]
  6. Step-by-step derivation
    1. *-commutative47.0%

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

      \[\leadsto z \cdot \left(-0.5 \cdot {y}^{2} + \color{blue}{\left(-y\right)}\right) - t \]
    3. unsub-neg47.0%

      \[\leadsto z \cdot \color{blue}{\left(-0.5 \cdot {y}^{2} - y\right)} - t \]
    4. unpow247.0%

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

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

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

Alternative 10: 42.1% accurate, 23.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.6 \cdot 10^{-58}:\\
\;\;\;\;y - t\\

\mathbf{elif}\;t \leq 62000:\\
\;\;\;\;y - y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -1.6e-58

    1. Initial program 96.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6e-58 < t < 62000

    1. Initial program 84.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(1 + \left(-z\right)\right)} \]
      2. distribute-rgt-in16.4%

        \[\leadsto \color{blue}{1 \cdot y + \left(-z\right) \cdot y} \]
      3. *-lft-identity16.4%

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

        \[\leadsto y + \color{blue}{y \cdot \left(-z\right)} \]
      5. distribute-rgt-neg-in16.4%

        \[\leadsto y + \color{blue}{\left(-y \cdot z\right)} \]
      6. unsub-neg16.4%

        \[\leadsto \color{blue}{y - y \cdot z} \]
    11. Simplified16.4%

      \[\leadsto \color{blue}{y - y \cdot z} \]

    if 62000 < t

    1. Initial program 96.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. cancel-sign-sub96.9%

        \[\leadsto \color{blue}{\left(\left(x - 1\right) \cdot \log y - \left(-\left(z - 1\right)\right) \cdot \log \left(1 - y\right)\right)} - t \]
      2. distribute-lft-neg-in96.9%

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

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

        \[\leadsto \mathsf{fma}\left(x - 1, \log y, \color{blue}{\left(z - 1\right) \cdot \log \left(1 - y\right)}\right) - t \]
      5. sub-neg96.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 \]
      6. 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. Taylor expanded in t around inf 73.3%

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

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

      \[\leadsto \color{blue}{-t} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification45.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.6 \cdot 10^{-58}:\\ \;\;\;\;y - t\\ \mathbf{elif}\;t \leq 62000:\\ \;\;\;\;y - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]

Alternative 11: 45.8% accurate, 30.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 45.6% accurate, 35.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 35.7% accurate, 71.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{y - t} \]
  10. Final simplification40.0%

    \[\leadsto y - t \]

Alternative 14: 35.4% accurate, 107.5× speedup?

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

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

    \[\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. cancel-sign-sub91.6%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x - 1, \log y, \left(z - 1\right) \cdot \log \color{blue}{\left(1 + \left(-y\right)\right)}\right) - t \]
    6. 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. Taylor expanded in t around inf 39.9%

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

      \[\leadsto \color{blue}{-t} \]
  6. Simplified39.9%

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

    \[\leadsto -t \]

Reproduce

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