
(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 11 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 (* (pow (exp y) y) x))
double code(double x, double y) {
return pow(exp(y), y) * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (exp(y) ** y) * x
end function
public static double code(double x, double y) {
return Math.pow(Math.exp(y), y) * x;
}
def code(x, y): return math.pow(math.exp(y), y) * x
function code(x, y) return Float64((exp(y) ^ y) * x) end
function tmp = code(x, y) tmp = (exp(y) ^ y) * x; end
code[x_, y_] := N[(N[Power[N[Exp[y], $MachinePrecision], y], $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
{\left(e^{y}\right)}^{y} \cdot x
\end{array}
Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
Applied rewrites100.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(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}
\\
\frac{x}{e^{\left(-y\right) \cdot y}}
\end{array}
Initial program 100.0%
lift-*.f64N/A
lift-exp.f64N/A
sinh-+-cosh-revN/A
flip-+N/A
sinh---cosh-revN/A
sinh-coshN/A
metadata-evalN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
metadata-evalN/A
lower-exp.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-rgt-identity100.0
Applied rewrites100.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%
(FPCore (x y) :precision binary64 (* (pow (+ 1.0 y) y) x))
double code(double x, double y) {
return pow((1.0 + y), y) * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 + y) ** y) * x
end function
public static double code(double x, double y) {
return Math.pow((1.0 + y), y) * x;
}
def code(x, y): return math.pow((1.0 + y), y) * x
function code(x, y) return Float64((Float64(1.0 + y) ^ y) * x) end
function tmp = code(x, y) tmp = ((1.0 + y) ^ y) * x; end
code[x_, y_] := N[(N[Power[N[(1.0 + y), $MachinePrecision], y], $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
{\left(1 + y\right)}^{y} \cdot x
\end{array}
Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
lower-+.f6476.4
Applied rewrites76.4%
(FPCore (x y) :precision binary64 (* x (fma (* y y) (fma (fma 0.16666666666666666 (* y y) 0.5) (* y y) 1.0) 1.0)))
double code(double x, double y) {
return x * fma((y * y), fma(fma(0.16666666666666666, (y * y), 0.5), (y * y), 1.0), 1.0);
}
function code(x, y) return Float64(x * fma(Float64(y * y), fma(fma(0.16666666666666666, Float64(y * y), 0.5), Float64(y * y), 1.0), 1.0)) end
code[x_, y_] := N[(x * N[(N[(y * y), $MachinePrecision] * N[(N[(0.16666666666666666 * N[(y * y), $MachinePrecision] + 0.5), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, y \cdot y, 0.5\right), y \cdot y, 1\right), 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r*N/A
associate-+r+N/A
distribute-lft-inN/A
+-commutativeN/A
Applied rewrites90.6%
Applied rewrites92.8%
(FPCore (x y) :precision binary64 (* x (fma (* y y) (fma (* 0.16666666666666666 (* y y)) (* y y) 1.0) 1.0)))
double code(double x, double y) {
return x * fma((y * y), fma((0.16666666666666666 * (y * y)), (y * y), 1.0), 1.0);
}
function code(x, y) return Float64(x * fma(Float64(y * y), fma(Float64(0.16666666666666666 * Float64(y * y)), Float64(y * y), 1.0), 1.0)) end
code[x_, y_] := N[(x * N[(N[(y * y), $MachinePrecision] * N[(N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(0.16666666666666666 \cdot \left(y \cdot y\right), y \cdot y, 1\right), 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r*N/A
associate-+r+N/A
distribute-lft-inN/A
+-commutativeN/A
Applied rewrites90.6%
Applied rewrites92.8%
Taylor expanded in y around inf
Applied rewrites92.7%
(FPCore (x y) :precision binary64 (fma x (* y (* (fma (* y y) 0.5 1.0) y)) x))
double code(double x, double y) {
return fma(x, (y * (fma((y * y), 0.5, 1.0) * y)), x);
}
function code(x, y) return fma(x, Float64(y * Float64(fma(Float64(y * y), 0.5, 1.0) * y)), x) end
code[x_, y_] := N[(x * N[(y * N[(N[(N[(y * y), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y \cdot \left(\mathsf{fma}\left(y \cdot y, 0.5, 1\right) \cdot y\right), x\right)
\end{array}
Initial program 100.0%
lift-*.f64N/A
lift-exp.f64N/A
sinh-+-cosh-revN/A
flip-+N/A
sinh---cosh-revN/A
sinh-coshN/A
metadata-evalN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
metadata-evalN/A
lower-exp.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites86.8%
Applied rewrites90.5%
Final simplification90.5%
(FPCore (x y) :precision binary64 (* x (fma (* y y) (fma 0.5 (* y y) 1.0) 1.0)))
double code(double x, double y) {
return x * fma((y * y), fma(0.5, (y * y), 1.0), 1.0);
}
function code(x, y) return Float64(x * fma(Float64(y * y), fma(0.5, Float64(y * y), 1.0), 1.0)) end
code[x_, y_] := N[(x * N[(N[(y * y), $MachinePrecision] * N[(0.5 * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \mathsf{fma}\left(y \cdot y, \mathsf{fma}\left(0.5, y \cdot y, 1\right), 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
associate-*r*N/A
associate-+r+N/A
distribute-lft-inN/A
+-commutativeN/A
Applied rewrites90.6%
Applied rewrites92.8%
Taylor expanded in y around 0
Applied rewrites90.5%
(FPCore (x y) :precision binary64 (fma (* y y) x x))
double code(double x, double y) {
return fma((y * y), x, x);
}
function code(x, y) return fma(Float64(y * y), x, x) end
code[x_, y_] := N[(N[(y * y), $MachinePrecision] * x + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y \cdot y, x, x\right)
\end{array}
Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.5
Applied rewrites82.5%
Final simplification82.5%
(FPCore (x y) :precision binary64 (fma (* x y) y x))
double code(double x, double y) {
return fma((x * y), y, x);
}
function code(x, y) return fma(Float64(x * y), y, x) end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x \cdot y, y, x\right)
\end{array}
Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.5
Applied rewrites82.5%
Applied rewrites78.5%
Final simplification78.5%
(FPCore (x y) :precision binary64 (* x 1.0))
double code(double x, double y) {
return x * 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * 1.0d0
end function
public static double code(double x, double y) {
return x * 1.0;
}
def code(x, y): return x * 1.0
function code(x, y) return Float64(x * 1.0) end
function tmp = code(x, y) tmp = x * 1.0; end
code[x_, y_] := N[(x * 1.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 1
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites49.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 2024320
(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))))