
(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 4 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 (* 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.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (or (<= (* y y) 0.0002) (not (<= (* y y) 1e+296))) (+ x (* x (* y y))) (exp (* y y))))
double code(double x, double y) {
double tmp;
if (((y * y) <= 0.0002) || !((y * y) <= 1e+296)) {
tmp = x + (x * (y * y));
} else {
tmp = exp((y * y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (((y * y) <= 0.0002d0) .or. (.not. ((y * y) <= 1d+296))) then
tmp = x + (x * (y * y))
else
tmp = exp((y * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((y * y) <= 0.0002) || !((y * y) <= 1e+296)) {
tmp = x + (x * (y * y));
} else {
tmp = Math.exp((y * y));
}
return tmp;
}
def code(x, y): tmp = 0 if ((y * y) <= 0.0002) or not ((y * y) <= 1e+296): tmp = x + (x * (y * y)) else: tmp = math.exp((y * y)) return tmp
function code(x, y) tmp = 0.0 if ((Float64(y * y) <= 0.0002) || !(Float64(y * y) <= 1e+296)) tmp = Float64(x + Float64(x * Float64(y * y))); else tmp = exp(Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((y * y) <= 0.0002) || ~(((y * y) <= 1e+296))) tmp = x + (x * (y * y)); else tmp = exp((y * y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[N[(y * y), $MachinePrecision], 0.0002], N[Not[LessEqual[N[(y * y), $MachinePrecision], 1e+296]], $MachinePrecision]], N[(x + N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[(y * y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot y \leq 0.0002 \lor \neg \left(y \cdot y \leq 10^{+296}\right):\\
\;\;\;\;x + x \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;e^{y \cdot y}\\
\end{array}
\end{array}
if (*.f64 y y) < 2.0000000000000001e-4 or 9.99999999999999981e295 < (*.f64 y y) Initial program 100.0%
Taylor expanded in y around 0 99.8%
unpow299.8%
Simplified99.8%
if 2.0000000000000001e-4 < (*.f64 y y) < 9.99999999999999981e295Initial program 98.4%
*-commutative98.4%
add-exp-log51.1%
prod-exp52.5%
Applied egg-rr52.5%
Taylor expanded in y around inf 51.1%
unpow251.1%
Simplified51.1%
Final simplification89.3%
(FPCore (x y) :precision binary64 (+ x (* x (* y y))))
double code(double x, double y) {
return x + (x * (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (x * (y * y))
end function
public static double code(double x, double y) {
return x + (x * (y * y));
}
def code(x, y): return x + (x * (y * y))
function code(x, y) return Float64(x + Float64(x * Float64(y * y))) end
function tmp = code(x, y) tmp = x + (x * (y * y)); end
code[x_, y_] := N[(x + N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + x \cdot \left(y \cdot y\right)
\end{array}
Initial program 99.6%
Taylor expanded in y around 0 83.3%
unpow283.3%
Simplified83.3%
Final simplification83.3%
(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.6%
Taylor expanded in y around 0 51.5%
Final simplification51.5%
(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 2023297
(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))))