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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 89.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 95.4% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;-1 + x \leq -5 \cdot 10^{+21}:\\
\;\;\;\;x \cdot \log y - t\\

\mathbf{elif}\;-1 + x \leq 200000000000:\\
\;\;\;\;\left(y \cdot \left(\left(--1\right) - z\right) - \log y\right) - t\\

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


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

    1. Initial program 95.1%

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

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

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

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

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

    if -5e21 < (-.f64 x #s(literal 1 binary64)) < 2e11

    1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot \left(y \cdot \left(z - 1\right)\right) - \log y\right)} - t \]
      4. associate-*r*99.3%

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

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

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

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

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

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

    if 2e11 < (-.f64 x #s(literal 1 binary64))

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.7% accurate, 1.7× speedup?

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

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

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

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

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

Alternative 4: 95.6% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;t \leq 860000000000:\\
\;\;\;\;\log y \cdot \left(-1 + x\right) - y \cdot \left(z + -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -3.80000000000000022e27

    1. Initial program 96.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 100.0%

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

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

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

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

    if -3.80000000000000022e27 < t < 8.6e11

    1. Initial program 86.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.6e11 < t

    1. Initial program 96.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto t \cdot \left(\log y \cdot \frac{\color{blue}{-1 + x}}{t} + \left(\frac{\log \left(1 - y\right) \cdot \left(z - 1\right)}{t} - 1\right)\right) \]
      6. associate-/l*96.4%

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

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

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

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

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

      \[\leadsto \color{blue}{t \cdot \left(\frac{\log y \cdot \left(x - 1\right)}{t} - 1\right)} \]
    9. Step-by-step derivation
      1. sub-neg96.4%

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

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

        \[\leadsto t \cdot \left(\frac{\log y \cdot \left(x + \color{blue}{-1}\right)}{t} + \left(-1\right)\right) \]
      4. associate-*r/96.4%

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

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

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

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

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

Alternative 5: 99.5% accurate, 1.8× speedup?

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

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

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

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

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

Alternative 6: 87.0% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2600000000000 \lor \neg \left(x \leq 120000000000\right):\\
\;\;\;\;x \cdot \log y - t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.6e12 or 1.2e11 < x

    1. Initial program 94.4%

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

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

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

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

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

    if -2.6e12 < x < 1.2e11

    1. Initial program 86.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 100.0%

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

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

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

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

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

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

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

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

Alternative 7: 89.6% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.65000000000000005e245

    1. Initial program 24.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 100.0%

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

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

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

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

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

    if -1.65000000000000005e245 < z

    1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 99.2% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 89.5% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.4e246

    1. Initial program 24.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 100.0%

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

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

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

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

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

    if -5.4e246 < z

    1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 57.8% accurate, 2.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.50000000000000026e112

    1. Initial program 57.9%

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

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

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

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

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

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

    if -5.50000000000000026e112 < z

    1. Initial program 95.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 99.8%

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

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

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

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

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

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

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

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

Alternative 11: 43.1% accurate, 13.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.85 \cdot 10^{-10} \lor \neg \left(t \leq 900000000000\right):\\
\;\;\;\;-t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.85000000000000007e-10 or 9e11 < t

    1. Initial program 95.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.85000000000000007e-10 < t < 9e11

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-y\right)} \cdot \left(z - 1\right) \]
      3. sub-neg15.6%

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

        \[\leadsto \left(-y\right) \cdot \left(z + \color{blue}{-1}\right) \]
      5. +-commutative15.6%

        \[\leadsto \left(-y\right) \cdot \color{blue}{\left(-1 + z\right)} \]
    10. Simplified15.6%

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

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

Alternative 12: 42.8% accurate, 15.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.85 \cdot 10^{-10} \lor \neg \left(t \leq 900000000000\right):\\
\;\;\;\;-t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1.85000000000000007e-10 or 9e11 < t

    1. Initial program 95.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.85000000000000007e-10 < t < 9e11

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-y\right)} \cdot z \]
    10. Simplified15.0%

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

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

Alternative 13: 46.1% accurate, 19.5× speedup?

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

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

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

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

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

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

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

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

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

Alternative 14: 35.6% accurate, 107.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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