
(FPCore (x y) :precision binary64 (* (* (* x 3.0) x) y))
double code(double x, double y) {
return ((x * 3.0) * x) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 3.0d0) * x) * y
end function
public static double code(double x, double y) {
return ((x * 3.0) * x) * y;
}
def code(x, y): return ((x * 3.0) * x) * y
function code(x, y) return Float64(Float64(Float64(x * 3.0) * x) * y) end
function tmp = code(x, y) tmp = ((x * 3.0) * x) * y; end
code[x_, y_] := N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot 3\right) \cdot x\right) \cdot y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (* (* x 3.0) x) y))
double code(double x, double y) {
return ((x * 3.0) * x) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 3.0d0) * x) * y
end function
public static double code(double x, double y) {
return ((x * 3.0) * x) * y;
}
def code(x, y): return ((x * 3.0) * x) * y
function code(x, y) return Float64(Float64(Float64(x * 3.0) * x) * y) end
function tmp = code(x, y) tmp = ((x * 3.0) * x) * y; end
code[x_, y_] := N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot 3\right) \cdot x\right) \cdot y
\end{array}
(FPCore (x y) :precision binary64 (* (* y x) (* 3.0 x)))
double code(double x, double y) {
return (y * x) * (3.0 * x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y * x) * (3.0d0 * x)
end function
public static double code(double x, double y) {
return (y * x) * (3.0 * x);
}
def code(x, y): return (y * x) * (3.0 * x)
function code(x, y) return Float64(Float64(y * x) * Float64(3.0 * x)) end
function tmp = code(x, y) tmp = (y * x) * (3.0 * x); end
code[x_, y_] := N[(N[(y * x), $MachinePrecision] * N[(3.0 * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y \cdot x\right) \cdot \left(3 \cdot x\right)
\end{array}
Initial program 90.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
sqr-neg-revN/A
associate-*l*N/A
associate-*r*N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
rem-square-sqrtN/A
sqrt-prodN/A
sqr-neg-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-neg-outN/A
distribute-lft-neg-outN/A
remove-double-negN/A
rem-square-sqrtN/A
sqrt-prodN/A
rem-sqrt-square-revN/A
Applied rewrites44.2%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
sqr-powN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
metadata-eval46.3
Applied rewrites46.3%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
lift-pow.f64N/A
pow-prod-upN/A
metadata-evalN/A
metadata-evalN/A
pow-plusN/A
pow1/2N/A
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
(FPCore (x y) :precision binary64 (* (* y 3.0) (* x x)))
double code(double x, double y) {
return (y * 3.0) * (x * x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y * 3.0d0) * (x * x)
end function
public static double code(double x, double y) {
return (y * 3.0) * (x * x);
}
def code(x, y): return (y * 3.0) * (x * x)
function code(x, y) return Float64(Float64(y * 3.0) * Float64(x * x)) end
function tmp = code(x, y) tmp = (y * 3.0) * (x * x); end
code[x_, y_] := N[(N[(y * 3.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y \cdot 3\right) \cdot \left(x \cdot x\right)
\end{array}
Initial program 90.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
fabs-sqrN/A
sqr-neg-revN/A
distribute-rgt-neg-outN/A
fabs-negN/A
rem-sqrt-squareN/A
sqrt-prodN/A
rem-square-sqrtN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rem-square-sqrtN/A
sqrt-prodN/A
rem-sqrt-squareN/A
fabs-negN/A
distribute-rgt-neg-outN/A
sqr-neg-revN/A
Applied rewrites90.0%
(FPCore (x y) :precision binary64 (* (* x 3.0) (* x y)))
double code(double x, double y) {
return (x * 3.0) * (x * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 3.0d0) * (x * y)
end function
public static double code(double x, double y) {
return (x * 3.0) * (x * y);
}
def code(x, y): return (x * 3.0) * (x * y)
function code(x, y) return Float64(Float64(x * 3.0) * Float64(x * y)) end
function tmp = code(x, y) tmp = (x * 3.0) * (x * y); end
code[x_, y_] := N[(N[(x * 3.0), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 3\right) \cdot \left(x \cdot y\right)
\end{array}
herbie shell --seed 2024343
(FPCore (x y)
:name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, A"
:precision binary64
:alt
(! :herbie-platform default (* (* x 3) (* x y)))
(* (* (* x 3.0) x) y))