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

Percentage Accurate: 89.7% → 99.1%
Time: 11.0s
Alternatives: 9
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 9 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.7% 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.1% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]
    15. lower-log.f6499.8

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

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

    \[\leadsto \mathsf{fma}\left(-1 \cdot z, y, \left(x - 1\right) \cdot \log y\right) - t \]
  7. Step-by-step derivation
    1. Applied rewrites99.8%

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

    Alternative 2: 87.6% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t\\ \mathbf{if}\;t\_1 \leq -10000000 \lor \neg \left(t\_1 \leq 1000\right):\\ \;\;\;\;\log y \cdot x - t\\ \mathbf{else}:\\ \;\;\;\;\left(-\log y\right) - t\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (let* ((t_1 (- (+ (* (- x 1.0) (log y)) (* (- z 1.0) (log (- 1.0 y)))) t)))
       (if (or (<= t_1 -10000000.0) (not (<= t_1 1000.0)))
         (- (* (log y) x) t)
         (- (- (log y)) t))))
    double code(double x, double y, double z, double t) {
    	double t_1 = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
    	double tmp;
    	if ((t_1 <= -10000000.0) || !(t_1 <= 1000.0)) {
    		tmp = (log(y) * x) - 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) :: t_1
        real(8) :: tmp
        t_1 = (((x - 1.0d0) * log(y)) + ((z - 1.0d0) * log((1.0d0 - y)))) - t
        if ((t_1 <= (-10000000.0d0)) .or. (.not. (t_1 <= 1000.0d0))) then
            tmp = (log(y) * x) - 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 t_1 = (((x - 1.0) * Math.log(y)) + ((z - 1.0) * Math.log((1.0 - y)))) - t;
    	double tmp;
    	if ((t_1 <= -10000000.0) || !(t_1 <= 1000.0)) {
    		tmp = (Math.log(y) * x) - t;
    	} else {
    		tmp = -Math.log(y) - t;
    	}
    	return tmp;
    }
    
    def code(x, y, z, t):
    	t_1 = (((x - 1.0) * math.log(y)) + ((z - 1.0) * math.log((1.0 - y)))) - t
    	tmp = 0
    	if (t_1 <= -10000000.0) or not (t_1 <= 1000.0):
    		tmp = (math.log(y) * x) - t
    	else:
    		tmp = -math.log(y) - t
    	return tmp
    
    function code(x, y, z, t)
    	t_1 = Float64(Float64(Float64(Float64(x - 1.0) * log(y)) + Float64(Float64(z - 1.0) * log(Float64(1.0 - y)))) - t)
    	tmp = 0.0
    	if ((t_1 <= -10000000.0) || !(t_1 <= 1000.0))
    		tmp = Float64(Float64(log(y) * x) - t);
    	else
    		tmp = Float64(Float64(-log(y)) - t);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z, t)
    	t_1 = (((x - 1.0) * log(y)) + ((z - 1.0) * log((1.0 - y)))) - t;
    	tmp = 0.0;
    	if ((t_1 <= -10000000.0) || ~((t_1 <= 1000.0)))
    		tmp = (log(y) * x) - t;
    	else
    		tmp = -log(y) - t;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_, t_] := Block[{t$95$1 = 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]}, If[Or[LessEqual[t$95$1, -10000000.0], N[Not[LessEqual[t$95$1, 1000.0]], $MachinePrecision]], N[(N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision] - t), $MachinePrecision], N[((-N[Log[y], $MachinePrecision]) - t), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \left(\left(x - 1\right) \cdot \log y + \left(z - 1\right) \cdot \log \left(1 - y\right)\right) - t\\
    \mathbf{if}\;t\_1 \leq -10000000 \lor \neg \left(t\_1 \leq 1000\right):\\
    \;\;\;\;\log y \cdot x - t\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(-\log y\right) - t\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t) < -1e7 or 1e3 < (-.f64 (+.f64 (*.f64 (-.f64 x #s(literal 1 binary64)) (log.f64 y)) (*.f64 (-.f64 z #s(literal 1 binary64)) (log.f64 (-.f64 #s(literal 1 binary64) y)))) t)

      1. Initial program 94.6%

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

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

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

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

          \[\leadsto \color{blue}{\log y} \cdot x - t \]
      5. Applied rewrites93.9%

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

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

      1. Initial program 75.8%

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

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

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

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

          \[\leadsto \color{blue}{\left(x - 1\right)} \cdot \log y - t \]
        4. lower-log.f6475.8

          \[\leadsto \left(x - 1\right) \cdot \color{blue}{\log y} - t \]
      5. Applied rewrites75.8%

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

        \[\leadsto -1 \cdot \color{blue}{\log y} - t \]
      7. Step-by-step derivation
        1. Applied rewrites74.1%

          \[\leadsto \left(-\log y\right) - t \]
      8. Recombined 2 regimes into one program.
      9. Final simplification89.9%

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

      Alternative 3: 96.0% accurate, 1.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x - 1 \leq -1.00000005 \lor \neg \left(x - 1 \leq 50\right):\\ \;\;\;\;\left(x - 1\right) \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, -\log y\right) - t\\ \end{array} \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (if (or (<= (- x 1.0) -1.00000005) (not (<= (- x 1.0) 50.0)))
         (- (* (- x 1.0) (log y)) t)
         (- (fma (- z) y (- (log y))) t)))
      double code(double x, double y, double z, double t) {
      	double tmp;
      	if (((x - 1.0) <= -1.00000005) || !((x - 1.0) <= 50.0)) {
      		tmp = ((x - 1.0) * log(y)) - t;
      	} else {
      		tmp = fma(-z, y, -log(y)) - t;
      	}
      	return tmp;
      }
      
      function code(x, y, z, t)
      	tmp = 0.0
      	if ((Float64(x - 1.0) <= -1.00000005) || !(Float64(x - 1.0) <= 50.0))
      		tmp = Float64(Float64(Float64(x - 1.0) * log(y)) - t);
      	else
      		tmp = Float64(fma(Float64(-z), y, Float64(-log(y))) - t);
      	end
      	return tmp
      end
      
      code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x - 1.0), $MachinePrecision], -1.00000005], N[Not[LessEqual[N[(x - 1.0), $MachinePrecision], 50.0]], $MachinePrecision]], N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[((-z) * y + (-N[Log[y], $MachinePrecision])), $MachinePrecision] - t), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x - 1 \leq -1.00000005 \lor \neg \left(x - 1 \leq 50\right):\\
      \;\;\;\;\left(x - 1\right) \cdot \log y - t\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(-z, y, -\log y\right) - t\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (-.f64 x #s(literal 1 binary64)) < -1.00000004999999992 or 50 < (-.f64 x #s(literal 1 binary64))

        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

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

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

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

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

            \[\leadsto \left(x - 1\right) \cdot \color{blue}{\log y} - t \]
        5. Applied rewrites96.1%

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

        if -1.00000004999999992 < (-.f64 x #s(literal 1 binary64)) < 50

        1. Initial program 84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]
          15. lower-log.f64100.0

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

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

          \[\leadsto \mathsf{fma}\left(1 - z, y, -1 \cdot \log y\right) - t \]
        7. Step-by-step derivation
          1. Applied rewrites99.6%

            \[\leadsto \mathsf{fma}\left(1 - z, y, -\log y\right) - t \]
          2. Taylor expanded in z around inf

            \[\leadsto \mathsf{fma}\left(-1 \cdot z, y, -\log y\right) - t \]
          3. Step-by-step derivation
            1. Applied rewrites99.6%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;x - 1 \leq -1.00000005 \lor \neg \left(x - 1 \leq 50\right):\\ \;\;\;\;\left(x - 1\right) \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-z, y, -\log y\right) - t\\ \end{array} \]
          6. Add Preprocessing

          Alternative 4: 74.7% accurate, 1.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x - 1 \leq -2 \cdot 10^{+142} \lor \neg \left(x - 1 \leq 2 \cdot 10^{+21}\right):\\ \;\;\;\;\log y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(-\log y\right) - t\\ \end{array} \end{array} \]
          (FPCore (x y z t)
           :precision binary64
           (if (or (<= (- x 1.0) -2e+142) (not (<= (- x 1.0) 2e+21)))
             (* (log y) x)
             (- (- (log y)) t)))
          double code(double x, double y, double z, double t) {
          	double tmp;
          	if (((x - 1.0) <= -2e+142) || !((x - 1.0) <= 2e+21)) {
          		tmp = log(y) * x;
          	} 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 - 1.0d0) <= (-2d+142)) .or. (.not. ((x - 1.0d0) <= 2d+21))) then
                  tmp = log(y) * x
              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 - 1.0) <= -2e+142) || !((x - 1.0) <= 2e+21)) {
          		tmp = Math.log(y) * x;
          	} else {
          		tmp = -Math.log(y) - t;
          	}
          	return tmp;
          }
          
          def code(x, y, z, t):
          	tmp = 0
          	if ((x - 1.0) <= -2e+142) or not ((x - 1.0) <= 2e+21):
          		tmp = math.log(y) * x
          	else:
          		tmp = -math.log(y) - t
          	return tmp
          
          function code(x, y, z, t)
          	tmp = 0.0
          	if ((Float64(x - 1.0) <= -2e+142) || !(Float64(x - 1.0) <= 2e+21))
          		tmp = Float64(log(y) * x);
          	else
          		tmp = Float64(Float64(-log(y)) - t);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z, t)
          	tmp = 0.0;
          	if (((x - 1.0) <= -2e+142) || ~(((x - 1.0) <= 2e+21)))
          		tmp = log(y) * x;
          	else
          		tmp = -log(y) - t;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x - 1.0), $MachinePrecision], -2e+142], N[Not[LessEqual[N[(x - 1.0), $MachinePrecision], 2e+21]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[((-N[Log[y], $MachinePrecision]) - t), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x - 1 \leq -2 \cdot 10^{+142} \lor \neg \left(x - 1 \leq 2 \cdot 10^{+21}\right):\\
          \;\;\;\;\log y \cdot x\\
          
          \mathbf{else}:\\
          \;\;\;\;\left(-\log y\right) - t\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (-.f64 x #s(literal 1 binary64)) < -2.0000000000000001e142 or 2e21 < (-.f64 x #s(literal 1 binary64))

            1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]
              15. lower-log.f6499.5

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

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

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

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

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

                \[\leadsto \color{blue}{\log y} \cdot x \]
            8. Applied rewrites77.7%

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

            if -2.0000000000000001e142 < (-.f64 x #s(literal 1 binary64)) < 2e21

            1. Initial program 87.7%

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

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

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

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

                \[\leadsto \color{blue}{\left(x - 1\right)} \cdot \log y - t \]
              4. lower-log.f6487.7

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

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

              \[\leadsto -1 \cdot \color{blue}{\log y} - t \]
            7. Step-by-step derivation
              1. Applied rewrites77.8%

                \[\leadsto \left(-\log y\right) - t \]
            8. Recombined 2 regimes into one program.
            9. Final simplification77.8%

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

            Alternative 5: 65.9% accurate, 1.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x - 1 \leq -2 \cdot 10^{+142} \lor \neg \left(x - 1 \leq 2 \cdot 10^{+21}\right):\\ \;\;\;\;\log y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(1 - z\right) \cdot y - t\\ \end{array} \end{array} \]
            (FPCore (x y z t)
             :precision binary64
             (if (or (<= (- x 1.0) -2e+142) (not (<= (- x 1.0) 2e+21)))
               (* (log y) x)
               (- (* (- 1.0 z) y) t)))
            double code(double x, double y, double z, double t) {
            	double tmp;
            	if (((x - 1.0) <= -2e+142) || !((x - 1.0) <= 2e+21)) {
            		tmp = log(y) * x;
            	} else {
            		tmp = ((1.0 - z) * 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 - 1.0d0) <= (-2d+142)) .or. (.not. ((x - 1.0d0) <= 2d+21))) then
                    tmp = log(y) * x
                else
                    tmp = ((1.0d0 - z) * y) - t
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z, double t) {
            	double tmp;
            	if (((x - 1.0) <= -2e+142) || !((x - 1.0) <= 2e+21)) {
            		tmp = Math.log(y) * x;
            	} else {
            		tmp = ((1.0 - z) * y) - t;
            	}
            	return tmp;
            }
            
            def code(x, y, z, t):
            	tmp = 0
            	if ((x - 1.0) <= -2e+142) or not ((x - 1.0) <= 2e+21):
            		tmp = math.log(y) * x
            	else:
            		tmp = ((1.0 - z) * y) - t
            	return tmp
            
            function code(x, y, z, t)
            	tmp = 0.0
            	if ((Float64(x - 1.0) <= -2e+142) || !(Float64(x - 1.0) <= 2e+21))
            		tmp = Float64(log(y) * x);
            	else
            		tmp = Float64(Float64(Float64(1.0 - z) * y) - t);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z, t)
            	tmp = 0.0;
            	if (((x - 1.0) <= -2e+142) || ~(((x - 1.0) <= 2e+21)))
            		tmp = log(y) * x;
            	else
            		tmp = ((1.0 - z) * y) - t;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x - 1.0), $MachinePrecision], -2e+142], N[Not[LessEqual[N[(x - 1.0), $MachinePrecision], 2e+21]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision] - t), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x - 1 \leq -2 \cdot 10^{+142} \lor \neg \left(x - 1 \leq 2 \cdot 10^{+21}\right):\\
            \;\;\;\;\log y \cdot x\\
            
            \mathbf{else}:\\
            \;\;\;\;\left(1 - z\right) \cdot y - t\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (-.f64 x #s(literal 1 binary64)) < -2.0000000000000001e142 or 2e21 < (-.f64 x #s(literal 1 binary64))

              1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]
                15. lower-log.f6499.5

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

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

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

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

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

                  \[\leadsto \color{blue}{\log y} \cdot x \]
              8. Applied rewrites77.7%

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

              if -2.0000000000000001e142 < (-.f64 x #s(literal 1 binary64)) < 2e21

              1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]
                15. lower-log.f64100.0

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

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

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

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

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

              Alternative 6: 89.1% accurate, 1.9× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z - 1 \leq 5 \cdot 10^{+272}:\\ \;\;\;\;\left(x - 1\right) \cdot \log y - t\\ \mathbf{else}:\\ \;\;\;\;\left(-y\right) \cdot z - t\\ \end{array} \end{array} \]
              (FPCore (x y z t)
               :precision binary64
               (if (<= (- z 1.0) 5e+272) (- (* (- x 1.0) (log y)) t) (- (* (- y) z) t)))
              double code(double x, double y, double z, double t) {
              	double tmp;
              	if ((z - 1.0) <= 5e+272) {
              		tmp = ((x - 1.0) * log(y)) - t;
              	} 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 ((z - 1.0d0) <= 5d+272) then
                      tmp = ((x - 1.0d0) * log(y)) - t
                  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 ((z - 1.0) <= 5e+272) {
              		tmp = ((x - 1.0) * Math.log(y)) - t;
              	} else {
              		tmp = (-y * z) - t;
              	}
              	return tmp;
              }
              
              def code(x, y, z, t):
              	tmp = 0
              	if (z - 1.0) <= 5e+272:
              		tmp = ((x - 1.0) * math.log(y)) - t
              	else:
              		tmp = (-y * z) - t
              	return tmp
              
              function code(x, y, z, t)
              	tmp = 0.0
              	if (Float64(z - 1.0) <= 5e+272)
              		tmp = Float64(Float64(Float64(x - 1.0) * log(y)) - t);
              	else
              		tmp = Float64(Float64(Float64(-y) * z) - t);
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y, z, t)
              	tmp = 0.0;
              	if ((z - 1.0) <= 5e+272)
              		tmp = ((x - 1.0) * log(y)) - t;
              	else
              		tmp = (-y * z) - t;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_, t_] := If[LessEqual[N[(z - 1.0), $MachinePrecision], 5e+272], N[(N[(N[(x - 1.0), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision], N[(N[((-y) * z), $MachinePrecision] - t), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;z - 1 \leq 5 \cdot 10^{+272}:\\
              \;\;\;\;\left(x - 1\right) \cdot \log y - t\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(-y\right) \cdot z - t\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (-.f64 z #s(literal 1 binary64)) < 4.99999999999999973e272

                1. Initial program 93.2%

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

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

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

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

                    \[\leadsto \color{blue}{\left(x - 1\right)} \cdot \log y - t \]
                  4. lower-log.f6493.2

                    \[\leadsto \left(x - 1\right) \cdot \color{blue}{\log y} - t \]
                5. Applied rewrites93.2%

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

                if 4.99999999999999973e272 < (-.f64 z #s(literal 1 binary64))

                1. Initial program 14.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]
                  15. lower-log.f64100.0

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

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

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

                    \[\leadsto \left(-y\right) \cdot \color{blue}{z} - t \]
                8. Recombined 2 regimes into one program.
                9. Add Preprocessing

                Alternative 7: 45.4% accurate, 18.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]
                  15. lower-log.f6499.8

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

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

                  \[\leadsto y \cdot \color{blue}{\left(1 - z\right)} - t \]
                7. Step-by-step derivation
                  1. Applied rewrites49.9%

                    \[\leadsto \left(1 - z\right) \cdot \color{blue}{y} - t \]
                  2. Add Preprocessing

                  Alternative 8: 45.2% accurate, 20.5× speedup?

                  \[\begin{array}{l} \\ \left(-y\right) \cdot z - 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(Float64(-y) * 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}
                  
                  \\
                  \left(-y\right) \cdot z - t
                  \end{array}
                  
                  Derivation
                  1. Initial program 90.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(1 - z, y, \color{blue}{\left(x - 1\right)} \cdot \log y\right) - t \]
                    15. lower-log.f6499.8

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

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

                    \[\leadsto -1 \cdot \color{blue}{\left(y \cdot z\right)} - t \]
                  7. Step-by-step derivation
                    1. Applied rewrites49.8%

                      \[\leadsto \left(-y\right) \cdot \color{blue}{z} - t \]
                    2. Add Preprocessing

                    Alternative 9: 35.4% accurate, 75.3× speedup?

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

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

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

                        \[\leadsto \color{blue}{\mathsf{neg}\left(t\right)} \]
                      2. lower-neg.f6441.1

                        \[\leadsto \color{blue}{-t} \]
                    5. Applied rewrites41.1%

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

                    Reproduce

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