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

Percentage Accurate: 99.9% → 99.9%
Time: 10.0s
Alternatives: 9
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 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: 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, 0.5× speedup?

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

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

    \[\left(x \cdot \log y - z\right) - y \]
  2. Step-by-step derivation
    1. associate--l-99.8%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \log y, -\left(z + y\right)\right)} \]
    3. distribute-neg-in99.8%

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

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

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

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

Alternative 2: 77.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \log y\\ t_1 := \left(-y\right) - z\\ \mathbf{if}\;x \leq -2.15 \cdot 10^{+55}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-5}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{+19} \lor \neg \left(x \leq 2.6 \cdot 10^{+112} \lor \neg \left(x \leq 3 \cdot 10^{+202}\right) \land x \leq 1.1 \cdot 10^{+216}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t\_1}{x}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (log y))) (t_1 (- (- y) z)))
   (if (<= x -2.15e+55)
     t_0
     (if (<= x 4.5e-5)
       t_1
       (if (or (<= x 5.8e+19)
               (not
                (or (<= x 2.6e+112)
                    (and (not (<= x 3e+202)) (<= x 1.1e+216)))))
         t_0
         (* x (/ t_1 x)))))))
double code(double x, double y, double z) {
	double t_0 = x * log(y);
	double t_1 = -y - z;
	double tmp;
	if (x <= -2.15e+55) {
		tmp = t_0;
	} else if (x <= 4.5e-5) {
		tmp = t_1;
	} else if ((x <= 5.8e+19) || !((x <= 2.6e+112) || (!(x <= 3e+202) && (x <= 1.1e+216)))) {
		tmp = t_0;
	} else {
		tmp = x * (t_1 / x);
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * log(y)
    t_1 = -y - z
    if (x <= (-2.15d+55)) then
        tmp = t_0
    else if (x <= 4.5d-5) then
        tmp = t_1
    else if ((x <= 5.8d+19) .or. (.not. (x <= 2.6d+112) .or. (.not. (x <= 3d+202)) .and. (x <= 1.1d+216))) then
        tmp = t_0
    else
        tmp = x * (t_1 / x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * Math.log(y);
	double t_1 = -y - z;
	double tmp;
	if (x <= -2.15e+55) {
		tmp = t_0;
	} else if (x <= 4.5e-5) {
		tmp = t_1;
	} else if ((x <= 5.8e+19) || !((x <= 2.6e+112) || (!(x <= 3e+202) && (x <= 1.1e+216)))) {
		tmp = t_0;
	} else {
		tmp = x * (t_1 / x);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * math.log(y)
	t_1 = -y - z
	tmp = 0
	if x <= -2.15e+55:
		tmp = t_0
	elif x <= 4.5e-5:
		tmp = t_1
	elif (x <= 5.8e+19) or not ((x <= 2.6e+112) or (not (x <= 3e+202) and (x <= 1.1e+216))):
		tmp = t_0
	else:
		tmp = x * (t_1 / x)
	return tmp
function code(x, y, z)
	t_0 = Float64(x * log(y))
	t_1 = Float64(Float64(-y) - z)
	tmp = 0.0
	if (x <= -2.15e+55)
		tmp = t_0;
	elseif (x <= 4.5e-5)
		tmp = t_1;
	elseif ((x <= 5.8e+19) || !((x <= 2.6e+112) || (!(x <= 3e+202) && (x <= 1.1e+216))))
		tmp = t_0;
	else
		tmp = Float64(x * Float64(t_1 / x));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * log(y);
	t_1 = -y - z;
	tmp = 0.0;
	if (x <= -2.15e+55)
		tmp = t_0;
	elseif (x <= 4.5e-5)
		tmp = t_1;
	elseif ((x <= 5.8e+19) || ~(((x <= 2.6e+112) || (~((x <= 3e+202)) && (x <= 1.1e+216)))))
		tmp = t_0;
	else
		tmp = x * (t_1 / x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-y) - z), $MachinePrecision]}, If[LessEqual[x, -2.15e+55], t$95$0, If[LessEqual[x, 4.5e-5], t$95$1, If[Or[LessEqual[x, 5.8e+19], N[Not[Or[LessEqual[x, 2.6e+112], And[N[Not[LessEqual[x, 3e+202]], $MachinePrecision], LessEqual[x, 1.1e+216]]]], $MachinePrecision]], t$95$0, N[(x * N[(t$95$1 / x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 4.5 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 5.8 \cdot 10^{+19} \lor \neg \left(x \leq 2.6 \cdot 10^{+112} \lor \neg \left(x \leq 3 \cdot 10^{+202}\right) \land x \leq 1.1 \cdot 10^{+216}\right):\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{t\_1}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.1499999999999999e55 or 4.50000000000000028e-5 < x < 5.8e19 or 2.6000000000000001e112 < x < 3.0000000000000001e202 or 1.1e216 < x

    1. Initial program 99.7%

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

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

    if -2.1499999999999999e55 < x < 4.50000000000000028e-5

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \color{blue}{\left(-z\right) + \left(-y\right)} \]
      4. sub-neg89.7%

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

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

    if 5.8e19 < x < 2.6000000000000001e112 or 3.0000000000000001e202 < x < 1.1e216

    1. Initial program 99.8%

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

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

        \[\leadsto x \cdot \left(\log y + \color{blue}{\left(-\frac{y + z}{x}\right)}\right) \]
      2. unsub-neg99.8%

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

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \frac{y + z}{x}\right)} \]
    7. Step-by-step derivation
      1. associate-*r/73.7%

        \[\leadsto x \cdot \color{blue}{\frac{-1 \cdot \left(y + z\right)}{x}} \]
      2. +-commutative73.7%

        \[\leadsto x \cdot \frac{-1 \cdot \color{blue}{\left(z + y\right)}}{x} \]
      3. distribute-lft-in73.7%

        \[\leadsto x \cdot \frac{\color{blue}{-1 \cdot z + -1 \cdot y}}{x} \]
      4. mul-1-neg73.7%

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

        \[\leadsto x \cdot \frac{\color{blue}{-1 \cdot z - y}}{x} \]
      6. mul-1-neg73.7%

        \[\leadsto x \cdot \frac{\color{blue}{\left(-z\right)} - y}{x} \]
    8. Simplified73.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.15 \cdot 10^{+55}:\\ \;\;\;\;x \cdot \log y\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-5}:\\ \;\;\;\;\left(-y\right) - z\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{+19} \lor \neg \left(x \leq 2.6 \cdot 10^{+112} \lor \neg \left(x \leq 3 \cdot 10^{+202}\right) \land x \leq 1.1 \cdot 10^{+216}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\left(-y\right) - z}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 83.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-71} \lor \neg \left(x \leq 5.8 \cdot 10^{-6}\right):\\
\;\;\;\;x \cdot \log y - y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.49999999999999988e-71 or 5.8000000000000004e-6 < x

    1. Initial program 99.7%

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

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

    if -8.49999999999999988e-71 < x < 5.8000000000000004e-6

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{-\left(y + z\right)} \]
      2. +-commutative94.9%

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

        \[\leadsto \color{blue}{\left(-z\right) + \left(-y\right)} \]
      4. sub-neg94.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{-71} \lor \neg \left(x \leq 5.8 \cdot 10^{-6}\right):\\ \;\;\;\;x \cdot \log y - y\\ \mathbf{else}:\\ \;\;\;\;\left(-y\right) - z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := x \cdot \log y\\
\mathbf{if}\;y \leq 1.55 \cdot 10^{+95}:\\
\;\;\;\;t\_0 - z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.5500000000000001e95

    1. Initial program 99.8%

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

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

    if 1.5500000000000001e95 < y

    1. Initial program 99.9%

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

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

Alternative 5: 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 6: 52.2% accurate, 15.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 8 \cdot 10^{+94}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;-y\\ \end{array} \end{array} \]
(FPCore (x y z) :precision binary64 (if (<= y 8e+94) (- z) (- y)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 8e+94) {
		tmp = -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 (y <= 8d+94) then
        tmp = -z
    else
        tmp = -y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 8e+94) {
		tmp = -z;
	} else {
		tmp = -y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 8e+94:
		tmp = -z
	else:
		tmp = -y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 8e+94)
		tmp = Float64(-z);
	else
		tmp = Float64(-y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 8e+94)
		tmp = -z;
	else
		tmp = -y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 8e+94], (-z), (-y)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{+94}:\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 8.0000000000000002e94

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. neg-mul-142.9%

        \[\leadsto \color{blue}{-z} \]
    5. Simplified42.9%

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

    if 8.0000000000000002e94 < y

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{-1 \cdot y} \]
    4. Step-by-step derivation
      1. mul-1-neg68.0%

        \[\leadsto \color{blue}{-y} \]
    5. Simplified68.0%

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

Alternative 7: 66.6% accurate, 26.8× speedup?

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

\\
\left(-y\right) - z
\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 63.0%

    \[\leadsto \color{blue}{-1 \cdot \left(y + z\right)} \]
  4. Step-by-step derivation
    1. mul-1-neg63.0%

      \[\leadsto \color{blue}{-\left(y + z\right)} \]
    2. +-commutative63.0%

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

      \[\leadsto \color{blue}{\left(-z\right) + \left(-y\right)} \]
    4. sub-neg63.0%

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

    \[\leadsto \color{blue}{\left(-z\right) - y} \]
  6. Final simplification63.0%

    \[\leadsto \left(-y\right) - z \]
  7. Add Preprocessing

Alternative 8: 34.6% accurate, 53.5× 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 31.2%

    \[\leadsto \color{blue}{-1 \cdot y} \]
  4. Step-by-step derivation
    1. mul-1-neg31.2%

      \[\leadsto \color{blue}{-y} \]
  5. Simplified31.2%

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

Alternative 9: 2.2% accurate, 107.0× 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 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. Step-by-step derivation
    1. associate--l-99.8%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, \log y, \color{blue}{\left(-y\right) - z}\right) \]
    6. add-cube-cbrt97.9%

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

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

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

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

Reproduce

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