
(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 6 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}
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (* x (pow (exp (* 2.0 y_m)) (* y_m 0.5))))
y_m = fabs(y);
double code(double x, double y_m) {
return x * pow(exp((2.0 * y_m)), (y_m * 0.5));
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
code = x * (exp((2.0d0 * y_m)) ** (y_m * 0.5d0))
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
return x * Math.pow(Math.exp((2.0 * y_m)), (y_m * 0.5));
}
y_m = math.fabs(y) def code(x, y_m): return x * math.pow(math.exp((2.0 * y_m)), (y_m * 0.5))
y_m = abs(y) function code(x, y_m) return Float64(x * (exp(Float64(2.0 * y_m)) ^ Float64(y_m * 0.5))) end
y_m = abs(y); function tmp = code(x, y_m) tmp = x * (exp((2.0 * y_m)) ^ (y_m * 0.5)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := N[(x * N[Power[N[Exp[N[(2.0 * y$95$m), $MachinePrecision]], $MachinePrecision], N[(y$95$m * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
x \cdot {\left(e^{2 \cdot y\_m}\right)}^{\left(y\_m \cdot 0.5\right)}
\end{array}
Initial program 100.0%
pow-exp100.0%
sqr-pow100.0%
pow-prod-down100.0%
add-exp-log100.0%
pow2100.0%
log-pow100.0%
add-log-exp100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (+ x (* x (expm1 (* y_m y_m)))))
y_m = fabs(y);
double code(double x, double y_m) {
return x + (x * expm1((y_m * y_m)));
}
y_m = Math.abs(y);
public static double code(double x, double y_m) {
return x + (x * Math.expm1((y_m * y_m)));
}
y_m = math.fabs(y) def code(x, y_m): return x + (x * math.expm1((y_m * y_m)))
y_m = abs(y) function code(x, y_m) return Float64(x + Float64(x * expm1(Float64(y_m * y_m)))) end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := N[(x + N[(x * N[(Exp[N[(y$95$m * y$95$m), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
x + x \cdot \mathsf{expm1}\left(y\_m \cdot y\_m\right)
\end{array}
Initial program 100.0%
log1p-expm1-u100.0%
log1p-undefine100.0%
add-exp-log100.0%
pow2100.0%
Applied egg-rr100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
unpow2100.0%
Applied egg-rr100.0%
Final simplification100.0%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (* x (+ (expm1 (* y_m y_m)) 1.0)))
y_m = fabs(y);
double code(double x, double y_m) {
return x * (expm1((y_m * y_m)) + 1.0);
}
y_m = Math.abs(y);
public static double code(double x, double y_m) {
return x * (Math.expm1((y_m * y_m)) + 1.0);
}
y_m = math.fabs(y) def code(x, y_m): return x * (math.expm1((y_m * y_m)) + 1.0)
y_m = abs(y) function code(x, y_m) return Float64(x * Float64(expm1(Float64(y_m * y_m)) + 1.0)) end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := N[(x * N[(N[(Exp[N[(y$95$m * y$95$m), $MachinePrecision]] - 1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
x \cdot \left(\mathsf{expm1}\left(y\_m \cdot y\_m\right) + 1\right)
\end{array}
Initial program 100.0%
log1p-expm1-u100.0%
log1p-undefine100.0%
add-exp-log100.0%
pow2100.0%
Applied egg-rr100.0%
unpow2100.0%
Applied egg-rr100.0%
Final simplification100.0%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (* x (exp (* y_m y_m))))
y_m = fabs(y);
double code(double x, double y_m) {
return x * exp((y_m * y_m));
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
code = x * exp((y_m * y_m))
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
return x * Math.exp((y_m * y_m));
}
y_m = math.fabs(y) def code(x, y_m): return x * math.exp((y_m * y_m))
y_m = abs(y) function code(x, y_m) return Float64(x * exp(Float64(y_m * y_m))) end
y_m = abs(y); function tmp = code(x, y_m) tmp = x * exp((y_m * y_m)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := N[(x * N[Exp[N[(y$95$m * y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
x \cdot e^{y\_m \cdot y\_m}
\end{array}
Initial program 100.0%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 (+ x (* x (* y_m y_m))))
y_m = fabs(y);
double code(double x, double y_m) {
return x + (x * (y_m * y_m));
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
code = x + (x * (y_m * y_m))
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
return x + (x * (y_m * y_m));
}
y_m = math.fabs(y) def code(x, y_m): return x + (x * (y_m * y_m))
y_m = abs(y) function code(x, y_m) return Float64(x + Float64(x * Float64(y_m * y_m))) end
y_m = abs(y); function tmp = code(x, y_m) tmp = x + (x * (y_m * y_m)); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := N[(x + N[(x * N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
x + x \cdot \left(y\_m \cdot y\_m\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 83.3%
*-commutative83.3%
Simplified83.3%
unpow2100.0%
Applied egg-rr83.3%
Final simplification83.3%
y_m = (fabs.f64 y) (FPCore (x y_m) :precision binary64 x)
y_m = fabs(y);
double code(double x, double y_m) {
return x;
}
y_m = abs(y)
real(8) function code(x, y_m)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
code = x
end function
y_m = Math.abs(y);
public static double code(double x, double y_m) {
return x;
}
y_m = math.fabs(y) def code(x, y_m): return x
y_m = abs(y) function code(x, y_m) return x end
y_m = abs(y); function tmp = code(x, y_m) tmp = x; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_] := x
\begin{array}{l}
y_m = \left|y\right|
\\
x
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 51.3%
(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 2024123
(FPCore (x y)
:name "Data.Number.Erf:$dmerfcx from erf-2.0.0.0"
:precision binary64
:alt
(! :herbie-platform default (* x (pow (exp y) y)))
(* x (exp (* y y))))