
(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 5 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) 2.0) (/ (/ y 6.0) 2.0)))) (* x (* (pow (exp (* y 2.0)) (* y 0.3333333333333333)) (* t_0 t_0)))))
double code(double x, double y) {
double t_0 = pow(pow(exp(y), 2.0), ((y / 6.0) / 2.0));
return x * (pow(exp((y * 2.0)), (y * 0.3333333333333333)) * (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) ** 2.0d0) ** ((y / 6.0d0) / 2.0d0)
code = x * ((exp((y * 2.0d0)) ** (y * 0.3333333333333333d0)) * (t_0 * t_0))
end function
public static double code(double x, double y) {
double t_0 = Math.pow(Math.pow(Math.exp(y), 2.0), ((y / 6.0) / 2.0));
return x * (Math.pow(Math.exp((y * 2.0)), (y * 0.3333333333333333)) * (t_0 * t_0));
}
def code(x, y): t_0 = math.pow(math.pow(math.exp(y), 2.0), ((y / 6.0) / 2.0)) return x * (math.pow(math.exp((y * 2.0)), (y * 0.3333333333333333)) * (t_0 * t_0))
function code(x, y) t_0 = (exp(y) ^ 2.0) ^ Float64(Float64(y / 6.0) / 2.0) return Float64(x * Float64((exp(Float64(y * 2.0)) ^ Float64(y * 0.3333333333333333)) * Float64(t_0 * t_0))) end
function tmp = code(x, y) t_0 = (exp(y) ^ 2.0) ^ ((y / 6.0) / 2.0); tmp = x * ((exp((y * 2.0)) ^ (y * 0.3333333333333333)) * (t_0 * t_0)); end
code[x_, y_] := Block[{t$95$0 = N[Power[N[Power[N[Exp[y], $MachinePrecision], 2.0], $MachinePrecision], N[(N[(y / 6.0), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(x * N[(N[Power[N[Exp[N[(y * 2.0), $MachinePrecision]], $MachinePrecision], N[(y * 0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left({\left(e^{y}\right)}^{2}\right)}^{\left(\frac{\frac{y}{6}}{2}\right)}\\
x \cdot \left({\left(e^{y \cdot 2}\right)}^{\left(y \cdot 0.3333333333333333\right)} \cdot \left(t_0 \cdot t_0\right)\right)
\end{array}
\end{array}
Initial program 99.9%
*-un-lft-identity99.9%
exp-prod100.0%
exp-1-e100.0%
pow2100.0%
Applied egg-rr100.0%
unpow2100.0%
pow-unpow99.9%
e-exp-199.9%
exp-prod100.0%
*-un-lft-identity100.0%
add-cbrt-cube99.9%
unpow399.9%
exp-prod99.9%
pow1/399.9%
pow-unpow99.9%
*-commutative99.9%
add-cube-cbrt99.9%
unpow-prod-down99.9%
pow299.9%
exp-prod99.9%
unpow399.9%
add-cbrt-cube99.9%
Applied egg-rr100.0%
pow-exp100.0%
Applied egg-rr100.0%
sqr-pow100.0%
pow-prod-down100.0%
exp-lft-sqr100.0%
sqr-pow100.0%
exp-prod100.0%
associate-/l*100.0%
metadata-eval100.0%
exp-prod100.0%
associate-/l*100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (* x (* (pow (exp (* y 2.0)) (* y 0.3333333333333333)) (pow (exp y) (* y 0.3333333333333333)))))
double code(double x, double y) {
return x * (pow(exp((y * 2.0)), (y * 0.3333333333333333)) * pow(exp(y), (y * 0.3333333333333333)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * ((exp((y * 2.0d0)) ** (y * 0.3333333333333333d0)) * (exp(y) ** (y * 0.3333333333333333d0)))
end function
public static double code(double x, double y) {
return x * (Math.pow(Math.exp((y * 2.0)), (y * 0.3333333333333333)) * Math.pow(Math.exp(y), (y * 0.3333333333333333)));
}
def code(x, y): return x * (math.pow(math.exp((y * 2.0)), (y * 0.3333333333333333)) * math.pow(math.exp(y), (y * 0.3333333333333333)))
function code(x, y) return Float64(x * Float64((exp(Float64(y * 2.0)) ^ Float64(y * 0.3333333333333333)) * (exp(y) ^ Float64(y * 0.3333333333333333)))) end
function tmp = code(x, y) tmp = x * ((exp((y * 2.0)) ^ (y * 0.3333333333333333)) * (exp(y) ^ (y * 0.3333333333333333))); end
code[x_, y_] := N[(x * N[(N[Power[N[Exp[N[(y * 2.0), $MachinePrecision]], $MachinePrecision], N[(y * 0.3333333333333333), $MachinePrecision]], $MachinePrecision] * N[Power[N[Exp[y], $MachinePrecision], N[(y * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left({\left(e^{y \cdot 2}\right)}^{\left(y \cdot 0.3333333333333333\right)} \cdot {\left(e^{y}\right)}^{\left(y \cdot 0.3333333333333333\right)}\right)
\end{array}
Initial program 99.9%
*-un-lft-identity99.9%
exp-prod100.0%
exp-1-e100.0%
pow2100.0%
Applied egg-rr100.0%
unpow2100.0%
pow-unpow99.9%
e-exp-199.9%
exp-prod100.0%
*-un-lft-identity100.0%
add-cbrt-cube99.9%
unpow399.9%
exp-prod99.9%
pow1/399.9%
pow-unpow99.9%
*-commutative99.9%
add-cube-cbrt99.9%
unpow-prod-down99.9%
pow299.9%
exp-prod99.9%
unpow399.9%
add-cbrt-cube99.9%
Applied egg-rr100.0%
pow-exp100.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 (* 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)
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 47.2%
Final simplification47.2%
(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 2023320
(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))))