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

Percentage Accurate: 89.1% → 99.6%
Time: 15.7s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 89.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.7% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 670:\\
\;\;\;\;\left(-t\right) - \log y\\

\mathbf{else}:\\
\;\;\;\;x \cdot \log y - t\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < -4.9999999999999999e23

    1. Initial program 96.7%

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

      \[\leadsto \color{blue}{x \cdot \log y} - t \]
    4. Step-by-step derivation
      1. *-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.f6494.1

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{-t}\right) \]
    7. Applied egg-rr94.2%

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

    if -4.9999999999999999e23 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < 670

    1. Initial program 81.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}{\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.f6481.1

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

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

      \[\leadsto \color{blue}{-1 \cdot \log y - t} \]
    7. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \color{blue}{-1 \cdot \log y - t} \]
      2. mul-1-negN/A

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} - t \]
      4. log-lowering-log.f6480.0

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

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

    if 670 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y))))

    1. Initial program 96.6%

      \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
    2. Add Preprocessing
    3. Taylor expanded in 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.4

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

      \[\leadsto \color{blue}{\log y \cdot x} - t \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.6%

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

Alternative 3: 85.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y - t\\ t_2 := \log y \cdot \left(x + -1\right) + \left(-1 + z\right) \cdot \log \left(1 - y\right)\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+23}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 670:\\ \;\;\;\;\left(-t\right) - \log y\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* x (log y)) t))
        (t_2 (+ (* (log y) (+ x -1.0)) (* (+ -1.0 z) (log (- 1.0 y))))))
   (if (<= t_2 -5e+23) t_1 (if (<= t_2 670.0) (- (- t) (log y)) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = (x * log(y)) - t;
	double t_2 = (log(y) * (x + -1.0)) + ((-1.0 + z) * log((1.0 - y)));
	double tmp;
	if (t_2 <= -5e+23) {
		tmp = t_1;
	} else if (t_2 <= 670.0) {
		tmp = -t - log(y);
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (x * log(y)) - t
    t_2 = (log(y) * (x + (-1.0d0))) + (((-1.0d0) + z) * log((1.0d0 - y)))
    if (t_2 <= (-5d+23)) then
        tmp = t_1
    else if (t_2 <= 670.0d0) then
        tmp = -t - log(y)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (x * Math.log(y)) - t;
	double t_2 = (Math.log(y) * (x + -1.0)) + ((-1.0 + z) * Math.log((1.0 - y)));
	double tmp;
	if (t_2 <= -5e+23) {
		tmp = t_1;
	} else if (t_2 <= 670.0) {
		tmp = -t - Math.log(y);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (x * math.log(y)) - t
	t_2 = (math.log(y) * (x + -1.0)) + ((-1.0 + z) * math.log((1.0 - y)))
	tmp = 0
	if t_2 <= -5e+23:
		tmp = t_1
	elif t_2 <= 670.0:
		tmp = -t - math.log(y)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(x * log(y)) - t)
	t_2 = Float64(Float64(log(y) * Float64(x + -1.0)) + Float64(Float64(-1.0 + z) * log(Float64(1.0 - y))))
	tmp = 0.0
	if (t_2 <= -5e+23)
		tmp = t_1;
	elseif (t_2 <= 670.0)
		tmp = Float64(Float64(-t) - log(y));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x * log(y)) - t;
	t_2 = (log(y) * (x + -1.0)) + ((-1.0 + z) * log((1.0 - y)));
	tmp = 0.0;
	if (t_2 <= -5e+23)
		tmp = t_1;
	elseif (t_2 <= 670.0)
		tmp = -t - log(y);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Log[y], $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + z), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+23], t$95$1, If[LessEqual[t$95$2, 670.0], N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y - t\\
t_2 := \log y \cdot \left(x + -1\right) + \left(-1 + z\right) \cdot \log \left(1 - y\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 670:\\
\;\;\;\;\left(-t\right) - \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < -4.9999999999999999e23 or 670 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y))))

    1. Initial program 96.6%

      \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
    2. Add Preprocessing
    3. Taylor expanded in 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.7

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

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

    if -4.9999999999999999e23 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < 670

    1. Initial program 81.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}{\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.f6481.1

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

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

      \[\leadsto \color{blue}{-1 \cdot \log y - t} \]
    7. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \color{blue}{-1 \cdot \log y - t} \]
      2. mul-1-negN/A

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} - t \]
      4. log-lowering-log.f6480.0

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

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

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

Alternative 4: 76.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \log y \cdot \left(x + -1\right)\\ t_2 := t\_1 + \left(-1 + z\right) \cdot \log \left(1 - y\right)\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+23}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;t\_2 \leq 10^{+23}:\\ \;\;\;\;\left(-t\right) - \log y\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* (log y) (+ x -1.0)))
        (t_2 (+ t_1 (* (+ -1.0 z) (log (- 1.0 y))))))
   (if (<= t_2 -5e+23)
     (* x (log y))
     (if (<= t_2 1e+23) (- (- t) (log y)) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = log(y) * (x + -1.0);
	double t_2 = t_1 + ((-1.0 + z) * log((1.0 - y)));
	double tmp;
	if (t_2 <= -5e+23) {
		tmp = x * log(y);
	} else if (t_2 <= 1e+23) {
		tmp = -t - log(y);
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = log(y) * (x + (-1.0d0))
    t_2 = t_1 + (((-1.0d0) + z) * log((1.0d0 - y)))
    if (t_2 <= (-5d+23)) then
        tmp = x * log(y)
    else if (t_2 <= 1d+23) then
        tmp = -t - log(y)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = Math.log(y) * (x + -1.0);
	double t_2 = t_1 + ((-1.0 + z) * Math.log((1.0 - y)));
	double tmp;
	if (t_2 <= -5e+23) {
		tmp = x * Math.log(y);
	} else if (t_2 <= 1e+23) {
		tmp = -t - Math.log(y);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = math.log(y) * (x + -1.0)
	t_2 = t_1 + ((-1.0 + z) * math.log((1.0 - y)))
	tmp = 0
	if t_2 <= -5e+23:
		tmp = x * math.log(y)
	elif t_2 <= 1e+23:
		tmp = -t - math.log(y)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(log(y) * Float64(x + -1.0))
	t_2 = Float64(t_1 + Float64(Float64(-1.0 + z) * log(Float64(1.0 - y))))
	tmp = 0.0
	if (t_2 <= -5e+23)
		tmp = Float64(x * log(y));
	elseif (t_2 <= 1e+23)
		tmp = Float64(Float64(-t) - log(y));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = log(y) * (x + -1.0);
	t_2 = t_1 + ((-1.0 + z) * log((1.0 - y)));
	tmp = 0.0;
	if (t_2 <= -5e+23)
		tmp = x * log(y);
	elseif (t_2 <= 1e+23)
		tmp = -t - log(y);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Log[y], $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(N[(-1.0 + z), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+23], N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+23], N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \log y \cdot \left(x + -1\right)\\
t_2 := t\_1 + \left(-1 + z\right) \cdot \log \left(1 - y\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+23}:\\
\;\;\;\;x \cdot \log y\\

\mathbf{elif}\;t\_2 \leq 10^{+23}:\\
\;\;\;\;\left(-t\right) - \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < -4.9999999999999999e23

    1. Initial program 96.7%

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

      \[\leadsto \color{blue}{x \cdot \log y} \]
    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.f6479.0

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

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

    if -4.9999999999999999e23 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < 9.9999999999999992e22

    1. Initial program 81.6%

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

      \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right) - t} \]
    4. Step-by-step derivation
      1. 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.f6481.6

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

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

      \[\leadsto \color{blue}{-1 \cdot \log y - t} \]
    7. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \color{blue}{-1 \cdot \log y - t} \]
      2. mul-1-negN/A

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} - t \]
      4. log-lowering-log.f6480.0

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

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

    if 9.9999999999999992e22 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y))))

    1. Initial program 97.5%

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

      \[\leadsto \color{blue}{\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.f6495.0

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

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

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

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

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

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

        \[\leadsto \log y \cdot \left(x + \color{blue}{-1}\right) \]
      5. +-lowering-+.f6477.2

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

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

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

Alternative 5: 76.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ t_2 := \log y \cdot \left(x + -1\right) + \left(-1 + z\right) \cdot \log \left(1 - y\right)\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+23}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 10^{+23}:\\ \;\;\;\;\left(-t\right) - \log y\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y)))
        (t_2 (+ (* (log y) (+ x -1.0)) (* (+ -1.0 z) (log (- 1.0 y))))))
   (if (<= t_2 -5e+23) t_1 (if (<= t_2 1e+23) (- (- t) (log y)) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double t_2 = (log(y) * (x + -1.0)) + ((-1.0 + z) * log((1.0 - y)));
	double tmp;
	if (t_2 <= -5e+23) {
		tmp = t_1;
	} else if (t_2 <= 1e+23) {
		tmp = -t - log(y);
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x * log(y)
    t_2 = (log(y) * (x + (-1.0d0))) + (((-1.0d0) + z) * log((1.0d0 - y)))
    if (t_2 <= (-5d+23)) then
        tmp = t_1
    else if (t_2 <= 1d+23) then
        tmp = -t - log(y)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x * Math.log(y);
	double t_2 = (Math.log(y) * (x + -1.0)) + ((-1.0 + z) * Math.log((1.0 - y)));
	double tmp;
	if (t_2 <= -5e+23) {
		tmp = t_1;
	} else if (t_2 <= 1e+23) {
		tmp = -t - Math.log(y);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x * math.log(y)
	t_2 = (math.log(y) * (x + -1.0)) + ((-1.0 + z) * math.log((1.0 - y)))
	tmp = 0
	if t_2 <= -5e+23:
		tmp = t_1
	elif t_2 <= 1e+23:
		tmp = -t - math.log(y)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	t_2 = Float64(Float64(log(y) * Float64(x + -1.0)) + Float64(Float64(-1.0 + z) * log(Float64(1.0 - y))))
	tmp = 0.0
	if (t_2 <= -5e+23)
		tmp = t_1;
	elseif (t_2 <= 1e+23)
		tmp = Float64(Float64(-t) - log(y));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * log(y);
	t_2 = (log(y) * (x + -1.0)) + ((-1.0 + z) * log((1.0 - y)));
	tmp = 0.0;
	if (t_2 <= -5e+23)
		tmp = t_1;
	elseif (t_2 <= 1e+23)
		tmp = -t - log(y);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Log[y], $MachinePrecision] * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + z), $MachinePrecision] * N[Log[N[(1.0 - y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+23], t$95$1, If[LessEqual[t$95$2, 1e+23], N[((-t) - N[Log[y], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
t_2 := \log y \cdot \left(x + -1\right) + \left(-1 + z\right) \cdot \log \left(1 - y\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq 10^{+23}:\\
\;\;\;\;\left(-t\right) - \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < -4.9999999999999999e23 or 9.9999999999999992e22 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y))))

    1. Initial program 97.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.f6478.0

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

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

    if -4.9999999999999999e23 < (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) < 9.9999999999999992e22

    1. Initial program 81.6%

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

      \[\leadsto \color{blue}{\log y \cdot \left(x - 1\right) - t} \]
    4. Step-by-step derivation
      1. 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.f6481.6

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

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

      \[\leadsto \color{blue}{-1 \cdot \log y - t} \]
    7. Step-by-step derivation
      1. --lowering--.f64N/A

        \[\leadsto \color{blue}{-1 \cdot \log y - t} \]
      2. mul-1-negN/A

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\log y\right)\right)} - t \]
      4. log-lowering-log.f6480.0

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

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

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

Alternative 6: 95.3% 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 -1.0000002:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x + -1 \leq 50000000:\\ \;\;\;\;\left(y - \log y\right) - \mathsf{fma}\left(y, z, t\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) -1.0000002)
     t_1
     (if (<= (+ x -1.0) 50000000.0) (- (- y (log y)) (fma y z t)) 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) <= -1.0000002) {
		tmp = t_1;
	} else if ((x + -1.0) <= 50000000.0) {
		tmp = (y - log(y)) - fma(y, z, t);
	} 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) <= -1.0000002)
		tmp = t_1;
	elseif (Float64(x + -1.0) <= 50000000.0)
		tmp = Float64(Float64(y - log(y)) - fma(y, z, t));
	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], -1.0000002], t$95$1, If[LessEqual[N[(x + -1.0), $MachinePrecision], 50000000.0], N[(N[(y - N[Log[y], $MachinePrecision]), $MachinePrecision] - N[(y * z + t), $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 -1.0000002:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 97.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}{\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.f6495.7

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

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

    if -1.00000019999999989 < (-.f64 x #s(literal 1 binary64)) < 5e7

    1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\log y}{\frac{1}{\color{blue}{x + \left(\mathsf{neg}\left(1\right)\right)}}} + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
      12. metadata-eval81.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(y - \log y\right) - \color{blue}{\left(y \cdot z + t\right)} \]
      7. accelerator-lowering-fma.f6498.5

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

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

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

Alternative 7: 90.0% accurate, 1.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 z #s(literal 1 binary64)) < -2.00000000000000014e246 or 2.00000000000000017e218 < (-.f64 z #s(literal 1 binary64))

    1. Initial program 58.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 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.f6485.8

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

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

    if -2.00000000000000014e246 < (-.f64 z #s(literal 1 binary64)) < 2.00000000000000017e218

    1. Initial program 93.8%

      \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
    2. 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.5

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

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

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

Alternative 8: 66.5% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x + -1 \leq -2 \cdot 10^{+42}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x + -1 \leq 4 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{fma}\left(y, -z, y\right) - t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))))
   (if (<= (+ x -1.0) -2e+42)
     t_1
     (if (<= (+ x -1.0) 4e+73) (- (fma y (- z) y) t) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double tmp;
	if ((x + -1.0) <= -2e+42) {
		tmp = t_1;
	} else if ((x + -1.0) <= 4e+73) {
		tmp = fma(y, -z, y) - t;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	tmp = 0.0
	if (Float64(x + -1.0) <= -2e+42)
		tmp = t_1;
	elseif (Float64(x + -1.0) <= 4e+73)
		tmp = Float64(fma(y, Float64(-z), y) - 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[N[(x + -1.0), $MachinePrecision], -2e+42], t$95$1, If[LessEqual[N[(x + -1.0), $MachinePrecision], 4e+73], N[(N[(y * (-z) + y), $MachinePrecision] - t), $MachinePrecision], t$95$1]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 98.6%

      \[\left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
    2. Add Preprocessing
    3. Taylor expanded in 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.f6482.5

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

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

    if -2.00000000000000009e42 < (-.f64 x #s(literal 1 binary64)) < 3.99999999999999993e73

    1. Initial program 81.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. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\log y}{\frac{1}{x + -1}} + \color{blue}{\left(y - y \cdot z\right)}\right) - t \]
      15. *-lowering-*.f6499.0

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 99.1% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 42.8% accurate, 10.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1900000:\\
\;\;\;\;-t\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.9e6 or 1.8e9 < t

    1. Initial program 96.5%

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

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

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

        \[\leadsto \color{blue}{-t} \]
    5. Simplified66.2%

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

    if -1.9e6 < t < 1.8e9

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(1 + \color{blue}{-1 \cdot z}\right) \]
      3. distribute-lft-inN/A

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

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

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

        \[\leadsto \color{blue}{y \cdot 1 - y \cdot z} \]
      7. *-rgt-identityN/A

        \[\leadsto \color{blue}{y} - y \cdot z \]
      8. --lowering--.f64N/A

        \[\leadsto \color{blue}{y - y \cdot z} \]
      9. *-lowering-*.f6421.9

        \[\leadsto y - \color{blue}{y \cdot z} \]
    11. Simplified21.9%

      \[\leadsto \color{blue}{y - y \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 42.6% accurate, 11.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -500000:\\
\;\;\;\;-t\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -5e5 or 4.5e8 < t

    1. Initial program 96.5%

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

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

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

        \[\leadsto \color{blue}{-t} \]
    5. Simplified66.2%

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

    if -5e5 < t < 4.5e8

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(-1 \cdot z\right)} \]
      5. neg-mul-1N/A

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -500000:\\ \;\;\;\;-t\\ \mathbf{elif}\;t \leq 450000000:\\ \;\;\;\;-y \cdot z\\ \mathbf{else}:\\ \;\;\;\;-t\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 46.0% accurate, 18.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{\log y}{\frac{1}{\color{blue}{x + \left(\mathsf{neg}\left(1\right)\right)}}} + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
    12. metadata-eval88.5

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{\log y}{\frac{1}{x + -1}} + \color{blue}{\left(y - y \cdot z\right)}\right) - t \]
    15. *-lowering-*.f6499.0

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

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

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

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

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

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

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

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

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

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

Alternative 13: 45.8% accurate, 20.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{\log y}{\frac{1}{\color{blue}{x + \left(\mathsf{neg}\left(1\right)\right)}}} + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t \]
    12. metadata-eval88.5

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{\log y}{\frac{1}{x + -1}} + \color{blue}{\left(y - y \cdot z\right)}\right) - t \]
    15. *-lowering-*.f6499.0

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

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

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

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

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

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

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

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

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

Alternative 14: 35.3% 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 88.5%

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

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

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

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

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

Alternative 15: 2.9% accurate, 226.0× speedup?

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

\\
y
\end{array}
Derivation
  1. Initial program 88.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto y \cdot \left(1 + \color{blue}{-1 \cdot z}\right) \]
    3. distribute-lft-inN/A

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

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

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

      \[\leadsto \color{blue}{y \cdot 1 - y \cdot z} \]
    7. *-rgt-identityN/A

      \[\leadsto \color{blue}{y} - y \cdot z \]
    8. --lowering--.f64N/A

      \[\leadsto \color{blue}{y - y \cdot z} \]
    9. *-lowering-*.f6413.8

      \[\leadsto y - \color{blue}{y \cdot z} \]
  11. Simplified13.8%

    \[\leadsto \color{blue}{y - y \cdot z} \]
  12. Taylor expanded in z around 0

    \[\leadsto \color{blue}{y} \]
  13. Step-by-step derivation
    1. Simplified2.9%

      \[\leadsto \color{blue}{y} \]
    2. Add Preprocessing

    Reproduce

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