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

Percentage Accurate: 89.2% → 99.8%
Time: 19.9s
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.2% 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.9× speedup?

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

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

    \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutativeN/A

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

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \log \left(1 - y\right) \cdot \color{blue}{\frac{1}{\frac{z + 1}{z \cdot z - 1 \cdot 1}}}\right) - t \]
    4. un-div-invN/A

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

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \frac{\log \color{blue}{\left(1 + \left(\mathsf{neg}\left(y\right)\right)\right)}}{\frac{z + 1}{z \cdot z - 1 \cdot 1}}\right) - t \]
    7. accelerator-lowering-log1p.f64N/A

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

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \frac{\mathsf{log1p}\left(\color{blue}{\mathsf{neg}\left(y\right)}\right)}{\frac{z + 1}{z \cdot z - 1 \cdot 1}}\right) - t \]
    9. clear-numN/A

      \[\leadsto \left(\left(x - 1\right) \cdot \log y + \frac{\mathsf{log1p}\left(\mathsf{neg}\left(y\right)\right)}{\color{blue}{\frac{1}{\frac{z \cdot z - 1 \cdot 1}{z + 1}}}}\right) - t \]
    10. flip--N/A

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.8% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\log y, x + -1, -t\right)\\
\mathbf{if}\;x + -1 \leq -500000:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 94.8%

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

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

        \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(t\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x - 1, \mathsf{neg}\left(t\right)\right)} \]
      3. log-lowering-log.f64N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-1 + x}, \mathsf{neg}\left(t\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-1 + x}, \mathsf{neg}\left(t\right)\right) \]
      8. neg-lowering-neg.f6494.0

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

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

    if -5e5 < (-.f64 x #s(literal 1 binary64)) < -0.999998000000000054

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(y \cdot \mathsf{fma}\left(y, y \cdot \frac{-1}{3} + \color{blue}{\frac{-1}{2}}, -1\right)\right)\right) - t \]
      8. accelerator-lowering-fma.f64100.0

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(1 - z\right) + \left(\mathsf{neg}\left(\left(t + -1 \cdot \left(\log y \cdot \left(x - 1\right)\right)\right)\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{-1 \cdot \log y} - t\right) \]
    13. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} - t\right) \]
      2. neg-lowering-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} - t\right) \]
      3. log-lowering-log.f6499.6

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

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

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

Alternative 4: 99.6% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 5: 89.4% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z + -1 \leq -2 \cdot 10^{+252}:\\
\;\;\;\;\mathsf{fma}\left(y, 1 - z, x \cdot \log y\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 z #s(literal 1 binary64)) < -2.0000000000000002e252

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(1 - z\right) + \left(\mathsf{neg}\left(\left(t + -1 \cdot \left(\log y \cdot \left(x - 1\right)\right)\right)\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000002e252 < (-.f64 z #s(literal 1 binary64)) < 4.9999999999999997e167

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(1 - z\right) + \left(\mathsf{neg}\left(\left(t + -1 \cdot \left(\log y \cdot \left(x - 1\right)\right)\right)\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y + \log y \cdot \left(x - 1\right)\right) - t} \]
    13. Step-by-step derivation
      1. --lowering--.f64N/A

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

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

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

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

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

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

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

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

    if 4.9999999999999997e167 < (-.f64 z #s(literal 1 binary64))

    1. Initial program 52.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 z around inf

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(y\right)\right)} \cdot z - t \]
      5. neg-lowering-neg.f6477.9

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

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

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

Alternative 6: 88.8% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 z #s(literal 1 binary64)) < 4.9999999999999997e167

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(1 - z\right) + \left(\mathsf{neg}\left(\left(t + -1 \cdot \left(\log y \cdot \left(x - 1\right)\right)\right)\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y + \log y \cdot \left(x - 1\right)\right) - t} \]
    13. Step-by-step derivation
      1. --lowering--.f64N/A

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

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

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

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

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

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

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

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

    if 4.9999999999999997e167 < (-.f64 z #s(literal 1 binary64))

    1. Initial program 52.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 z around inf

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(y\right)\right)} \cdot z - t \]
      5. neg-lowering-neg.f6477.9

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

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

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

Alternative 7: 77.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y - t\\
\mathbf{if}\;x \leq -0.000106:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.06e-4 or 185 < x

    1. Initial program 94.7%

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

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

        \[\leadsto \color{blue}{\log y \cdot x} - t \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\log y \cdot x} - t \]
      3. log-lowering-log.f6493.2

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

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

    if -1.06e-4 < x < 185

    1. Initial program 85.4%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \left(y \cdot \mathsf{fma}\left(y, y \cdot \frac{-1}{3} + \color{blue}{\frac{-1}{2}}, -1\right)\right)\right) - t \]
      8. accelerator-lowering-fma.f64100.0

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(1 - z\right) + \left(\mathsf{neg}\left(\left(t + -1 \cdot \left(\log y \cdot \left(x - 1\right)\right)\right)\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{-1 \cdot t}\right) \]
    13. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{\mathsf{neg}\left(t\right)}\right) \]
      2. neg-lowering-neg.f6462.9

        \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{-t}\right) \]
    14. Simplified62.9%

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

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

Alternative 8: 88.7% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 z #s(literal 1 binary64)) < 4.9999999999999997e167

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

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

        \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right) + \left(\mathsf{neg}\left(t\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x - 1, \mathsf{neg}\left(t\right)\right)} \]
      3. log-lowering-log.f64N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-1 + x}, \mathsf{neg}\left(t\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\log y, \color{blue}{-1 + x}, \mathsf{neg}\left(t\right)\right) \]
      8. neg-lowering-neg.f6493.8

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

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

    if 4.9999999999999997e167 < (-.f64 z #s(literal 1 binary64))

    1. Initial program 52.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 z around inf

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(y\right)\right)} \cdot z - t \]
      5. neg-lowering-neg.f6477.9

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

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

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

Alternative 9: 99.3% accurate, 1.9× speedup?

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

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

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

    \[\leadsto \color{blue}{\left(-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. mul-1-negN/A

      \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(y \cdot \left(z - 1\right)\right)\right)} + \log y \cdot \left(x - 1\right)\right) - t \]
    2. distribute-rgt-neg-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 65.7% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -4.4 \cdot 10^{+166}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.85 \cdot 10^{+20}:\\
\;\;\;\;\mathsf{fma}\left(y, 1 - z, -t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.3999999999999998e166 or 1.85e20 < x

    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. Add Preprocessing
    3. Taylor expanded in x around inf

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

        \[\leadsto \color{blue}{\log y \cdot x} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\log y \cdot x} \]
      3. log-lowering-log.f6477.5

        \[\leadsto \color{blue}{\log y} \cdot x \]
    5. Simplified77.5%

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

    if -4.3999999999999998e166 < x < 1.85e20

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(1 - z\right) + \left(\mathsf{neg}\left(\left(t + -1 \cdot \left(\log y \cdot \left(x - 1\right)\right)\right)\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, 1 - z, \log y \cdot \left(x + \color{blue}{-1}\right) - t\right) \]
      14. +-lowering-+.f6499.2

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

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

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{-1 \cdot t}\right) \]
    13. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{\mathsf{neg}\left(t\right)}\right) \]
      2. neg-lowering-neg.f6461.1

        \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{-t}\right) \]
    14. Simplified61.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{+166}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{+20}:\\ \;\;\;\;\mathsf{fma}\left(y, 1 - z, -t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 43.4% accurate, 11.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -7.6 \cdot 10^{+18}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 270:\\ \;\;\;\;-y \cdot z\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= t -7.6e+18) (- t) (if (<= t 270.0) (- (* y z)) (- t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -7.6e+18) {
		tmp = -t;
	} else if (t <= 270.0) {
		tmp = -(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 <= (-7.6d+18)) then
        tmp = -t
    else if (t <= 270.0d0) then
        tmp = -(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 <= -7.6e+18) {
		tmp = -t;
	} else if (t <= 270.0) {
		tmp = -(y * z);
	} else {
		tmp = -t;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if t <= -7.6e+18:
		tmp = -t
	elif t <= 270.0:
		tmp = -(y * z)
	else:
		tmp = -t
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -7.6e+18)
		tmp = Float64(-t);
	elseif (t <= 270.0)
		tmp = Float64(-Float64(y * z));
	else
		tmp = Float64(-t);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -7.6e+18)
		tmp = -t;
	elseif (t <= 270.0)
		tmp = -(y * z);
	else
		tmp = -t;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[t, -7.6e+18], (-t), If[LessEqual[t, 270.0], (-N[(y * z), $MachinePrecision]), (-t)]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.6 \cdot 10^{+18}:\\
\;\;\;\;-t\\

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

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


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

    1. Initial program 94.9%

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

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

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

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

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

    if -7.6e18 < t < 270

    1. Initial program 85.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(y\right)\right)} \cdot z \]
      5. neg-lowering-neg.f6417.6

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot z \]
      2. neg-lowering-neg.f6416.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -7.6 \cdot 10^{+18}:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 270:\\ \;\;\;\;-y \cdot z\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 46.7% accurate, 18.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(1 - z\right) + \left(\mathsf{neg}\left(\left(t + -1 \cdot \left(\log y \cdot \left(x - 1\right)\right)\right)\right)\right)} \]
    2. accelerator-lowering-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{-1 \cdot t}\right) \]
  13. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{\mathsf{neg}\left(t\right)}\right) \]
    2. neg-lowering-neg.f6446.8

      \[\leadsto \mathsf{fma}\left(y, 1 - z, \color{blue}{-t}\right) \]
  14. Simplified46.8%

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

Alternative 13: 46.5% accurate, 25.1× speedup?

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{neg}\left(y\right)\right)} \cdot z - t \]
    5. neg-lowering-neg.f6447.0

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

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

    \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right) - t} \]
  7. Step-by-step derivation
    1. sub-negN/A

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right) + \left(\mathsf{neg}\left(t\right)\right)} \]
    2. mul-1-negN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(y \cdot z\right)\right)} + \left(\mathsf{neg}\left(t\right)\right) \]
    3. distribute-neg-outN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\left(y \cdot z + t\right)\right)} \]
    4. neg-lowering-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\left(y \cdot z + t\right)\right)} \]
    5. accelerator-lowering-fma.f6446.6

      \[\leadsto -\color{blue}{\mathsf{fma}\left(y, z, t\right)} \]
  8. Simplified46.6%

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

Alternative 14: 36.1% accurate, 75.3× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{neg}\left(t\right)} \]
    2. neg-lowering-neg.f6436.9

      \[\leadsto \color{blue}{-t} \]
  5. Simplified36.9%

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

Reproduce

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