
(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}
(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}
Initial program 100.0%
exp-prod100.0%
Simplified100.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
(let* ((t_0 (* y (* x y))))
(if (or (<= (* y y) 5e+120) (not (<= (* y y) 1e+194)))
(* x (+ (* y y) 1.0))
(/ (- (* x x) (* t_0 t_0)) (- x t_0)))))
double code(double x, double y) {
double t_0 = y * (x * y);
double tmp;
if (((y * y) <= 5e+120) || !((y * y) <= 1e+194)) {
tmp = x * ((y * y) + 1.0);
} else {
tmp = ((x * x) - (t_0 * t_0)) / (x - t_0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * (x * y)
if (((y * y) <= 5d+120) .or. (.not. ((y * y) <= 1d+194))) then
tmp = x * ((y * y) + 1.0d0)
else
tmp = ((x * x) - (t_0 * t_0)) / (x - t_0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (x * y);
double tmp;
if (((y * y) <= 5e+120) || !((y * y) <= 1e+194)) {
tmp = x * ((y * y) + 1.0);
} else {
tmp = ((x * x) - (t_0 * t_0)) / (x - t_0);
}
return tmp;
}
def code(x, y): t_0 = y * (x * y) tmp = 0 if ((y * y) <= 5e+120) or not ((y * y) <= 1e+194): tmp = x * ((y * y) + 1.0) else: tmp = ((x * x) - (t_0 * t_0)) / (x - t_0) return tmp
function code(x, y) t_0 = Float64(y * Float64(x * y)) tmp = 0.0 if ((Float64(y * y) <= 5e+120) || !(Float64(y * y) <= 1e+194)) tmp = Float64(x * Float64(Float64(y * y) + 1.0)); else tmp = Float64(Float64(Float64(x * x) - Float64(t_0 * t_0)) / Float64(x - t_0)); end return tmp end
function tmp_2 = code(x, y) t_0 = y * (x * y); tmp = 0.0; if (((y * y) <= 5e+120) || ~(((y * y) <= 1e+194))) tmp = x * ((y * y) + 1.0); else tmp = ((x * x) - (t_0 * t_0)) / (x - t_0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[(y * y), $MachinePrecision], 5e+120], N[Not[LessEqual[N[(y * y), $MachinePrecision], 1e+194]], $MachinePrecision]], N[(x * N[(N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x - t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot y\right)\\
\mathbf{if}\;y \cdot y \leq 5 \cdot 10^{+120} \lor \neg \left(y \cdot y \leq 10^{+194}\right):\\
\;\;\;\;x \cdot \left(y \cdot y + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x - t_0 \cdot t_0}{x - t_0}\\
\end{array}
\end{array}
if (*.f64 y y) < 5.00000000000000019e120 or 9.99999999999999945e193 < (*.f64 y y) Initial program 100.0%
Taylor expanded in y around 0 84.4%
unpow284.4%
Simplified84.4%
if 5.00000000000000019e120 < (*.f64 y y) < 9.99999999999999945e193Initial program 100.0%
Taylor expanded in y around 0 11.8%
unpow211.8%
Simplified11.8%
distribute-rgt-in11.8%
*-un-lft-identity11.8%
flip-+65.3%
associate-*l*65.3%
associate-*l*65.3%
associate-*l*65.3%
Applied egg-rr65.3%
Final simplification83.3%
(FPCore (x y) :precision binary64 (if (<= (* y y) 0.05) x (* x (* y y))))
double code(double x, double y) {
double tmp;
if ((y * y) <= 0.05) {
tmp = x;
} else {
tmp = x * (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.05d0) then
tmp = x
else
tmp = x * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y * y) <= 0.05) {
tmp = x;
} else {
tmp = x * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y * y) <= 0.05: tmp = x else: tmp = x * (y * y) return tmp
function code(x, y) tmp = 0.0 if (Float64(y * y) <= 0.05) tmp = x; else tmp = Float64(x * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y * y) <= 0.05) tmp = x; else tmp = x * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(y * y), $MachinePrecision], 0.05], x, N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot y \leq 0.05:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 y y) < 0.050000000000000003Initial program 100.0%
Taylor expanded in y around 0 99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in y around 0 99.2%
if 0.050000000000000003 < (*.f64 y y) Initial program 99.9%
Taylor expanded in y around 0 60.4%
unpow260.4%
Simplified60.4%
Taylor expanded in y around inf 60.4%
unpow260.4%
Simplified60.4%
Final simplification80.2%
(FPCore (x y) :precision binary64 (* x (+ (* y y) 1.0)))
double code(double x, double y) {
return x * ((y * y) + 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * ((y * y) + 1.0d0)
end function
public static double code(double x, double y) {
return x * ((y * y) + 1.0);
}
def code(x, y): return x * ((y * y) + 1.0)
function code(x, y) return Float64(x * Float64(Float64(y * y) + 1.0)) end
function tmp = code(x, y) tmp = x * ((y * y) + 1.0); end
code[x_, y_] := N[(x * N[(N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y \cdot y + 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around 0 80.4%
unpow280.4%
Simplified80.4%
Final simplification80.4%
(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 80.4%
unpow280.4%
Simplified80.4%
Taylor expanded in y around 0 52.5%
Final simplification52.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 2023275
(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))))