Statistics.Distribution.Poisson.Internal:probability from math-functions-0.1.5.2

Percentage Accurate: 100.0% → 100.0%
Time: 4.7s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ e^{\left(x + y \cdot \log y\right) - z} \end{array} \]
(FPCore (x y z) :precision binary64 (exp (- (+ x (* y (log y))) z)))
double code(double x, double y, double z) {
	return exp(((x + (y * log(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 = exp(((x + (y * log(y))) - z))
end function
public static double code(double x, double y, double z) {
	return Math.exp(((x + (y * Math.log(y))) - z));
}
def code(x, y, z):
	return math.exp(((x + (y * math.log(y))) - z))
function code(x, y, z)
	return exp(Float64(Float64(x + Float64(y * log(y))) - z))
end
function tmp = code(x, y, z)
	tmp = exp(((x + (y * log(y))) - z));
end
code[x_, y_, z_] := N[Exp[N[(N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
e^{\left(x + y \cdot \log y\right) - z}
\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: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ e^{\left(x + y \cdot \log y\right) - z} \end{array} \]
(FPCore (x y z) :precision binary64 (exp (- (+ x (* y (log y))) z)))
double code(double x, double y, double z) {
	return exp(((x + (y * log(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 = exp(((x + (y * log(y))) - z))
end function
public static double code(double x, double y, double z) {
	return Math.exp(((x + (y * Math.log(y))) - z));
}
def code(x, y, z):
	return math.exp(((x + (y * math.log(y))) - z))
function code(x, y, z)
	return exp(Float64(Float64(x + Float64(y * log(y))) - z))
end
function tmp = code(x, y, z)
	tmp = exp(((x + (y * log(y))) - z));
end
code[x_, y_, z_] := N[Exp[N[(N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ e^{\left(x + y \cdot \log y\right) - z} \end{array} \]
(FPCore (x y z) :precision binary64 (exp (- (+ x (* y (log y))) z)))
double code(double x, double y, double z) {
	return exp(((x + (y * log(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 = exp(((x + (y * log(y))) - z))
end function
public static double code(double x, double y, double z) {
	return Math.exp(((x + (y * Math.log(y))) - z));
}
def code(x, y, z):
	return math.exp(((x + (y * math.log(y))) - z))
function code(x, y, z)
	return exp(Float64(Float64(x + Float64(y * log(y))) - z))
end
function tmp = code(x, y, z)
	tmp = exp(((x + (y * log(y))) - z));
end
code[x_, y_, z_] := N[Exp[N[(N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

    \[e^{\left(x + y \cdot \log y\right) - z} \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto e^{\left(x + y \cdot \log y\right) - z} \]
  4. Add Preprocessing

Alternative 2: 94.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \log y\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-304}:\\
\;\;\;\;{y}^{y} \cdot e^{x - z}\\

\mathbf{else}:\\
\;\;\;\;e^{t\_0 - z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y (log.f64 y)) < -4.99999999999999965e-304

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto e^{\color{blue}{\left(y \cdot \log y + x\right)} - z} \]
      2. associate--l+100.0%

        \[\leadsto e^{\color{blue}{y \cdot \log y + \left(x - z\right)}} \]
      3. exp-sum100.0%

        \[\leadsto \color{blue}{e^{y \cdot \log y} \cdot e^{x - z}} \]
      4. *-commutative100.0%

        \[\leadsto e^{\color{blue}{\log y \cdot y}} \cdot e^{x - z} \]
      5. exp-to-pow100.0%

        \[\leadsto \color{blue}{{y}^{y}} \cdot e^{x - z} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x - z}} \]
    4. Add Preprocessing

    if -4.99999999999999965e-304 < (*.f64 y (log.f64 y))

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 94.3%

      \[\leadsto e^{\color{blue}{y \cdot \log y - z}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \log y \leq -5 \cdot 10^{-304}:\\ \;\;\;\;{y}^{y} \cdot e^{x - z}\\ \mathbf{else}:\\ \;\;\;\;e^{y \cdot \log y - z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 90.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.22 \cdot 10^{+176}:\\ \;\;\;\;e^{x}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;e^{y \cdot \log y - z}\\ \mathbf{else}:\\ \;\;\;\;{y}^{y} \cdot e^{x}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.22e+176)
   (exp x)
   (if (<= x 4.2e-7) (exp (- (* y (log y)) z)) (* (pow y y) (exp x)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.22e+176) {
		tmp = exp(x);
	} else if (x <= 4.2e-7) {
		tmp = exp(((y * log(y)) - z));
	} else {
		tmp = pow(y, y) * exp(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) :: tmp
    if (x <= (-1.22d+176)) then
        tmp = exp(x)
    else if (x <= 4.2d-7) then
        tmp = exp(((y * log(y)) - z))
    else
        tmp = (y ** y) * exp(x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.22e+176) {
		tmp = Math.exp(x);
	} else if (x <= 4.2e-7) {
		tmp = Math.exp(((y * Math.log(y)) - z));
	} else {
		tmp = Math.pow(y, y) * Math.exp(x);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -1.22e+176:
		tmp = math.exp(x)
	elif x <= 4.2e-7:
		tmp = math.exp(((y * math.log(y)) - z))
	else:
		tmp = math.pow(y, y) * math.exp(x)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.22e+176)
		tmp = exp(x);
	elseif (x <= 4.2e-7)
		tmp = exp(Float64(Float64(y * log(y)) - z));
	else
		tmp = Float64((y ^ y) * exp(x));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -1.22e+176)
		tmp = exp(x);
	elseif (x <= 4.2e-7)
		tmp = exp(((y * log(y)) - z));
	else
		tmp = (y ^ y) * exp(x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -1.22e+176], N[Exp[x], $MachinePrecision], If[LessEqual[x, 4.2e-7], N[Exp[N[(N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision], N[(N[Power[y, y], $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.22 \cdot 10^{+176}:\\
\;\;\;\;e^{x}\\

\mathbf{elif}\;x \leq 4.2 \cdot 10^{-7}:\\
\;\;\;\;e^{y \cdot \log y - z}\\

\mathbf{else}:\\
\;\;\;\;{y}^{y} \cdot e^{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.2199999999999999e176

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 94.5%

      \[\leadsto e^{\color{blue}{x}} \]

    if -1.2199999999999999e176 < x < 4.2e-7

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 96.1%

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

    if 4.2e-7 < x

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto e^{\color{blue}{\left(y \cdot \log y + x\right)} - z} \]
      2. associate--l+100.0%

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

        \[\leadsto \color{blue}{e^{y \cdot \log y} \cdot e^{x - z}} \]
      4. *-commutative94.8%

        \[\leadsto e^{\color{blue}{\log y \cdot y}} \cdot e^{x - z} \]
      5. exp-to-pow94.8%

        \[\leadsto \color{blue}{{y}^{y}} \cdot e^{x - z} \]
    3. Simplified94.8%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x - z}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 89.8%

      \[\leadsto \color{blue}{e^{x} \cdot {y}^{y}} \]
    6. Step-by-step derivation
      1. *-commutative89.8%

        \[\leadsto \color{blue}{{y}^{y} \cdot e^{x}} \]
    7. Simplified89.8%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.22 \cdot 10^{+176}:\\ \;\;\;\;e^{x}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-7}:\\ \;\;\;\;e^{y \cdot \log y - z}\\ \mathbf{else}:\\ \;\;\;\;{y}^{y} \cdot e^{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 83.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -860 \lor \neg \left(z \leq 2.5 \cdot 10^{+78}\right):\\
\;\;\;\;e^{-z}\\

\mathbf{else}:\\
\;\;\;\;{y}^{y} \cdot e^{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -860 or 2.49999999999999992e78 < z

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 90.4%

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

        \[\leadsto e^{\color{blue}{-z}} \]
    5. Simplified90.4%

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

    if -860 < z < 2.49999999999999992e78

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto e^{\color{blue}{\left(y \cdot \log y + x\right)} - z} \]
      2. associate--l+100.0%

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

        \[\leadsto \color{blue}{e^{y \cdot \log y} \cdot e^{x - z}} \]
      4. *-commutative84.2%

        \[\leadsto e^{\color{blue}{\log y \cdot y}} \cdot e^{x - z} \]
      5. exp-to-pow84.2%

        \[\leadsto \color{blue}{{y}^{y}} \cdot e^{x - z} \]
    3. Simplified84.2%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x - z}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 84.3%

      \[\leadsto \color{blue}{e^{x} \cdot {y}^{y}} \]
    6. Step-by-step derivation
      1. *-commutative84.3%

        \[\leadsto \color{blue}{{y}^{y} \cdot e^{x}} \]
    7. Simplified84.3%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -860 \lor \neg \left(z \leq 2.5 \cdot 10^{+78}\right):\\ \;\;\;\;e^{-z}\\ \mathbf{else}:\\ \;\;\;\;{y}^{y} \cdot e^{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 83.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{-16}:\\ \;\;\;\;\frac{{y}^{y}}{e^{z}}\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+78}:\\ \;\;\;\;{y}^{y} \cdot e^{x}\\ \mathbf{else}:\\ \;\;\;\;e^{-z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.6e-16)
   (/ (pow y y) (exp z))
   (if (<= z 2.1e+78) (* (pow y y) (exp x)) (exp (- z)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.6e-16) {
		tmp = pow(y, y) / exp(z);
	} else if (z <= 2.1e+78) {
		tmp = pow(y, y) * exp(x);
	} else {
		tmp = exp(-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 (z <= (-1.6d-16)) then
        tmp = (y ** y) / exp(z)
    else if (z <= 2.1d+78) then
        tmp = (y ** y) * exp(x)
    else
        tmp = exp(-z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.6e-16) {
		tmp = Math.pow(y, y) / Math.exp(z);
	} else if (z <= 2.1e+78) {
		tmp = Math.pow(y, y) * Math.exp(x);
	} else {
		tmp = Math.exp(-z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -1.6e-16:
		tmp = math.pow(y, y) / math.exp(z)
	elif z <= 2.1e+78:
		tmp = math.pow(y, y) * math.exp(x)
	else:
		tmp = math.exp(-z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.6e-16)
		tmp = Float64((y ^ y) / exp(z));
	elseif (z <= 2.1e+78)
		tmp = Float64((y ^ y) * exp(x));
	else
		tmp = exp(Float64(-z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -1.6e-16)
		tmp = (y ^ y) / exp(z);
	elseif (z <= 2.1e+78)
		tmp = (y ^ y) * exp(x);
	else
		tmp = exp(-z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -1.6e-16], N[(N[Power[y, y], $MachinePrecision] / N[Exp[z], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1e+78], N[(N[Power[y, y], $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.6 \cdot 10^{-16}:\\
\;\;\;\;\frac{{y}^{y}}{e^{z}}\\

\mathbf{elif}\;z \leq 2.1 \cdot 10^{+78}:\\
\;\;\;\;{y}^{y} \cdot e^{x}\\

\mathbf{else}:\\
\;\;\;\;e^{-z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.60000000000000011e-16

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto e^{\color{blue}{\left(y \cdot \log y + x\right)} - z} \]
      2. associate--l+100.0%

        \[\leadsto e^{\color{blue}{y \cdot \log y + \left(x - z\right)}} \]
      3. exp-sum94.6%

        \[\leadsto \color{blue}{e^{y \cdot \log y} \cdot e^{x - z}} \]
      4. *-commutative94.6%

        \[\leadsto e^{\color{blue}{\log y \cdot y}} \cdot e^{x - z} \]
      5. exp-to-pow94.6%

        \[\leadsto \color{blue}{{y}^{y}} \cdot e^{x - z} \]
    3. Simplified94.6%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x - z}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 92.1%

      \[\leadsto \color{blue}{e^{-z} \cdot {y}^{y}} \]
    6. Step-by-step derivation
      1. *-commutative92.1%

        \[\leadsto \color{blue}{{y}^{y} \cdot e^{-z}} \]
      2. exp-to-pow92.1%

        \[\leadsto \color{blue}{e^{\log y \cdot y}} \cdot e^{-z} \]
      3. *-commutative92.1%

        \[\leadsto e^{\color{blue}{y \cdot \log y}} \cdot e^{-z} \]
      4. exp-sum92.1%

        \[\leadsto \color{blue}{e^{y \cdot \log y + \left(-z\right)}} \]
      5. sub-neg92.1%

        \[\leadsto e^{\color{blue}{y \cdot \log y - z}} \]
      6. exp-diff92.1%

        \[\leadsto \color{blue}{\frac{e^{y \cdot \log y}}{e^{z}}} \]
      7. *-commutative92.1%

        \[\leadsto \frac{e^{\color{blue}{\log y \cdot y}}}{e^{z}} \]
      8. exp-to-pow92.1%

        \[\leadsto \frac{\color{blue}{{y}^{y}}}{e^{z}} \]
    7. Simplified92.1%

      \[\leadsto \color{blue}{\frac{{y}^{y}}{e^{z}}} \]

    if -1.60000000000000011e-16 < z < 2.1000000000000001e78

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto e^{\color{blue}{\left(y \cdot \log y + x\right)} - z} \]
      2. associate--l+100.0%

        \[\leadsto e^{\color{blue}{y \cdot \log y + \left(x - z\right)}} \]
      3. exp-sum85.4%

        \[\leadsto \color{blue}{e^{y \cdot \log y} \cdot e^{x - z}} \]
      4. *-commutative85.4%

        \[\leadsto e^{\color{blue}{\log y \cdot y}} \cdot e^{x - z} \]
      5. exp-to-pow85.4%

        \[\leadsto \color{blue}{{y}^{y}} \cdot e^{x - z} \]
    3. Simplified85.4%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x - z}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 85.4%

      \[\leadsto \color{blue}{e^{x} \cdot {y}^{y}} \]
    6. Step-by-step derivation
      1. *-commutative85.4%

        \[\leadsto \color{blue}{{y}^{y} \cdot e^{x}} \]
    7. Simplified85.4%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x}} \]

    if 2.1000000000000001e78 < z

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 86.7%

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

        \[\leadsto e^{\color{blue}{-z}} \]
    5. Simplified86.7%

      \[\leadsto e^{\color{blue}{-z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{-16}:\\ \;\;\;\;\frac{{y}^{y}}{e^{z}}\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+78}:\\ \;\;\;\;{y}^{y} \cdot e^{x}\\ \mathbf{else}:\\ \;\;\;\;e^{-z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 72.7% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-z}\\ \mathbf{if}\;x \leq -1.5 \cdot 10^{+119}:\\ \;\;\;\;e^{x}\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-277}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-218}:\\ \;\;\;\;{y}^{y}\\ \mathbf{elif}\;x \leq 0.019:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;e^{x}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (exp (- z))))
   (if (<= x -1.5e+119)
     (exp x)
     (if (<= x -6.8e-277)
       t_0
       (if (<= x 6.8e-218) (pow y y) (if (<= x 0.019) t_0 (exp x)))))))
double code(double x, double y, double z) {
	double t_0 = exp(-z);
	double tmp;
	if (x <= -1.5e+119) {
		tmp = exp(x);
	} else if (x <= -6.8e-277) {
		tmp = t_0;
	} else if (x <= 6.8e-218) {
		tmp = pow(y, y);
	} else if (x <= 0.019) {
		tmp = t_0;
	} else {
		tmp = exp(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) :: tmp
    t_0 = exp(-z)
    if (x <= (-1.5d+119)) then
        tmp = exp(x)
    else if (x <= (-6.8d-277)) then
        tmp = t_0
    else if (x <= 6.8d-218) then
        tmp = y ** y
    else if (x <= 0.019d0) then
        tmp = t_0
    else
        tmp = exp(x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.exp(-z);
	double tmp;
	if (x <= -1.5e+119) {
		tmp = Math.exp(x);
	} else if (x <= -6.8e-277) {
		tmp = t_0;
	} else if (x <= 6.8e-218) {
		tmp = Math.pow(y, y);
	} else if (x <= 0.019) {
		tmp = t_0;
	} else {
		tmp = Math.exp(x);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.exp(-z)
	tmp = 0
	if x <= -1.5e+119:
		tmp = math.exp(x)
	elif x <= -6.8e-277:
		tmp = t_0
	elif x <= 6.8e-218:
		tmp = math.pow(y, y)
	elif x <= 0.019:
		tmp = t_0
	else:
		tmp = math.exp(x)
	return tmp
function code(x, y, z)
	t_0 = exp(Float64(-z))
	tmp = 0.0
	if (x <= -1.5e+119)
		tmp = exp(x);
	elseif (x <= -6.8e-277)
		tmp = t_0;
	elseif (x <= 6.8e-218)
		tmp = y ^ y;
	elseif (x <= 0.019)
		tmp = t_0;
	else
		tmp = exp(x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = exp(-z);
	tmp = 0.0;
	if (x <= -1.5e+119)
		tmp = exp(x);
	elseif (x <= -6.8e-277)
		tmp = t_0;
	elseif (x <= 6.8e-218)
		tmp = y ^ y;
	elseif (x <= 0.019)
		tmp = t_0;
	else
		tmp = exp(x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Exp[(-z)], $MachinePrecision]}, If[LessEqual[x, -1.5e+119], N[Exp[x], $MachinePrecision], If[LessEqual[x, -6.8e-277], t$95$0, If[LessEqual[x, 6.8e-218], N[Power[y, y], $MachinePrecision], If[LessEqual[x, 0.019], t$95$0, N[Exp[x], $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-z}\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{+119}:\\
\;\;\;\;e^{x}\\

\mathbf{elif}\;x \leq -6.8 \cdot 10^{-277}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 6.8 \cdot 10^{-218}:\\
\;\;\;\;{y}^{y}\\

\mathbf{elif}\;x \leq 0.019:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;e^{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.50000000000000001e119 or 0.0189999999999999995 < x

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 86.4%

      \[\leadsto e^{\color{blue}{x}} \]

    if -1.50000000000000001e119 < x < -6.79999999999999964e-277 or 6.79999999999999971e-218 < x < 0.0189999999999999995

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 77.7%

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

        \[\leadsto e^{\color{blue}{-z}} \]
    5. Simplified77.7%

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

    if -6.79999999999999964e-277 < x < 6.79999999999999971e-218

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto e^{\color{blue}{\left(y \cdot \log y + x\right)} - z} \]
      2. associate--l+100.0%

        \[\leadsto e^{\color{blue}{y \cdot \log y + \left(x - z\right)}} \]
      3. exp-sum85.7%

        \[\leadsto \color{blue}{e^{y \cdot \log y} \cdot e^{x - z}} \]
      4. *-commutative85.7%

        \[\leadsto e^{\color{blue}{\log y \cdot y}} \cdot e^{x - z} \]
      5. exp-to-pow85.7%

        \[\leadsto \color{blue}{{y}^{y}} \cdot e^{x - z} \]
    3. Simplified85.7%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x - z}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 82.0%

      \[\leadsto \color{blue}{e^{x} \cdot {y}^{y}} \]
    6. Step-by-step derivation
      1. *-commutative82.0%

        \[\leadsto \color{blue}{{y}^{y} \cdot e^{x}} \]
    7. Simplified82.0%

      \[\leadsto \color{blue}{{y}^{y} \cdot e^{x}} \]
    8. Taylor expanded in x around 0 82.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{+119}:\\ \;\;\;\;e^{x}\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-277}:\\ \;\;\;\;e^{-z}\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-218}:\\ \;\;\;\;{y}^{y}\\ \mathbf{elif}\;x \leq 0.019:\\ \;\;\;\;e^{-z}\\ \mathbf{else}:\\ \;\;\;\;e^{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 72.1% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+119} \lor \neg \left(x \leq 0.019\right):\\
\;\;\;\;e^{x}\\

\mathbf{else}:\\
\;\;\;\;e^{-z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.2e119 or 0.0189999999999999995 < x

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 86.4%

      \[\leadsto e^{\color{blue}{x}} \]

    if -1.2e119 < x < 0.0189999999999999995

    1. Initial program 100.0%

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 75.1%

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

        \[\leadsto e^{\color{blue}{-z}} \]
    5. Simplified75.1%

      \[\leadsto e^{\color{blue}{-z}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{+119} \lor \neg \left(x \leq 0.019\right):\\ \;\;\;\;e^{x}\\ \mathbf{else}:\\ \;\;\;\;e^{-z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 52.9% accurate, 2.0× speedup?

\[\begin{array}{l} \\ e^{x} \end{array} \]
(FPCore (x y z) :precision binary64 (exp x))
double code(double x, double y, double z) {
	return exp(x);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = exp(x)
end function
public static double code(double x, double y, double z) {
	return Math.exp(x);
}
def code(x, y, z):
	return math.exp(x)
function code(x, y, z)
	return exp(x)
end
function tmp = code(x, y, z)
	tmp = exp(x);
end
code[x_, y_, z_] := N[Exp[x], $MachinePrecision]
\begin{array}{l}

\\
e^{x}
\end{array}
Derivation
  1. Initial program 100.0%

    \[e^{\left(x + y \cdot \log y\right) - z} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 47.1%

    \[\leadsto e^{\color{blue}{x}} \]
  4. Final simplification47.1%

    \[\leadsto e^{x} \]
  5. Add Preprocessing

Developer target: 100.0% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024085 
(FPCore (x y z)
  :name "Statistics.Distribution.Poisson.Internal:probability from math-functions-0.1.5.2"
  :precision binary64

  :alt
  (exp (+ (- x z) (* (log y) y)))

  (exp (- (+ x (* y (log y))) z)))