
(FPCore (x y) :precision binary64 (* x (exp (* y y))))
double code(double x, double y) {
return x * exp((y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * exp((y * y))
end function
public static double code(double x, double y) {
return x * Math.exp((y * y));
}
def code(x, y): return x * math.exp((y * y))
function code(x, y) return Float64(x * exp(Float64(y * y))) end
function tmp = code(x, y) tmp = x * exp((y * y)); end
code[x_, y_] := N[(x * N[Exp[N[(y * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{y \cdot y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* x (exp (* y y))))
double code(double x, double y) {
return x * exp((y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * exp((y * y))
end function
public static double code(double x, double y) {
return x * Math.exp((y * y));
}
def code(x, y): return x * math.exp((y * y))
function code(x, y) return Float64(x * exp(Float64(y * y))) end
function tmp = code(x, y) tmp = x * exp((y * y)); end
code[x_, y_] := N[(x * N[Exp[N[(y * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{y \cdot y}
\end{array}
(FPCore (x y) :precision binary64 (let* ((t_0 (pow (pow (exp y) 0.25) (* y 2.0)))) (* x (* t_0 t_0))))
double code(double x, double y) {
double t_0 = pow(pow(exp(y), 0.25), (y * 2.0));
return x * (t_0 * t_0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (exp(y) ** 0.25d0) ** (y * 2.0d0)
code = x * (t_0 * t_0)
end function
public static double code(double x, double y) {
double t_0 = Math.pow(Math.pow(Math.exp(y), 0.25), (y * 2.0));
return x * (t_0 * t_0);
}
def code(x, y): t_0 = math.pow(math.pow(math.exp(y), 0.25), (y * 2.0)) return x * (t_0 * t_0)
function code(x, y) t_0 = (exp(y) ^ 0.25) ^ Float64(y * 2.0) return Float64(x * Float64(t_0 * t_0)) end
function tmp = code(x, y) t_0 = (exp(y) ^ 0.25) ^ (y * 2.0); tmp = x * (t_0 * t_0); end
code[x_, y_] := Block[{t$95$0 = N[Power[N[Power[N[Exp[y], $MachinePrecision], 0.25], $MachinePrecision], N[(y * 2.0), $MachinePrecision]], $MachinePrecision]}, N[(x * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left({\left(e^{y}\right)}^{0.25}\right)}^{\left(y \cdot 2\right)}\\
x \cdot \left(t_0 \cdot t_0\right)
\end{array}
\end{array}
Initial program 99.9%
exp-prod100.0%
sqr-pow100.0%
pow-prod-down100.0%
prod-exp100.0%
count-2100.0%
*-commutative100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
pow-exp99.9%
*-commutative99.9%
add-log-exp100.0%
exp-prod100.0%
pow1/2100.0%
pow-to-exp100.0%
add-sqr-sqrt100.0%
unpow-prod-down100.0%
pow1/2100.0%
sqrt-pow1100.0%
metadata-eval100.0%
pow1/2100.0%
sqrt-pow1100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (* x (pow (exp y) y)))
double code(double x, double y) {
return x * pow(exp(y), y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (exp(y) ** y)
end function
public static double code(double x, double y) {
return x * Math.pow(Math.exp(y), y);
}
def code(x, y): return x * math.pow(math.exp(y), y)
function code(x, y) return Float64(x * (exp(y) ^ y)) end
function tmp = code(x, y) tmp = x * (exp(y) ^ y); end
code[x_, y_] := N[(x * N[Power[N[Exp[y], $MachinePrecision], y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot {\left(e^{y}\right)}^{y}
\end{array}
Initial program 99.9%
exp-prod100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (or (<= y -3.3e+159) (not (<= y 1e+142))) (* x (pow y 2.0)) (+ x (* y (* x y)))))
double code(double x, double y) {
double tmp;
if ((y <= -3.3e+159) || !(y <= 1e+142)) {
tmp = x * pow(y, 2.0);
} else {
tmp = x + (y * (x * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-3.3d+159)) .or. (.not. (y <= 1d+142))) then
tmp = x * (y ** 2.0d0)
else
tmp = x + (y * (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -3.3e+159) || !(y <= 1e+142)) {
tmp = x * Math.pow(y, 2.0);
} else {
tmp = x + (y * (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3.3e+159) or not (y <= 1e+142): tmp = x * math.pow(y, 2.0) else: tmp = x + (y * (x * y)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -3.3e+159) || !(y <= 1e+142)) tmp = Float64(x * (y ^ 2.0)); else tmp = Float64(x + Float64(y * Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -3.3e+159) || ~((y <= 1e+142))) tmp = x * (y ^ 2.0); else tmp = x + (y * (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -3.3e+159], N[Not[LessEqual[y, 1e+142]], $MachinePrecision]], N[(x * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+159} \lor \neg \left(y \leq 10^{+142}\right):\\
\;\;\;\;x \cdot {y}^{2}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < -3.2999999999999999e159 or 1.00000000000000005e142 < y Initial program 100.0%
Taylor expanded in y around 0 98.8%
*-commutative98.8%
Simplified98.8%
*-commutative98.8%
unpow298.8%
associate-*r*76.9%
add-log-exp100.0%
*-un-lft-identity100.0%
log-prod100.0%
metadata-eval100.0%
add-log-exp76.9%
distribute-rgt-in38.0%
Applied egg-rr38.0%
Taylor expanded in x around 0 76.9%
Taylor expanded in y around inf 98.8%
if -3.2999999999999999e159 < y < 1.00000000000000005e142Initial program 99.9%
Taylor expanded in y around 0 76.8%
*-commutative76.8%
Simplified76.8%
*-commutative76.8%
unpow276.8%
associate-*r*76.8%
add-log-exp98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
add-log-exp76.8%
distribute-rgt-in72.3%
Applied egg-rr72.3%
Taylor expanded in x around 0 76.8%
Final simplification83.4%
(FPCore (x y) :precision binary64 (* x (exp (* y y))))
double code(double x, double y) {
return x * exp((y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * exp((y * y))
end function
public static double code(double x, double y) {
return x * Math.exp((y * y));
}
def code(x, y): return x * math.exp((y * y))
function code(x, y) return Float64(x * exp(Float64(y * y))) end
function tmp = code(x, y) tmp = x * exp((y * y)); end
code[x_, y_] := N[(x * N[Exp[N[(y * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{y \cdot y}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (+ x (* y (* x y))))
double code(double x, double y) {
return x + (y * (x * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (y * (x * y))
end function
public static double code(double x, double y) {
return x + (y * (x * y));
}
def code(x, y): return x + (y * (x * y))
function code(x, y) return Float64(x + Float64(y * Float64(x * y))) end
function tmp = code(x, y) tmp = x + (y * (x * y)); end
code[x_, y_] := N[(x + N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(x \cdot y\right)
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 83.4%
*-commutative83.4%
Simplified83.4%
*-commutative83.4%
unpow283.4%
associate-*r*76.8%
add-log-exp99.0%
*-un-lft-identity99.0%
log-prod99.0%
metadata-eval99.0%
add-log-exp76.8%
distribute-rgt-in62.0%
Applied egg-rr62.0%
Taylor expanded in x around 0 76.8%
Final simplification76.8%
(FPCore (x y) :precision binary64 (+ x (* x y)))
double code(double x, double y) {
return x + (x * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (x * y)
end function
public static double code(double x, double y) {
return x + (x * y);
}
def code(x, y): return x + (x * y)
function code(x, y) return Float64(x + Float64(x * y)) end
function tmp = code(x, y) tmp = x + (x * y); end
code[x_, y_] := N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + x \cdot y
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 83.4%
*-commutative83.4%
Simplified83.4%
*-commutative83.4%
unpow283.4%
associate-*r*76.8%
*-un-lft-identity76.8%
*-commutative76.8%
metadata-eval76.8%
distribute-lft-out76.8%
distribute-rgt-in76.8%
Applied egg-rr76.8%
flip-+0.0%
+-inverses0.0%
metadata-eval0.0%
mul0-lft0.0%
pow1/20.0%
+-inverses0.0%
metadata-eval0.0%
mul0-lft0.0%
pow1/20.0%
sqrt-div0.0%
mul0-lft0.0%
+-inverses0.0%
mul0-lft0.0%
+-inverses0.0%
flip-+47.2%
*-un-lft-identity47.2%
Applied egg-rr53.9%
Final simplification53.9%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 48.1%
Final simplification48.1%
(FPCore (x y) :precision binary64 (* x (pow (exp y) y)))
double code(double x, double y) {
return x * pow(exp(y), y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (exp(y) ** y)
end function
public static double code(double x, double y) {
return x * Math.pow(Math.exp(y), y);
}
def code(x, y): return x * math.pow(math.exp(y), y)
function code(x, y) return Float64(x * (exp(y) ^ y)) end
function tmp = code(x, y) tmp = x * (exp(y) ^ y); end
code[x_, y_] := N[(x * N[Power[N[Exp[y], $MachinePrecision], y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot {\left(e^{y}\right)}^{y}
\end{array}
herbie shell --seed 2023301
(FPCore (x y)
:name "Data.Number.Erf:$dmerfcx from erf-2.0.0.0"
:precision binary64
:herbie-target
(* x (pow (exp y) y))
(* x (exp (* y y))))