Average Error: 0.0 → 1.3
Time: 4.2s
Precision: binary64
Cost: 6660
\[e^{\left(x + y \cdot \log y\right) - z} \]
\[\begin{array}{l} \mathbf{if}\;z \leq 3.35 \cdot 10^{-15}:\\ \;\;\;\;e^{x}\\ \mathbf{else}:\\ \;\;\;\;e^{-z}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (exp (- (+ x (* y (log y))) z)))
(FPCore (x y z) :precision binary64 (if (<= z 3.35e-15) (exp x) (exp (- z))))
double code(double x, double y, double z) {
	return exp(((x + (y * log(y))) - z));
}
double code(double x, double y, double z) {
	double tmp;
	if (z <= 3.35e-15) {
		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
    code = exp(((x + (y * log(y))) - z))
end function
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 <= 3.35d-15) then
        tmp = exp(x)
    else
        tmp = exp(-z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return Math.exp(((x + (y * Math.log(y))) - z));
}
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= 3.35e-15) {
		tmp = Math.exp(x);
	} else {
		tmp = Math.exp(-z);
	}
	return tmp;
}
def code(x, y, z):
	return math.exp(((x + (y * math.log(y))) - z))
def code(x, y, z):
	tmp = 0
	if z <= 3.35e-15:
		tmp = math.exp(x)
	else:
		tmp = math.exp(-z)
	return tmp
function code(x, y, z)
	return exp(Float64(Float64(x + Float64(y * log(y))) - z))
end
function code(x, y, z)
	tmp = 0.0
	if (z <= 3.35e-15)
		tmp = exp(x);
	else
		tmp = exp(Float64(-z));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = exp(((x + (y * log(y))) - z));
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= 3.35e-15)
		tmp = exp(x);
	else
		tmp = exp(-z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[Exp[N[(N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[z, 3.35e-15], N[Exp[x], $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]
e^{\left(x + y \cdot \log y\right) - z}
\begin{array}{l}
\mathbf{if}\;z \leq 3.35 \cdot 10^{-15}:\\
\;\;\;\;e^{x}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie1.3
\[e^{\left(x - z\right) + \log y \cdot y} \]

Derivation

  1. Split input into 2 regimes
  2. if z < 3.35e-15

    1. Initial program 0.0

      \[e^{\left(x + y \cdot \log y\right) - z} \]
    2. Simplified11.0

      \[\leadsto \color{blue}{\frac{{y}^{y}}{e^{z - x}}} \]
    3. Taylor expanded in z around 0 11.5

      \[\leadsto \color{blue}{\frac{{y}^{y}}{e^{-x}}} \]
    4. Taylor expanded in y around 0 1.6

      \[\leadsto \color{blue}{\frac{1}{e^{-x}}} \]
    5. Simplified1.6

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

    if 3.35e-15 < z

    1. Initial program 0.0

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

      \[\leadsto e^{\color{blue}{-1 \cdot z}} \]
    3. Simplified0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 3.35 \cdot 10^{-15}:\\ \;\;\;\;e^{x}\\ \mathbf{else}:\\ \;\;\;\;e^{-z}\\ \end{array} \]

Alternatives

Alternative 1
Error18.9
Cost6464
\[e^{x} \]
Alternative 2
Error44.5
Cost192
\[x + 1 \]

Error

Reproduce

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

  :herbie-target
  (exp (+ (- x z) (* (log y) y)))

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