
(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 10 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%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ x (* y (log y))))) (if (<= t_0 -3e+50) (exp x) (if (<= t_0 1e-20) (exp (- z)) (pow y y)))))
double code(double x, double y, double z) {
double t_0 = x + (y * log(y));
double tmp;
if (t_0 <= -3e+50) {
tmp = exp(x);
} else if (t_0 <= 1e-20) {
tmp = exp(-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) :: t_0
real(8) :: tmp
t_0 = x + (y * log(y))
if (t_0 <= (-3d+50)) then
tmp = exp(x)
else if (t_0 <= 1d-20) then
tmp = exp(-z)
else
tmp = y ** y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + (y * Math.log(y));
double tmp;
if (t_0 <= -3e+50) {
tmp = Math.exp(x);
} else if (t_0 <= 1e-20) {
tmp = Math.exp(-z);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): t_0 = x + (y * math.log(y)) tmp = 0 if t_0 <= -3e+50: tmp = math.exp(x) elif t_0 <= 1e-20: tmp = math.exp(-z) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) t_0 = Float64(x + Float64(y * log(y))) tmp = 0.0 if (t_0 <= -3e+50) tmp = exp(x); elseif (t_0 <= 1e-20) tmp = exp(Float64(-z)); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (y * log(y)); tmp = 0.0; if (t_0 <= -3e+50) tmp = exp(x); elseif (t_0 <= 1e-20) tmp = exp(-z); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -3e+50], N[Exp[x], $MachinePrecision], If[LessEqual[t$95$0, 1e-20], N[Exp[(-z)], $MachinePrecision], N[Power[y, y], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + y \cdot \log y\\
\mathbf{if}\;t\_0 \leq -3 \cdot 10^{+50}:\\
\;\;\;\;e^{x}\\
\mathbf{elif}\;t\_0 \leq 10^{-20}:\\
\;\;\;\;e^{-z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if (+.f64 x (*.f64 y (log.f64 y))) < -2.9999999999999998e50Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6457.2
Applied rewrites57.2%
Taylor expanded in x around 0
Applied rewrites8.5%
Taylor expanded in y around 0
Applied rewrites90.0%
if -2.9999999999999998e50 < (+.f64 x (*.f64 y (log.f64 y))) < 9.99999999999999945e-21Initial program 100.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6497.0
Applied rewrites97.0%
if 9.99999999999999945e-21 < (+.f64 x (*.f64 y (log.f64 y))) Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6475.7
Applied rewrites75.7%
Taylor expanded in x around 0
Applied rewrites72.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.1e+26) (not (<= x 2.45e-49))) (exp (- x z)) (exp (- (* (log y) y) z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.1e+26) || !(x <= 2.45e-49)) {
tmp = exp((x - z));
} else {
tmp = exp(((log(y) * 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 <= (-1.1d+26)) .or. (.not. (x <= 2.45d-49))) then
tmp = exp((x - z))
else
tmp = exp(((log(y) * y) - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.1e+26) || !(x <= 2.45e-49)) {
tmp = Math.exp((x - z));
} else {
tmp = Math.exp(((Math.log(y) * y) - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.1e+26) or not (x <= 2.45e-49): tmp = math.exp((x - z)) else: tmp = math.exp(((math.log(y) * y) - z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.1e+26) || !(x <= 2.45e-49)) tmp = exp(Float64(x - z)); else tmp = exp(Float64(Float64(log(y) * y) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.1e+26) || ~((x <= 2.45e-49))) tmp = exp((x - z)); else tmp = exp(((log(y) * y) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.1e+26], N[Not[LessEqual[x, 2.45e-49]], $MachinePrecision]], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(N[Log[y], $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{+26} \lor \neg \left(x \leq 2.45 \cdot 10^{-49}\right):\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;e^{\log y \cdot y - z}\\
\end{array}
\end{array}
if x < -1.10000000000000004e26 or 2.4500000000000001e-49 < x Initial program 100.0%
Taylor expanded in y around 0
lower--.f6490.7
Applied rewrites90.7%
if -1.10000000000000004e26 < x < 2.4500000000000001e-49Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-log.f6499.9
Applied rewrites99.9%
Final simplification95.0%
(FPCore (x y z) :precision binary64 (if (<= y 1e+22) (exp (- x z)) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1e+22) {
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 <= 1d+22) 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 <= 1e+22) {
tmp = Math.exp((x - z));
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1e+22: tmp = math.exp((x - z)) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1e+22) 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 <= 1e+22) tmp = exp((x - z)); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1e+22], N[Exp[N[(x - z), $MachinePrecision]], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+22}:\\
\;\;\;\;e^{x - z}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 1e22Initial program 99.9%
Taylor expanded in y around 0
lower--.f6496.4
Applied rewrites96.4%
if 1e22 < y Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6461.6
Applied rewrites61.6%
Taylor expanded in x around 0
Applied rewrites79.8%
(FPCore (x y z) :precision binary64 (if (<= y 62.0) (exp x) (pow y y)))
double code(double x, double y, double z) {
double tmp;
if (y <= 62.0) {
tmp = exp(x);
} 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 <= 62.0d0) then
tmp = exp(x)
else
tmp = y ** y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 62.0) {
tmp = Math.exp(x);
} else {
tmp = Math.pow(y, y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 62.0: tmp = math.exp(x) else: tmp = math.pow(y, y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 62.0) tmp = exp(x); else tmp = y ^ y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 62.0) tmp = exp(x); else tmp = y ^ y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 62.0], N[Exp[x], $MachinePrecision], N[Power[y, y], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 62:\\
\;\;\;\;e^{x}\\
\mathbf{else}:\\
\;\;\;\;{y}^{y}\\
\end{array}
\end{array}
if y < 62Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6464.2
Applied rewrites64.2%
Taylor expanded in x around 0
Applied rewrites21.4%
Taylor expanded in y around 0
Applied rewrites64.2%
if 62 < y Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6461.3
Applied rewrites61.3%
Taylor expanded in x around 0
Applied rewrites78.0%
(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%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6462.7
Applied rewrites62.7%
Taylor expanded in x around 0
Applied rewrites51.0%
Taylor expanded in y around 0
Applied rewrites50.2%
(FPCore (x y z) :precision binary64 (if (<= x -5e-5) (fma (fma 0.5 x 1.0) x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0)))
double code(double x, double y, double z) {
double tmp;
if (x <= -5e-5) {
tmp = fma(fma(0.5, x, 1.0), x, 1.0);
} else {
tmp = fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -5e-5) tmp = fma(fma(0.5, x, 1.0), x, 1.0); else tmp = fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -5e-5], N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision], N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)\\
\end{array}
\end{array}
if x < -5.00000000000000024e-5Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6439.6
Applied rewrites39.6%
Taylor expanded in x around 0
Applied rewrites32.1%
Taylor expanded in y around 0
Applied rewrites63.8%
Taylor expanded in x around 0
Applied rewrites13.0%
if -5.00000000000000024e-5 < x Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6472.4
Applied rewrites72.4%
Taylor expanded in x around 0
Applied rewrites59.0%
Taylor expanded in y around 0
Applied rewrites44.5%
Taylor expanded in x around 0
Applied rewrites35.6%
(FPCore (x y z) :precision binary64 (fma (fma 0.5 x 1.0) x 1.0))
double code(double x, double y, double z) {
return fma(fma(0.5, x, 1.0), x, 1.0);
}
function code(x, y, z) return fma(fma(0.5, x, 1.0), x, 1.0) end
code[x_, y_, z_] := N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6462.7
Applied rewrites62.7%
Taylor expanded in x around 0
Applied rewrites51.0%
Taylor expanded in y around 0
Applied rewrites50.2%
Taylor expanded in x around 0
Applied rewrites24.9%
(FPCore (x y z) :precision binary64 (+ 1.0 x))
double code(double x, double y, double z) {
return 1.0 + x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + x
end function
public static double code(double x, double y, double z) {
return 1.0 + x;
}
def code(x, y, z): return 1.0 + x
function code(x, y, z) return Float64(1.0 + x) end
function tmp = code(x, y, z) tmp = 1.0 + x; end
code[x_, y_, z_] := N[(1.0 + x), $MachinePrecision]
\begin{array}{l}
\\
1 + x
\end{array}
Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6462.7
Applied rewrites62.7%
Taylor expanded in x around 0
Applied rewrites51.0%
Taylor expanded in y around 0
Applied rewrites50.2%
Taylor expanded in x around 0
Applied rewrites11.9%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in z around 0
+-commutativeN/A
exp-sumN/A
lower-*.f64N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
lower-exp.f6462.7
Applied rewrites62.7%
Taylor expanded in x around 0
Applied rewrites51.0%
Taylor expanded in y around 0
Applied rewrites11.8%
(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 2024338
(FPCore (x y z)
:name "Statistics.Distribution.Poisson.Internal:probability from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (exp (+ (- x z) (* (log y) y))))
(exp (- (+ x (* y (log y))) z)))