
(FPCore (x y) :precision binary64 (* (* x y) (- 1.0 y)))
double code(double x, double y) {
return (x * y) * (1.0 - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) * (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x * y) * (1.0 - y);
}
def code(x, y): return (x * y) * (1.0 - y)
function code(x, y) return Float64(Float64(x * y) * Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x * y) * (1.0 - y); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y\right) \cdot \left(1 - y\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (* x y) (- 1.0 y)))
double code(double x, double y) {
return (x * y) * (1.0 - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) * (1.0d0 - y)
end function
public static double code(double x, double y) {
return (x * y) * (1.0 - y);
}
def code(x, y): return (x * y) * (1.0 - y)
function code(x, y) return Float64(Float64(x * y) * Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (x * y) * (1.0 - y); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y\right) \cdot \left(1 - y\right)
\end{array}
(FPCore (x y) :precision binary64 (fma y x (* y (* y (- x)))))
double code(double x, double y) {
return fma(y, x, (y * (y * -x)));
}
function code(x, y) return fma(y, x, Float64(y * Float64(y * Float64(-x)))) end
code[x_, y_] := N[(y * x + N[(y * N[(y * (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x, y \cdot \left(y \cdot \left(-x\right)\right)\right)
\end{array}
Initial program 99.9%
associate-*l*95.2%
Simplified95.2%
associate-*r*99.9%
sub-neg99.9%
distribute-lft-in92.5%
*-commutative92.5%
*-un-lft-identity92.5%
*-commutative92.5%
fma-def99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (* x (* y (- 1.0 y))))
double code(double x, double y) {
return x * (y * (1.0 - y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (y * (1.0d0 - y))
end function
public static double code(double x, double y) {
return x * (y * (1.0 - y));
}
def code(x, y): return x * (y * (1.0 - y))
function code(x, y) return Float64(x * Float64(y * Float64(1.0 - y))) end
function tmp = code(x, y) tmp = x * (y * (1.0 - y)); end
code[x_, y_] := N[(x * N[(y * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y \cdot \left(1 - y\right)\right)
\end{array}
Initial program 99.9%
associate-*l*95.2%
Simplified95.2%
Final simplification95.2%
(FPCore (x y) :precision binary64 (* (* y x) (- 1.0 y)))
double code(double x, double y) {
return (y * x) * (1.0 - y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y * x) * (1.0d0 - y)
end function
public static double code(double x, double y) {
return (y * x) * (1.0 - y);
}
def code(x, y): return (y * x) * (1.0 - y)
function code(x, y) return Float64(Float64(y * x) * Float64(1.0 - y)) end
function tmp = code(x, y) tmp = (y * x) * (1.0 - y); end
code[x_, y_] := N[(N[(y * x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y \cdot x\right) \cdot \left(1 - y\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (* y x))
double code(double x, double y) {
return y * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * x
end function
public static double code(double x, double y) {
return y * x;
}
def code(x, y): return y * x
function code(x, y) return Float64(y * x) end
function tmp = code(x, y) tmp = y * x; end
code[x_, y_] := N[(y * x), $MachinePrecision]
\begin{array}{l}
\\
y \cdot x
\end{array}
Initial program 99.9%
associate-*l*95.2%
Simplified95.2%
Taylor expanded in y around 0 60.0%
Final simplification60.0%
(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 99.9%
associate-*l*95.2%
Simplified95.2%
associate-*r*99.9%
flip--95.1%
associate-*r/91.5%
metadata-eval91.5%
pow291.5%
+-commutative91.5%
Applied egg-rr91.5%
associate-*l*87.8%
associate-/l*89.0%
sub-neg89.0%
distribute-lft-in89.0%
*-rgt-identity89.0%
distribute-rgt-neg-in89.0%
unpow289.0%
cube-mult89.1%
unsub-neg89.1%
Simplified89.1%
Taylor expanded in y around 0 50.3%
Taylor expanded in y around inf 2.7%
Final simplification2.7%
herbie shell --seed 2023336
(FPCore (x y)
:name "Statistics.Distribution.Binomial:$cvariance from math-functions-0.1.5.2"
:precision binary64
(* (* x y) (- 1.0 y)))