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

Percentage Accurate: 99.9% → 99.8%
Time: 9.8s
Alternatives: 10
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 10 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.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \left(3 \cdot \left(x \cdot \log \left(\sqrt[3]{y}\right)\right) - z\right) - y \end{array} \]
(FPCore (x y z) :precision binary64 (- (- (* 3.0 (* x (log (cbrt y)))) z) y))
double code(double x, double y, double z) {
	return ((3.0 * (x * log(cbrt(y)))) - z) - y;
}
public static double code(double x, double y, double z) {
	return ((3.0 * (x * Math.log(Math.cbrt(y)))) - z) - y;
}
function code(x, y, z)
	return Float64(Float64(Float64(3.0 * Float64(x * log(cbrt(y)))) - z) - y)
end
code[x_, y_, z_] := N[(N[(N[(3.0 * N[(x * N[Log[N[Power[y, 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}

\\
\left(3 \cdot \left(x \cdot \log \left(\sqrt[3]{y}\right)\right) - z\right) - 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. add-cube-cbrt99.8%

      \[\leadsto \left(x \cdot \log \color{blue}{\left(\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}\right)} - z\right) - y \]
    2. log-prod99.8%

      \[\leadsto \left(x \cdot \color{blue}{\left(\log \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) + \log \left(\sqrt[3]{y}\right)\right)} - z\right) - y \]
    3. pow299.8%

      \[\leadsto \left(x \cdot \left(\log \color{blue}{\left({\left(\sqrt[3]{y}\right)}^{2}\right)} + \log \left(\sqrt[3]{y}\right)\right) - z\right) - y \]
  4. Applied egg-rr99.8%

    \[\leadsto \left(x \cdot \color{blue}{\left(\log \left({\left(\sqrt[3]{y}\right)}^{2}\right) + \log \left(\sqrt[3]{y}\right)\right)} - z\right) - y \]
  5. Step-by-step derivation
    1. distribute-lft-in99.8%

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

      \[\leadsto \left(\left(\color{blue}{\log \left({\left(\sqrt[3]{y}\right)}^{2}\right) \cdot x} + x \cdot \log \left(\sqrt[3]{y}\right)\right) - z\right) - y \]
    3. log-pow99.8%

      \[\leadsto \left(\left(\color{blue}{\left(2 \cdot \log \left(\sqrt[3]{y}\right)\right)} \cdot x + x \cdot \log \left(\sqrt[3]{y}\right)\right) - z\right) - y \]
    4. associate-*l*99.8%

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

      \[\leadsto \left(\left(2 \cdot \color{blue}{\left(x \cdot \log \left(\sqrt[3]{y}\right)\right)} + x \cdot \log \left(\sqrt[3]{y}\right)\right) - z\right) - y \]
  6. Applied egg-rr99.8%

    \[\leadsto \left(\color{blue}{\left(2 \cdot \left(x \cdot \log \left(\sqrt[3]{y}\right)\right) + x \cdot \log \left(\sqrt[3]{y}\right)\right)} - z\right) - y \]
  7. Step-by-step derivation
    1. distribute-lft1-in99.8%

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

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

    \[\leadsto \left(\color{blue}{3 \cdot \left(x \cdot \log \left(\sqrt[3]{y}\right)\right)} - z\right) - y \]
  9. Add Preprocessing

Alternative 2: 85.5% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;z \leq 8.4 \cdot 10^{+14}:\\
\;\;\;\;t\_1 - y\\

\mathbf{elif}\;z \leq 8.8 \cdot 10^{+126}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_1 - z\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.54999999999999994e72 or 8.4e14 < z < 8.79999999999999994e126

    1. Initial program 99.9%

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

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

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

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

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

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

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

    if -1.54999999999999994e72 < z < 8.4e14

    1. Initial program 99.8%

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

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

    if 8.79999999999999994e126 < z

    1. Initial program 99.8%

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

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

Alternative 3: 85.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+72} \lor \neg \left(z \leq 1.4 \cdot 10^{+14}\right):\\
\;\;\;\;\left(-z\right) - y\\

\mathbf{else}:\\
\;\;\;\;x \cdot \log y - y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.4999999999999998e72 or 1.4e14 < z

    1. Initial program 99.9%

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

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

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

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

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

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

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

    if -4.4999999999999998e72 < z < 1.4e14

    1. Initial program 99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+72} \lor \neg \left(z \leq 1.4 \cdot 10^{+14}\right):\\ \;\;\;\;\left(-z\right) - y\\ \mathbf{else}:\\ \;\;\;\;x \cdot \log y - y\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 79.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+134} \lor \neg \left(x \leq 1.35 \cdot 10^{+126}\right):\\
\;\;\;\;x \cdot \log y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.20000000000000003e134 or 1.35000000000000001e126 < x

    1. Initial program 99.6%

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

      \[\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. Step-by-step derivation
      1. sub-neg62.5%

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

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

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

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

        \[\leadsto y \cdot \left(\left(-\color{blue}{x \cdot \frac{-1 \cdot \log y}{y}}\right) + \left(-\left(1 + \frac{z}{y}\right)\right)\right) \]
      6. distribute-rgt-neg-in62.5%

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

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

        \[\leadsto y \cdot \left(x \cdot \left(-\color{blue}{\left(-\frac{\log y}{y}\right)}\right) + \left(-\left(1 + \frac{z}{y}\right)\right)\right) \]
      9. remove-double-neg62.5%

        \[\leadsto y \cdot \left(x \cdot \color{blue}{\frac{\log y}{y}} + \left(-\left(1 + \frac{z}{y}\right)\right)\right) \]
      10. distribute-neg-in62.5%

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

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

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

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

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

    if -1.20000000000000003e134 < x < 1.35000000000000001e126

    1. Initial program 99.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{+134} \lor \neg \left(x \leq 1.35 \cdot 10^{+126}\right):\\ \;\;\;\;x \cdot \log y\\ \mathbf{else}:\\ \;\;\;\;\left(-z\right) - y\\ \end{array} \]
  5. 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.8% accurate, 8.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+62} \lor \neg \left(z \leq 1.6 \cdot 10^{+34}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.00000000000000004e62 or 1.5999999999999999e34 < z

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{-z} \]
    5. Simplified61.8%

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

    if -1.00000000000000004e62 < z < 1.5999999999999999e34

    1. Initial program 99.8%

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

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

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

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

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

Alternative 7: 66.4% accurate, 26.8× 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 67.5%

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

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

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

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

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

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

Alternative 8: 35.0% 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 39.4%

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

      \[\leadsto \color{blue}{-y} \]
  5. Simplified39.4%

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

Alternative 9: 2.3% accurate, 107.0× speedup?

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

\\
z
\end{array}
Derivation
  1. Initial program 99.8%

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

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

      \[\leadsto \color{blue}{-z} \]
  5. Simplified30.2%

    \[\leadsto \color{blue}{-z} \]
  6. Step-by-step derivation
    1. neg-sub030.2%

      \[\leadsto \color{blue}{0 - z} \]
    2. sub-neg30.2%

      \[\leadsto \color{blue}{0 + \left(-z\right)} \]
    3. add-sqr-sqrt13.7%

      \[\leadsto 0 + \color{blue}{\sqrt{-z} \cdot \sqrt{-z}} \]
    4. sqrt-unprod6.4%

      \[\leadsto 0 + \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}} \]
    5. sqr-neg6.4%

      \[\leadsto 0 + \sqrt{\color{blue}{z \cdot z}} \]
    6. sqrt-unprod1.0%

      \[\leadsto 0 + \color{blue}{\sqrt{z} \cdot \sqrt{z}} \]
    7. add-sqr-sqrt2.5%

      \[\leadsto 0 + \color{blue}{z} \]
  7. Applied egg-rr2.5%

    \[\leadsto \color{blue}{0 + z} \]
  8. Step-by-step derivation
    1. +-lft-identity2.5%

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

    \[\leadsto \color{blue}{z} \]
  10. Add Preprocessing

Alternative 10: 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. Taylor expanded in y around inf 39.4%

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

      \[\leadsto \color{blue}{-y} \]
  5. Simplified39.4%

    \[\leadsto \color{blue}{-y} \]
  6. Step-by-step derivation
    1. neg-sub039.4%

      \[\leadsto \color{blue}{0 - y} \]
    2. sub-neg39.4%

      \[\leadsto \color{blue}{0 + \left(-y\right)} \]
    3. add-sqr-sqrt0.0%

      \[\leadsto 0 + \color{blue}{\sqrt{-y} \cdot \sqrt{-y}} \]
    4. sqrt-unprod2.1%

      \[\leadsto 0 + \color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} \]
    5. sqr-neg2.1%

      \[\leadsto 0 + \sqrt{\color{blue}{y \cdot y}} \]
    6. sqrt-unprod2.2%

      \[\leadsto 0 + \color{blue}{\sqrt{y} \cdot \sqrt{y}} \]
    7. add-sqr-sqrt2.2%

      \[\leadsto 0 + \color{blue}{y} \]
  7. Applied egg-rr2.2%

    \[\leadsto \color{blue}{0 + y} \]
  8. Step-by-step derivation
    1. +-lft-identity2.2%

      \[\leadsto \color{blue}{y} \]
  9. Simplified2.2%

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

Reproduce

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