
(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 4 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 (let* ((t_0 (* y (* x (- 0.0 y))))) (if (<= y -2.5e+72) t_0 (if (<= y 1.15e+60) (* x (* y (- 1.0 y))) t_0))))
double code(double x, double y) {
double t_0 = y * (x * (0.0 - y));
double tmp;
if (y <= -2.5e+72) {
tmp = t_0;
} else if (y <= 1.15e+60) {
tmp = x * (y * (1.0 - y));
} else {
tmp = 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 * (0.0d0 - y))
if (y <= (-2.5d+72)) then
tmp = t_0
else if (y <= 1.15d+60) then
tmp = x * (y * (1.0d0 - y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (x * (0.0 - y));
double tmp;
if (y <= -2.5e+72) {
tmp = t_0;
} else if (y <= 1.15e+60) {
tmp = x * (y * (1.0 - y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y * (x * (0.0 - y)) tmp = 0 if y <= -2.5e+72: tmp = t_0 elif y <= 1.15e+60: tmp = x * (y * (1.0 - y)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y * Float64(x * Float64(0.0 - y))) tmp = 0.0 if (y <= -2.5e+72) tmp = t_0; elseif (y <= 1.15e+60) tmp = Float64(x * Float64(y * Float64(1.0 - y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * (x * (0.0 - y)); tmp = 0.0; if (y <= -2.5e+72) tmp = t_0; elseif (y <= 1.15e+60) tmp = x * (y * (1.0 - y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(x * N[(0.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.5e+72], t$95$0, If[LessEqual[y, 1.15e+60], N[(x * N[(y * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot \left(0 - y\right)\right)\\
\mathbf{if}\;y \leq -2.5 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+60}:\\
\;\;\;\;x \cdot \left(y \cdot \left(1 - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.49999999999999996e72 or 1.15000000000000008e60 < y Initial program 99.9%
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6483.9%
Simplified83.9%
Applied egg-rr83.8%
frac-timesN/A
*-commutativeN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
neg-mul-1N/A
times-fracN/A
clear-numN/A
inv-powN/A
inv-powN/A
pow-prod-downN/A
*-commutativeN/A
inv-powN/A
/-lowering-/.f64N/A
associate-*r/N/A
Applied egg-rr99.8%
Taylor expanded in y around inf
/-lowering-/.f6499.8%
Simplified99.8%
/-rgt-identityN/A
clear-numN/A
associate-/l/N/A
associate-/r*N/A
frac-2negN/A
metadata-evalN/A
remove-double-divN/A
distribute-neg-fracN/A
neg-lowering-neg.f64N/A
div-invN/A
*-lowering-*.f64N/A
clear-numN/A
/-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f6499.9%
Applied egg-rr99.9%
if -2.49999999999999996e72 < y < 1.15000000000000008e60Initial program 99.9%
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6499.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (* y (* x (- 0.0 y))))) (if (<= y -1.0) t_0 (if (<= y 1.0) (* x y) t_0))))
double code(double x, double y) {
double t_0 = y * (x * (0.0 - y));
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = x * y;
} else {
tmp = 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 * (0.0d0 - y))
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 1.0d0) then
tmp = x * y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * (x * (0.0 - y));
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = x * y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y * (x * (0.0 - y)) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 1.0: tmp = x * y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y * Float64(x * Float64(0.0 - y))) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(x * y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * (x * (0.0 - y)); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = x * y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(x * N[(0.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 1.0], N[(x * y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot \left(0 - y\right)\right)\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 99.8%
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6487.3%
Simplified87.3%
Applied egg-rr87.2%
frac-timesN/A
*-commutativeN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
neg-mul-1N/A
times-fracN/A
clear-numN/A
inv-powN/A
inv-powN/A
pow-prod-downN/A
*-commutativeN/A
inv-powN/A
/-lowering-/.f64N/A
associate-*r/N/A
Applied egg-rr99.7%
Taylor expanded in y around inf
/-lowering-/.f6497.9%
Simplified97.9%
/-rgt-identityN/A
clear-numN/A
associate-/l/N/A
associate-/r*N/A
frac-2negN/A
metadata-evalN/A
remove-double-divN/A
distribute-neg-fracN/A
neg-lowering-neg.f64N/A
div-invN/A
*-lowering-*.f64N/A
clear-numN/A
/-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f6498.0%
Applied egg-rr98.0%
if -1 < y < 1Initial program 100.0%
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Taylor expanded in y around 0
*-lowering-*.f6496.7%
Simplified96.7%
Final simplification97.4%
(FPCore (x y) :precision binary64 (* (- 1.0 y) (* x y)))
double code(double x, double y) {
return (1.0 - y) * (x * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - y) * (x * y)
end function
public static double code(double x, double y) {
return (1.0 - y) * (x * y);
}
def code(x, y): return (1.0 - y) * (x * y)
function code(x, y) return Float64(Float64(1.0 - y) * Float64(x * y)) end
function tmp = code(x, y) tmp = (1.0 - y) * (x * y); end
code[x_, y_] := N[(N[(1.0 - y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - y\right) \cdot \left(x \cdot y\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (* x y))
double code(double x, double y) {
return x * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * y
end function
public static double code(double x, double y) {
return x * y;
}
def code(x, y): return x * y
function code(x, y) return Float64(x * y) end
function tmp = code(x, y) tmp = x * y; end
code[x_, y_] := N[(x * y), $MachinePrecision]
\begin{array}{l}
\\
x \cdot y
\end{array}
Initial program 99.9%
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6493.4%
Simplified93.4%
Taylor expanded in y around 0
*-lowering-*.f6456.0%
Simplified56.0%
herbie shell --seed 2024152
(FPCore (x y)
:name "Statistics.Distribution.Binomial:$cvariance from math-functions-0.1.5.2"
:precision binary64
(* (* x y) (- 1.0 y)))