
(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 (* x (pow E (pow y 2.0))))
double code(double x, double y) {
return x * pow(((double) M_E), pow(y, 2.0));
}
public static double code(double x, double y) {
return x * Math.pow(Math.E, Math.pow(y, 2.0));
}
def code(x, y): return x * math.pow(math.e, math.pow(y, 2.0))
function code(x, y) return Float64(x * (exp(1) ^ (y ^ 2.0))) end
function tmp = code(x, y) tmp = x * (2.71828182845904523536 ^ (y ^ 2.0)); end
code[x_, y_] := N[(x * N[Power[E, N[Power[y, 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot {e}^{\left({y}^{2}\right)}
\end{array}
Initial program 100.0%
*-un-lft-identity100.0%
exp-prod100.0%
exp-1-e100.0%
pow2100.0%
Applied egg-rr100.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 100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= y 8.0) x (/ (+ (* (+ x 1.0) (+ x 1.0)) -1.0) (+ 1.0 (+ x 1.0)))))
double code(double x, double y) {
double tmp;
if (y <= 8.0) {
tmp = x;
} else {
tmp = (((x + 1.0) * (x + 1.0)) + -1.0) / (1.0 + (x + 1.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 8.0d0) then
tmp = x
else
tmp = (((x + 1.0d0) * (x + 1.0d0)) + (-1.0d0)) / (1.0d0 + (x + 1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 8.0) {
tmp = x;
} else {
tmp = (((x + 1.0) * (x + 1.0)) + -1.0) / (1.0 + (x + 1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 8.0: tmp = x else: tmp = (((x + 1.0) * (x + 1.0)) + -1.0) / (1.0 + (x + 1.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= 8.0) tmp = x; else tmp = Float64(Float64(Float64(Float64(x + 1.0) * Float64(x + 1.0)) + -1.0) / Float64(1.0 + Float64(x + 1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 8.0) tmp = x; else tmp = (((x + 1.0) * (x + 1.0)) + -1.0) / (1.0 + (x + 1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 8.0], x, N[(N[(N[(N[(x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / N[(1.0 + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x + 1\right) \cdot \left(x + 1\right) + -1}{1 + \left(x + 1\right)}\\
\end{array}
\end{array}
if y < 8Initial program 100.0%
Taylor expanded in y around 0 66.9%
if 8 < y Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
exp-diff100.0%
log1p-udef100.0%
rem-exp-log100.0%
pow2100.0%
exp-1-e100.0%
Applied egg-rr100.0%
clear-num100.0%
un-div-inv100.0%
add-exp-log100.0%
clear-num100.0%
e-exp-1100.0%
div-exp100.0%
add-exp-log100.0%
log1p-udef100.0%
expm1-udef100.0%
expm1-log1p-u100.0%
*-un-lft-identity100.0%
pow-exp100.0%
e-exp-1100.0%
neg-log100.0%
e-exp-1100.0%
pow-exp100.0%
Applied egg-rr100.0%
clear-num100.0%
inv-pow100.0%
add-exp-log38.7%
div-exp38.7%
Applied egg-rr4.4%
unpow-14.4%
remove-double-div4.4%
add-exp-log2.0%
add-sqr-sqrt1.7%
sqrt-unprod2.2%
sqr-neg2.2%
log-rec2.2%
log-rec2.2%
sqrt-unprod0.5%
add-sqr-sqrt1.1%
expm1-log1p-u1.1%
expm1-udef1.4%
add-exp-log1.4%
flip--7.5%
Applied egg-rr37.0%
Final simplification59.6%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
exp-diff100.0%
log1p-udef100.0%
rem-exp-log100.0%
pow2100.0%
exp-1-e100.0%
Applied egg-rr100.0%
clear-num100.0%
un-div-inv100.0%
add-exp-log100.0%
clear-num100.0%
e-exp-1100.0%
div-exp100.0%
add-exp-log100.0%
log1p-udef100.0%
expm1-udef100.0%
expm1-log1p-u100.0%
*-un-lft-identity100.0%
pow-exp100.0%
e-exp-1100.0%
neg-log100.0%
e-exp-1100.0%
pow-exp100.0%
Applied egg-rr100.0%
clear-num99.8%
inv-pow99.8%
add-exp-log48.6%
div-exp48.6%
Applied egg-rr51.6%
unpow-151.6%
add-sqr-sqrt28.5%
associate-/r*28.5%
metadata-eval28.5%
sqrt-div28.6%
clear-num28.6%
pow1/228.6%
pow128.6%
pow-to-exp26.8%
metadata-eval26.8%
metadata-eval26.8%
pow-exp26.8%
*-rgt-identity26.8%
add-sqr-sqrt12.7%
sqrt-unprod14.1%
log-rec14.1%
log-rec14.1%
sqr-neg14.1%
sqrt-unprod1.2%
add-sqr-sqrt2.3%
pow-to-exp2.3%
metadata-eval2.3%
Applied egg-rr2.3%
*-inverses2.8%
Simplified2.8%
Final simplification2.8%
(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 100.0%
Taylor expanded in y around 0 51.7%
Final simplification51.7%
(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 2024036
(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))))