
(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 16 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 (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(Float64(-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}
\\
\frac{x}{{\left(e^{-y}\right)}^{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-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
lift-exp.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-rgt-identity100.0
Applied rewrites100.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(Float64(-y)) ^ Float64(-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)}^{\left(-y\right)}
\end{array}
Initial program 100.0%
lift-exp.f64N/A
lift-*.f64N/A
sqr-neg-revN/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-neg.f64100.0
Applied rewrites100.0%
(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 (* x (- 1.0 (* (* (fma (* (fma -0.16666666666666666 (* y y) -0.5) y) y -1.0) y) y))))
double code(double x, double y) {
return x * (1.0 - ((fma((fma(-0.16666666666666666, (y * y), -0.5) * y), y, -1.0) * y) * y));
}
function code(x, y) return Float64(x * Float64(1.0 - Float64(Float64(fma(Float64(fma(-0.16666666666666666, Float64(y * y), -0.5) * y), y, -1.0) * y) * y))) end
code[x_, y_] := N[(x * N[(1.0 - N[(N[(N[(N[(N[(-0.16666666666666666 * N[(y * y), $MachinePrecision] + -0.5), $MachinePrecision] * y), $MachinePrecision] * y + -1.0), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, y \cdot y, -0.5\right) \cdot y, y, -1\right) \cdot y\right) \cdot y\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 rewrites92.1%
Applied rewrites92.1%
Applied rewrites93.9%
Final simplification93.9%
(FPCore (x y) :precision binary64 (fma (* (fma (fma 0.16666666666666666 (* y y) 0.5) (* y y) 1.0) (* y y)) x x))
double code(double x, double y) {
return fma((fma(fma(0.16666666666666666, (y * y), 0.5), (y * y), 1.0) * (y * y)), x, x);
}
function code(x, y) return fma(Float64(fma(fma(0.16666666666666666, Float64(y * y), 0.5), Float64(y * y), 1.0) * Float64(y * y)), x, x) end
code[x_, y_] := N[(N[(N[(N[(0.16666666666666666 * N[(y * y), $MachinePrecision] + 0.5), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, y \cdot y, 0.5\right), y \cdot y, 1\right) \cdot \left(y \cdot y\right), x, x\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 rewrites92.1%
Applied rewrites93.9%
Final simplification93.9%
(FPCore (x y) :precision binary64 (fma y (* (* y x) (fma (fma (* 0.16666666666666666 y) y 0.5) (* y y) 1.0)) x))
double code(double x, double y) {
return fma(y, ((y * x) * fma(fma((0.16666666666666666 * y), y, 0.5), (y * y), 1.0)), x);
}
function code(x, y) return fma(y, Float64(Float64(y * x) * fma(fma(Float64(0.16666666666666666 * y), y, 0.5), Float64(y * y), 1.0)), x) end
code[x_, y_] := N[(y * N[(N[(y * x), $MachinePrecision] * N[(N[(N[(0.16666666666666666 * y), $MachinePrecision] * y + 0.5), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \left(y \cdot x\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666 \cdot y, y, 0.5\right), y \cdot y, 1\right), x\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 rewrites92.1%
Applied rewrites92.1%
Applied rewrites92.1%
Final simplification92.1%
(FPCore (x y) :precision binary64 (fma (* (* y y) x) (fma (* 0.16666666666666666 (* y y)) (* y y) 1.0) x))
double code(double x, double y) {
return fma(((y * y) * x), fma((0.16666666666666666 * (y * y)), (y * y), 1.0), x);
}
function code(x, y) return fma(Float64(Float64(y * y) * x), fma(Float64(0.16666666666666666 * Float64(y * y)), Float64(y * y), 1.0), x) end
code[x_, y_] := N[(N[(N[(y * y), $MachinePrecision] * x), $MachinePrecision] * N[(N[(0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(y \cdot y\right) \cdot x, \mathsf{fma}\left(0.16666666666666666 \cdot \left(y \cdot y\right), y \cdot y, 1\right), x\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 rewrites92.1%
Taylor expanded in y around inf
Applied rewrites92.0%
Final simplification92.0%
(FPCore (x y) :precision binary64 (* x (- 1.0 (* (* (fma (* -0.5 y) y -1.0) y) y))))
double code(double x, double y) {
return x * (1.0 - ((fma((-0.5 * y), y, -1.0) * y) * y));
}
function code(x, y) return Float64(x * Float64(1.0 - Float64(Float64(fma(Float64(-0.5 * y), y, -1.0) * y) * y))) end
code[x_, y_] := N[(x * N[(1.0 - N[(N[(N[(N[(-0.5 * y), $MachinePrecision] * y + -1.0), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(\mathsf{fma}\left(-0.5 \cdot y, y, -1\right) \cdot y\right) \cdot y\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 rewrites92.1%
Applied rewrites92.1%
Applied rewrites93.9%
Taylor expanded in y around 0
Applied rewrites90.5%
Final simplification90.5%
(FPCore (x y) :precision binary64 (fma (* (* y (fma (* y y) 0.5 1.0)) x) y x))
double code(double x, double y) {
return fma(((y * fma((y * y), 0.5, 1.0)) * x), y, x);
}
function code(x, y) return fma(Float64(Float64(y * fma(Float64(y * y), 0.5, 1.0)) * x), y, x) end
code[x_, y_] := N[(N[(N[(y * N[(N[(y * y), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(y \cdot \mathsf{fma}\left(y \cdot y, 0.5, 1\right)\right) \cdot x, y, 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%
lift-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
lift-exp.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
distribute-rgt-outN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
Applied rewrites89.0%
Applied rewrites89.8%
(FPCore (x y) :precision binary64 (fma (* (* y y) x) (fma 0.5 (* y y) 1.0) x))
double code(double x, double y) {
return fma(((y * y) * x), fma(0.5, (y * y), 1.0), x);
}
function code(x, y) return fma(Float64(Float64(y * y) * x), fma(0.5, Float64(y * y), 1.0), x) end
code[x_, y_] := N[(N[(N[(y * y), $MachinePrecision] * x), $MachinePrecision] * N[(0.5 * N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(y \cdot y\right) \cdot x, \mathsf{fma}\left(0.5, y \cdot y, 1\right), x\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 rewrites92.1%
Taylor expanded in y around 0
Applied rewrites89.0%
Final simplification89.0%
(FPCore (x y) :precision binary64 (fma (* (* (* (* y y) x) 0.5) y) y x))
double code(double x, double y) {
return fma(((((y * y) * x) * 0.5) * y), y, x);
}
function code(x, y) return fma(Float64(Float64(Float64(Float64(y * y) * x) * 0.5) * y), y, x) end
code[x_, y_] := N[(N[(N[(N[(N[(y * y), $MachinePrecision] * x), $MachinePrecision] * 0.5), $MachinePrecision] * y), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(\left(\left(y \cdot y\right) \cdot x\right) \cdot 0.5\right) \cdot y, y, 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%
lift-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
lift-exp.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
distribute-rgt-outN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
Applied rewrites89.0%
Taylor expanded in y around inf
Applied rewrites88.7%
(FPCore (x y) :precision binary64 (* x (fma y y 1.0)))
double code(double x, double y) {
return x * fma(y, y, 1.0);
}
function code(x, y) return Float64(x * fma(y, y, 1.0)) end
code[x_, y_] := N[(x * N[(y * y + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \mathsf{fma}\left(y, y, 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
unpow2N/A
lower-fma.f6480.8
Applied rewrites80.8%
(FPCore (x y) :precision binary64 (fma (* y x) y x))
double code(double x, double y) {
return fma((y * x), y, x);
}
function code(x, y) return fma(Float64(y * x), y, x) end
code[x_, y_] := N[(N[(y * x), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y \cdot x, y, 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%
lift-exp.f64N/A
lift-*.f64N/A
exp-prodN/A
lift-exp.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
+-commutativeN/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
distribute-rgt-outN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
Applied rewrites89.0%
Taylor expanded in y around 0
Applied rewrites77.1%
(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 rewrites50.8%
(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 2024337
(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))))