Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2

Percentage Accurate: 99.9% → 99.9%
Time: 6.7s
Alternatives: 8
Speedup: 1.0×

Specification

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

\\
\left(x \cdot \log y - z\right) - y
\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 8 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: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

    \[\left(x \cdot \log y - z\right) - y \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 81.7% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \left(x \cdot \log y - z\right) - y\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+168}:\\
\;\;\;\;\left(-z\right) - y\\

\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-74}:\\
\;\;\;\;\log y \cdot x - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (-.f64 (*.f64 x (log.f64 y)) z) y) < -9.9999999999999993e167

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} - y \]
      2. lower-neg.f6485.2

        \[\leadsto \color{blue}{\left(-z\right)} - y \]
    5. Applied rewrites85.2%

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

    if -9.9999999999999993e167 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) z) y) < -9.99999999999999958e-75

    1. Initial program 99.9%

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

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

        \[\leadsto x \cdot \log y - \color{blue}{1 \cdot y} \]
      2. metadata-evalN/A

        \[\leadsto x \cdot \log y - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot y \]
      3. fp-cancel-sign-sub-invN/A

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

        \[\leadsto \color{blue}{\log y \cdot x} + -1 \cdot y \]
      5. lower-fma.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\mathsf{neg}\left(y\right)}\right) \]
      8. lower-neg.f6482.9

        \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{-y}\right) \]
    5. Applied rewrites82.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, -y\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites82.9%

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

      if -9.99999999999999958e-75 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) z) y)

      1. Initial program 99.7%

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

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

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

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

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

          \[\leadsto \left(-1 \cdot \frac{y}{z}\right) \cdot z \]
        3. Step-by-step derivation
          1. Applied rewrites2.6%

            \[\leadsto \frac{y}{-z} \cdot z \]
          2. Taylor expanded in y around 0

            \[\leadsto \color{blue}{x \cdot \log y - z} \]
          3. Step-by-step derivation
            1. *-lft-identityN/A

              \[\leadsto x \cdot \log y - \color{blue}{1 \cdot z} \]
            2. metadata-evalN/A

              \[\leadsto x \cdot \log y - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot z \]
            3. fp-cancel-sign-sub-invN/A

              \[\leadsto \color{blue}{x \cdot \log y + -1 \cdot z} \]
            4. *-commutativeN/A

              \[\leadsto \color{blue}{\log y \cdot x} + -1 \cdot z \]
            5. lower-fma.f64N/A

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

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

              \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\mathsf{neg}\left(z\right)}\right) \]
            8. lower-neg.f6497.8

              \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{-z}\right) \]
          4. Applied rewrites97.8%

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

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

        Alternative 3: 81.7% accurate, 0.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x \cdot \log y - z\right) - y\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+168}:\\ \;\;\;\;\left(-z\right) - y\\ \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-74}:\\ \;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log y, x, -z\right)\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (- (- (* x (log y)) z) y)))
           (if (<= t_0 -1e+168)
             (- (- z) y)
             (if (<= t_0 -1e-74) (fma (log y) x (- y)) (fma (log y) x (- z))))))
        double code(double x, double y, double z) {
        	double t_0 = ((x * log(y)) - z) - y;
        	double tmp;
        	if (t_0 <= -1e+168) {
        		tmp = -z - y;
        	} else if (t_0 <= -1e-74) {
        		tmp = fma(log(y), x, -y);
        	} else {
        		tmp = fma(log(y), x, -z);
        	}
        	return tmp;
        }
        
        function code(x, y, z)
        	t_0 = Float64(Float64(Float64(x * log(y)) - z) - y)
        	tmp = 0.0
        	if (t_0 <= -1e+168)
        		tmp = Float64(Float64(-z) - y);
        	elseif (t_0 <= -1e-74)
        		tmp = fma(log(y), x, Float64(-y));
        	else
        		tmp = fma(log(y), x, Float64(-z));
        	end
        	return tmp
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+168], N[((-z) - y), $MachinePrecision], If[LessEqual[t$95$0, -1e-74], N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * x + (-z)), $MachinePrecision]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \left(x \cdot \log y - z\right) - y\\
        \mathbf{if}\;t\_0 \leq -1 \cdot 10^{+168}:\\
        \;\;\;\;\left(-z\right) - y\\
        
        \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-74}:\\
        \;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(\log y, x, -z\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (-.f64 (-.f64 (*.f64 x (log.f64 y)) z) y) < -9.9999999999999993e167

          1. Initial program 99.9%

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

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

              \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} - y \]
            2. lower-neg.f6485.2

              \[\leadsto \color{blue}{\left(-z\right)} - y \]
          5. Applied rewrites85.2%

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

          if -9.9999999999999993e167 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) z) y) < -9.99999999999999958e-75

          1. Initial program 99.9%

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

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

              \[\leadsto x \cdot \log y - \color{blue}{1 \cdot y} \]
            2. metadata-evalN/A

              \[\leadsto x \cdot \log y - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot y \]
            3. fp-cancel-sign-sub-invN/A

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

              \[\leadsto \color{blue}{\log y \cdot x} + -1 \cdot y \]
            5. lower-fma.f64N/A

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

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

              \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\mathsf{neg}\left(y\right)}\right) \]
            8. lower-neg.f6482.9

              \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{-y}\right) \]
          5. Applied rewrites82.9%

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

          if -9.99999999999999958e-75 < (-.f64 (-.f64 (*.f64 x (log.f64 y)) z) y)

          1. Initial program 99.7%

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

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

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

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

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

              \[\leadsto \left(-1 \cdot \frac{y}{z}\right) \cdot z \]
            3. Step-by-step derivation
              1. Applied rewrites2.6%

                \[\leadsto \frac{y}{-z} \cdot z \]
              2. Taylor expanded in y around 0

                \[\leadsto \color{blue}{x \cdot \log y - z} \]
              3. Step-by-step derivation
                1. *-lft-identityN/A

                  \[\leadsto x \cdot \log y - \color{blue}{1 \cdot z} \]
                2. metadata-evalN/A

                  \[\leadsto x \cdot \log y - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot z \]
                3. fp-cancel-sign-sub-invN/A

                  \[\leadsto \color{blue}{x \cdot \log y + -1 \cdot z} \]
                4. *-commutativeN/A

                  \[\leadsto \color{blue}{\log y \cdot x} + -1 \cdot z \]
                5. lower-fma.f64N/A

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

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

                  \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\mathsf{neg}\left(z\right)}\right) \]
                8. lower-neg.f6497.8

                  \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{-z}\right) \]
              4. Applied rewrites97.8%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, -z\right)} \]
            4. Recombined 3 regimes into one program.
            5. Add Preprocessing

            Alternative 4: 84.4% accurate, 0.9× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4600000 \lor \neg \left(z \leq 1.8 \cdot 10^{+121}\right):\\ \;\;\;\;\left(-z\right) - y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (or (<= z -4600000.0) (not (<= z 1.8e+121)))
               (- (- z) y)
               (fma (log y) x (- y))))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((z <= -4600000.0) || !(z <= 1.8e+121)) {
            		tmp = -z - y;
            	} else {
            		tmp = fma(log(y), x, -y);
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	tmp = 0.0
            	if ((z <= -4600000.0) || !(z <= 1.8e+121))
            		tmp = Float64(Float64(-z) - y);
            	else
            		tmp = fma(log(y), x, Float64(-y));
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := If[Or[LessEqual[z, -4600000.0], N[Not[LessEqual[z, 1.8e+121]], $MachinePrecision]], N[((-z) - y), $MachinePrecision], N[(N[Log[y], $MachinePrecision] * x + (-y)), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;z \leq -4600000 \lor \neg \left(z \leq 1.8 \cdot 10^{+121}\right):\\
            \;\;\;\;\left(-z\right) - y\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(\log y, x, -y\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if z < -4.6e6 or 1.79999999999999991e121 < z

              1. Initial program 99.9%

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

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

                  \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} - y \]
                2. lower-neg.f6479.8

                  \[\leadsto \color{blue}{\left(-z\right)} - y \]
              5. Applied rewrites79.8%

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

              if -4.6e6 < z < 1.79999999999999991e121

              1. Initial program 99.8%

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

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

                  \[\leadsto x \cdot \log y - \color{blue}{1 \cdot y} \]
                2. metadata-evalN/A

                  \[\leadsto x \cdot \log y - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot y \]
                3. fp-cancel-sign-sub-invN/A

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

                  \[\leadsto \color{blue}{\log y \cdot x} + -1 \cdot y \]
                5. lower-fma.f64N/A

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

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

                  \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\mathsf{neg}\left(y\right)}\right) \]
                8. lower-neg.f6489.6

                  \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{-y}\right) \]
              5. Applied rewrites89.6%

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

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

            Alternative 5: 79.5% accurate, 0.9× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+79} \lor \neg \left(x \leq 2.9 \cdot 10^{+105}\right):\\ \;\;\;\;\log y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(-z\right) - y\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (or (<= x -2.8e+79) (not (<= x 2.9e+105))) (* (log y) x) (- (- z) y)))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((x <= -2.8e+79) || !(x <= 2.9e+105)) {
            		tmp = log(y) * x;
            	} else {
            		tmp = -z - y;
            	}
            	return tmp;
            }
            
            real(8) function code(x, y, z)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8) :: tmp
                if ((x <= (-2.8d+79)) .or. (.not. (x <= 2.9d+105))) then
                    tmp = log(y) * x
                else
                    tmp = -z - y
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z) {
            	double tmp;
            	if ((x <= -2.8e+79) || !(x <= 2.9e+105)) {
            		tmp = Math.log(y) * x;
            	} else {
            		tmp = -z - y;
            	}
            	return tmp;
            }
            
            def code(x, y, z):
            	tmp = 0
            	if (x <= -2.8e+79) or not (x <= 2.9e+105):
            		tmp = math.log(y) * x
            	else:
            		tmp = -z - y
            	return tmp
            
            function code(x, y, z)
            	tmp = 0.0
            	if ((x <= -2.8e+79) || !(x <= 2.9e+105))
            		tmp = Float64(log(y) * x);
            	else
            		tmp = Float64(Float64(-z) - y);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z)
            	tmp = 0.0;
            	if ((x <= -2.8e+79) || ~((x <= 2.9e+105)))
            		tmp = log(y) * x;
            	else
            		tmp = -z - y;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_] := If[Or[LessEqual[x, -2.8e+79], N[Not[LessEqual[x, 2.9e+105]], $MachinePrecision]], N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision], N[((-z) - y), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -2.8 \cdot 10^{+79} \lor \neg \left(x \leq 2.9 \cdot 10^{+105}\right):\\
            \;\;\;\;\log y \cdot x\\
            
            \mathbf{else}:\\
            \;\;\;\;\left(-z\right) - y\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -2.8000000000000001e79 or 2.9000000000000001e105 < x

              1. Initial program 99.7%

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

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

                  \[\leadsto x \cdot \log y - \color{blue}{1 \cdot y} \]
                2. metadata-evalN/A

                  \[\leadsto x \cdot \log y - \color{blue}{\left(\mathsf{neg}\left(-1\right)\right)} \cdot y \]
                3. fp-cancel-sign-sub-invN/A

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

                  \[\leadsto \color{blue}{\log y \cdot x} + -1 \cdot y \]
                5. lower-fma.f64N/A

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

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

                  \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{\mathsf{neg}\left(y\right)}\right) \]
                8. lower-neg.f6482.5

                  \[\leadsto \mathsf{fma}\left(\log y, x, \color{blue}{-y}\right) \]
              5. Applied rewrites82.5%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\log y, x, -y\right)} \]
              6. Step-by-step derivation
                1. Applied rewrites53.1%

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

                  \[\leadsto -1 \cdot \color{blue}{\left(x \cdot \left(\log y \cdot {\left(\sqrt{-1}\right)}^{2}\right)\right)} \]
                3. Step-by-step derivation
                  1. Applied rewrites70.4%

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

                  if -2.8000000000000001e79 < x < 2.9000000000000001e105

                  1. Initial program 99.9%

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

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

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

                      \[\leadsto \color{blue}{\left(-z\right)} - y \]
                  5. Applied rewrites85.9%

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

                  \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{+79} \lor \neg \left(x \leq 2.9 \cdot 10^{+105}\right):\\ \;\;\;\;\log y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(-z\right) - y\\ \end{array} \]
                6. Add Preprocessing

                Alternative 6: 52.4% accurate, 6.2× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -8000000 \lor \neg \left(z \leq 2.3 \cdot 10^{+77}\right):\\ \;\;\;\;-1 \cdot z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \end{array} \]
                (FPCore (x y z)
                 :precision binary64
                 (if (or (<= z -8000000.0) (not (<= z 2.3e+77))) (* -1.0 z) (- y)))
                double code(double x, double y, double z) {
                	double tmp;
                	if ((z <= -8000000.0) || !(z <= 2.3e+77)) {
                		tmp = -1.0 * z;
                	} else {
                		tmp = -y;
                	}
                	return tmp;
                }
                
                real(8) function code(x, y, z)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    real(8), intent (in) :: z
                    real(8) :: tmp
                    if ((z <= (-8000000.0d0)) .or. (.not. (z <= 2.3d+77))) then
                        tmp = (-1.0d0) * z
                    else
                        tmp = -y
                    end if
                    code = tmp
                end function
                
                public static double code(double x, double y, double z) {
                	double tmp;
                	if ((z <= -8000000.0) || !(z <= 2.3e+77)) {
                		tmp = -1.0 * z;
                	} else {
                		tmp = -y;
                	}
                	return tmp;
                }
                
                def code(x, y, z):
                	tmp = 0
                	if (z <= -8000000.0) or not (z <= 2.3e+77):
                		tmp = -1.0 * z
                	else:
                		tmp = -y
                	return tmp
                
                function code(x, y, z)
                	tmp = 0.0
                	if ((z <= -8000000.0) || !(z <= 2.3e+77))
                		tmp = Float64(-1.0 * z);
                	else
                		tmp = Float64(-y);
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y, z)
                	tmp = 0.0;
                	if ((z <= -8000000.0) || ~((z <= 2.3e+77)))
                		tmp = -1.0 * z;
                	else
                		tmp = -y;
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_, z_] := If[Or[LessEqual[z, -8000000.0], N[Not[LessEqual[z, 2.3e+77]], $MachinePrecision]], N[(-1.0 * z), $MachinePrecision], (-y)]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;z \leq -8000000 \lor \neg \left(z \leq 2.3 \cdot 10^{+77}\right):\\
                \;\;\;\;-1 \cdot z\\
                
                \mathbf{else}:\\
                \;\;\;\;-y\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if z < -8e6 or 2.29999999999999995e77 < z

                  1. Initial program 99.9%

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

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

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

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

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

                      \[\leadsto \left(-1 \cdot \frac{y}{z}\right) \cdot z \]
                    3. Step-by-step derivation
                      1. Applied rewrites15.9%

                        \[\leadsto \frac{y}{-z} \cdot z \]
                      2. Taylor expanded in z around inf

                        \[\leadsto -1 \cdot z \]
                      3. Step-by-step derivation
                        1. Applied rewrites62.9%

                          \[\leadsto -1 \cdot z \]

                        if -8e6 < z < 2.29999999999999995e77

                        1. Initial program 99.8%

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

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

                            \[\leadsto \color{blue}{\mathsf{neg}\left(y\right)} \]
                          2. lower-neg.f6449.7

                            \[\leadsto \color{blue}{-y} \]
                        5. Applied rewrites49.7%

                          \[\leadsto \color{blue}{-y} \]
                      4. Recombined 2 regimes into one program.
                      5. Final simplification55.5%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8000000 \lor \neg \left(z \leq 2.3 \cdot 10^{+77}\right):\\ \;\;\;\;-1 \cdot z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \]
                      6. Add Preprocessing

                      Alternative 7: 66.4% accurate, 18.7× speedup?

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

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

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

                          \[\leadsto \color{blue}{\left(\mathsf{neg}\left(z\right)\right)} - y \]
                        2. lower-neg.f6465.5

                          \[\leadsto \color{blue}{\left(-z\right)} - y \]
                      5. Applied rewrites65.5%

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

                      Alternative 8: 34.1% accurate, 37.3× speedup?

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

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

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

                          \[\leadsto \color{blue}{\mathsf{neg}\left(y\right)} \]
                        2. lower-neg.f6434.6

                          \[\leadsto \color{blue}{-y} \]
                      5. Applied rewrites34.6%

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

                      Reproduce

                      ?
                      herbie shell --seed 2024326 
                      (FPCore (x y z)
                        :name "Statistics.Distribution.Poisson:$clogProbability from math-functions-0.1.5.2"
                        :precision binary64
                        (- (- (* x (log y)) z) y))