
(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:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (<= x -5.2e+32) (exp x) (if (<= x -9.5e-106) (exp (- z)) (if (<= x 8.8e-12) (pow y y) (exp x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.2e+32) {
tmp = exp(x);
} else if (x <= -9.5e-106) {
tmp = exp(-z);
} else if (x <= 8.8e-12) {
tmp = pow(y, y);
} 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) :: tmp
if (x <= (-5.2d+32)) then
tmp = exp(x)
else if (x <= (-9.5d-106)) then
tmp = exp(-z)
else if (x <= 8.8d-12) then
tmp = y ** y
else
tmp = exp(x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -5.2e+32) {
tmp = Math.exp(x);
} else if (x <= -9.5e-106) {
tmp = Math.exp(-z);
} else if (x <= 8.8e-12) {
tmp = Math.pow(y, y);
} else {
tmp = Math.exp(x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.2e+32: tmp = math.exp(x) elif x <= -9.5e-106: tmp = math.exp(-z) elif x <= 8.8e-12: tmp = math.pow(y, y) else: tmp = math.exp(x) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.2e+32) tmp = exp(x); elseif (x <= -9.5e-106) tmp = exp(Float64(-z)); elseif (x <= 8.8e-12) tmp = y ^ y; else tmp = exp(x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.2e+32) tmp = exp(x); elseif (x <= -9.5e-106) tmp = exp(-z); elseif (x <= 8.8e-12) tmp = y ^ y; else tmp = exp(x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.2e+32], N[Exp[x], $MachinePrecision], If[LessEqual[x, -9.5e-106], N[Exp[(-z)], $MachinePrecision], If[LessEqual[x, 8.8e-12], N[Power[y, y], $MachinePrecision], N[Exp[x], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{+32}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;x \leq -9.5 \cdot 10^{-106}:\\
\;\;\;\;e^{-z}\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-12}:\\
\;\;\;\;{y}^{y}\\
\mathbf{else}:\\
\;\;\;\;e^{x}\\
\end{array}
\end{array}
if x < -5.2000000000000004e32 or 8.79999999999999966e-12 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum79.4%
*-commutative79.4%
exp-to-pow79.4%
Simplified79.4%
Taylor expanded in z around 0 74.9%
*-commutative74.9%
Simplified74.9%
Taylor expanded in y around 0 87.1%
if -5.2000000000000004e32 < x < -9.4999999999999994e-106Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum85.7%
*-commutative85.7%
exp-to-pow85.7%
Simplified85.7%
Taylor expanded in x around 0 90.6%
exp-to-pow90.6%
*-commutative90.6%
prod-exp96.3%
+-commutative96.3%
unsub-neg96.3%
div-exp90.6%
*-commutative90.6%
exp-to-pow90.6%
Simplified90.6%
Taylor expanded in y around 0 76.9%
rec-exp76.9%
Simplified76.9%
if -9.4999999999999994e-106 < x < 8.79999999999999966e-12Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum86.0%
*-commutative86.0%
exp-to-pow86.0%
Simplified86.0%
Taylor expanded in z around 0 78.9%
*-commutative78.9%
Simplified78.9%
Taylor expanded in x around 0 78.9%
Final simplification82.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.2e+35) (not (<= x 145000.0))) (exp x) (exp (- z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.2e+35) || !(x <= 145000.0)) {
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 <= (-2.2d+35)) .or. (.not. (x <= 145000.0d0))) 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 <= -2.2e+35) || !(x <= 145000.0)) {
tmp = Math.exp(x);
} else {
tmp = Math.exp(-z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.2e+35) or not (x <= 145000.0): tmp = math.exp(x) else: tmp = math.exp(-z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.2e+35) || !(x <= 145000.0)) tmp = exp(x); else tmp = exp(Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.2e+35) || ~((x <= 145000.0))) tmp = exp(x); else tmp = exp(-z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.2e+35], N[Not[LessEqual[x, 145000.0]], $MachinePrecision]], N[Exp[x], $MachinePrecision], N[Exp[(-z)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{+35} \lor \neg \left(x \leq 145000\right):\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;e^{-z}\\
\end{array}
\end{array}
if x < -2.1999999999999999e35 or 145000 < x Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum78.4%
*-commutative78.4%
exp-to-pow78.4%
Simplified78.4%
Taylor expanded in z around 0 76.5%
*-commutative76.5%
Simplified76.5%
Taylor expanded in y around 0 89.4%
if -2.1999999999999999e35 < x < 145000Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum86.4%
*-commutative86.4%
exp-to-pow86.4%
Simplified86.4%
Taylor expanded in x around 0 87.1%
exp-to-pow87.1%
*-commutative87.1%
prod-exp98.8%
+-commutative98.8%
unsub-neg98.8%
div-exp87.1%
*-commutative87.1%
exp-to-pow87.1%
Simplified87.1%
Taylor expanded in y around 0 68.2%
rec-exp68.3%
Simplified68.3%
Final simplification76.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.25e+36) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.25e+36) {
tmp = exp((x - z));
} else {
tmp = pow(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 (y <= 2.25d+36) then
tmp = exp((x - z))
else
tmp = y ** y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.25e+36) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.25e+36: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.25e+36) tmp = exp(Float64(x - z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.25e+36) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.25e+36], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.25 \cdot 10^{+36}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 2.24999999999999998e36Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum95.5%
*-commutative95.5%
exp-to-pow95.5%
Simplified95.5%
Taylor expanded in y around 0 96.1%
if 2.24999999999999998e36 < y Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum69.7%
*-commutative69.7%
exp-to-pow69.7%
Simplified69.7%
Taylor expanded in z around 0 75.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in x around 0 86.3%
Final simplification91.4%
(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}
Initial program 100.0%
+-commutative100.0%
associate--l+100.0%
exp-sum83.2%
*-commutative83.2%
exp-to-pow83.2%
Simplified83.2%
Taylor expanded in z around 0 72.8%
*-commutative72.8%
Simplified72.8%
Taylor expanded in y around 0 51.4%
Final simplification51.4%
(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}
herbie shell --seed 2023322
(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)))