Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B

Percentage Accurate: 85.4% → 99.8%
Time: 14.1s
Alternatives: 11
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 85.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 1.0× speedup?

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

\\
\left(\left(x \cdot \log y + -0.5 \cdot \left(z \cdot {y}^{2}\right)\right) - z \cdot y\right) - t
\end{array}
Derivation
  1. Initial program 88.2%

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

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

    \[\leadsto \left(\left(x \cdot \log y + -0.5 \cdot \left(z \cdot {y}^{2}\right)\right) - z \cdot y\right) - t \]

Alternative 3: 99.2% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 75.9% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{+26} \lor \neg \left(x \leq 6 \cdot 10^{-13} \lor \neg \left(x \leq 180000000\right) \land x \leq 1.22 \cdot 10^{+116}\right):\\
\;\;\;\;x \cdot \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.20000000000000029e26 or 5.99999999999999968e-13 < x < 1.8e8 or 1.21999999999999993e116 < x

    1. Initial program 98.8%

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

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

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

    if -3.20000000000000029e26 < x < 5.99999999999999968e-13 or 1.8e8 < x < 1.21999999999999993e116

    1. Initial program 81.2%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{+26} \lor \neg \left(x \leq 6 \cdot 10^{-13} \lor \neg \left(x \leq 180000000\right) \land x \leq 1.22 \cdot 10^{+116}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right) - t\\ \end{array} \]

Alternative 5: 75.8% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot \log y\\ \mathbf{if}\;x \leq -3.8 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-11}:\\ \;\;\;\;-\mathsf{fma}\left(y, z, t\right)\\ \mathbf{elif}\;x \leq 110000000000 \lor \neg \left(x \leq 2.9 \cdot 10^{+114}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right) - t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (log y))))
   (if (<= x -3.8e+25)
     t_1
     (if (<= x 1.8e-11)
       (- (fma y z t))
       (if (or (<= x 110000000000.0) (not (<= x 2.9e+114)))
         t_1
         (- (* y (- z)) t))))))
double code(double x, double y, double z, double t) {
	double t_1 = x * log(y);
	double tmp;
	if (x <= -3.8e+25) {
		tmp = t_1;
	} else if (x <= 1.8e-11) {
		tmp = -fma(y, z, t);
	} else if ((x <= 110000000000.0) || !(x <= 2.9e+114)) {
		tmp = t_1;
	} else {
		tmp = (y * -z) - t;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(x * log(y))
	tmp = 0.0
	if (x <= -3.8e+25)
		tmp = t_1;
	elseif (x <= 1.8e-11)
		tmp = Float64(-fma(y, z, t));
	elseif ((x <= 110000000000.0) || !(x <= 2.9e+114))
		tmp = t_1;
	else
		tmp = Float64(Float64(y * Float64(-z)) - t);
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.8e+25], t$95$1, If[LessEqual[x, 1.8e-11], (-N[(y * z + t), $MachinePrecision]), If[Or[LessEqual[x, 110000000000.0], N[Not[LessEqual[x, 2.9e+114]], $MachinePrecision]], t$95$1, N[(N[(y * (-z)), $MachinePrecision] - t), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -3.8 \cdot 10^{+25}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.8 \cdot 10^{-11}:\\
\;\;\;\;-\mathsf{fma}\left(y, z, t\right)\\

\mathbf{elif}\;x \leq 110000000000 \lor \neg \left(x \leq 2.9 \cdot 10^{+114}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.8e25 or 1.79999999999999992e-11 < x < 1.1e11 or 2.9e114 < x

    1. Initial program 98.8%

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

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

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

    if -3.8e25 < x < 1.79999999999999992e-11

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\mathsf{fma}\left(y, z, t\right)} \]
    7. Simplified86.3%

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

    if 1.1e11 < x < 2.9e114

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{+25}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-11}:\\ \;\;\;\;-\mathsf{fma}\left(y, z, t\right)\\ \mathbf{elif}\;x \leq 110000000000 \lor \neg \left(x \leq 2.9 \cdot 10^{+114}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right) - t\\ \end{array} \]

Alternative 6: 90.3% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.42 \cdot 10^{-68} \lor \neg \left(x \leq 7.5 \cdot 10^{-116}\right):\\
\;\;\;\;x \cdot \log y - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.42e-68 or 7.5000000000000004e-116 < x

    1. Initial program 94.3%

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

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

    if -1.42e-68 < x < 7.5000000000000004e-116

    1. Initial program 76.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.42 \cdot 10^{-68} \lor \neg \left(x \leq 7.5 \cdot 10^{-116}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \mathsf{log1p}\left(-y\right) - t\\ \end{array} \]

Alternative 7: 90.0% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{-70} \lor \neg \left(x \leq 6.8 \cdot 10^{-116}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(y, z, t\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= x -9.2e-70) (not (<= x 6.8e-116)))
   (- (* x (log y)) t)
   (- (fma y z t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x <= -9.2e-70) || !(x <= 6.8e-116)) {
		tmp = (x * log(y)) - t;
	} else {
		tmp = -fma(y, z, t);
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if ((x <= -9.2e-70) || !(x <= 6.8e-116))
		tmp = Float64(Float64(x * log(y)) - t);
	else
		tmp = Float64(-fma(y, z, t));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -9.2e-70], N[Not[LessEqual[x, 6.8e-116]], $MachinePrecision]], N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], (-N[(y * z + t), $MachinePrecision])]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{-70} \lor \neg \left(x \leq 6.8 \cdot 10^{-116}\right):\\
\;\;\;\;x \cdot \log y - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.20000000000000002e-70 or 6.79999999999999985e-116 < x

    1. Initial program 94.3%

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

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

    if -9.20000000000000002e-70 < x < 6.79999999999999985e-116

    1. Initial program 76.8%

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

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

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

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

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

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

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

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

        \[\leadsto -\color{blue}{\mathsf{fma}\left(y, z, t\right)} \]
    7. Simplified93.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{-70} \lor \neg \left(x \leq 6.8 \cdot 10^{-116}\right):\\ \;\;\;\;x \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;-\mathsf{fma}\left(y, z, t\right)\\ \end{array} \]

Alternative 8: 99.2% accurate, 1.9× speedup?

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

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

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

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

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

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

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

Alternative 9: 48.0% accurate, 25.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.6 \cdot 10^{-173} \lor \neg \left(t \leq 6.5 \cdot 10^{-81}\right):\\
\;\;\;\;-t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.6e-173 or 6.5000000000000002e-81 < t

    1. Initial program 93.4%

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

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

        \[\leadsto \color{blue}{-t} \]
    4. Simplified58.1%

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

    if -1.6e-173 < t < 6.5000000000000002e-81

    1. Initial program 73.8%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-y\right)} \]
    7. Simplified29.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.6 \cdot 10^{-173} \lor \neg \left(t \leq 6.5 \cdot 10^{-81}\right):\\ \;\;\;\;-t\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \]

Alternative 10: 56.8% accurate, 35.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 42.4% accurate, 105.5× speedup?

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

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

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

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

      \[\leadsto \color{blue}{-t} \]
  4. Simplified44.8%

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

    \[\leadsto -t \]

Developer target: 99.6% accurate, 1.6× speedup?

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

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

Reproduce

?
herbie shell --seed 2023320 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (- (* (- z) (+ (+ (* 0.5 (* y y)) y) (* (/ 0.3333333333333333 (* 1.0 (* 1.0 1.0))) (* y (* y y))))) (- t (* x (log y))))

  (- (+ (* x (log y)) (* z (log (- 1.0 y)))) t))