
(FPCore (x y) :precision binary64 (* (* (* x 3.0) y) y))
double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 3.0d0) * y) * y
end function
public static double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
def code(x, y): return ((x * 3.0) * y) * y
function code(x, y) return Float64(Float64(Float64(x * 3.0) * y) * y) end
function tmp = code(x, y) tmp = ((x * 3.0) * y) * y; end
code[x_, y_] := N[(N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot 3\right) \cdot y\right) \cdot y
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (* (* x 3.0) y) y))
double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 3.0d0) * y) * y
end function
public static double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
def code(x, y): return ((x * 3.0) * y) * y
function code(x, y) return Float64(Float64(Float64(x * 3.0) * y) * y) end
function tmp = code(x, y) tmp = ((x * 3.0) * y) * y; end
code[x_, y_] := N[(N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot 3\right) \cdot y\right) \cdot y
\end{array}
(FPCore (x y) :precision binary64 (* (* (* x 3.0) y) y))
double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 3.0d0) * y) * y
end function
public static double code(double x, double y) {
return ((x * 3.0) * y) * y;
}
def code(x, y): return ((x * 3.0) * y) * y
function code(x, y) return Float64(Float64(Float64(x * 3.0) * y) * y) end
function tmp = code(x, y) tmp = ((x * 3.0) * y) * y; end
code[x_, y_] := N[(N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot 3\right) \cdot y\right) \cdot y
\end{array}
Initial program 99.7%
(FPCore (x y) :precision binary64 (* (* x y) (* 3.0 y)))
double code(double x, double y) {
return (x * y) * (3.0 * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) * (3.0d0 * y)
end function
public static double code(double x, double y) {
return (x * y) * (3.0 * y);
}
def code(x, y): return (x * y) * (3.0 * y)
function code(x, y) return Float64(Float64(x * y) * Float64(3.0 * y)) end
function tmp = code(x, y) tmp = (x * y) * (3.0 * y); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] * N[(3.0 * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y\right) \cdot \left(3 \cdot y\right)
\end{array}
Initial program 99.7%
lift-*.f64N/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-outN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
*-commutativeN/A
lower-*.f64N/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-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-neg.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lift-*.f64N/A
sqr-neg-revN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
lift-neg.f64N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqr-neg-revN/A
sqrt-prodN/A
rem-square-sqrtN/A
Applied rewrites99.7%
(FPCore (x y) :precision binary64 (* (* (* y y) 3.0) x))
double code(double x, double y) {
return ((y * y) * 3.0) * x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((y * y) * 3.0d0) * x
end function
public static double code(double x, double y) {
return ((y * y) * 3.0) * x;
}
def code(x, y): return ((y * y) * 3.0) * x
function code(x, y) return Float64(Float64(Float64(y * y) * 3.0) * x) end
function tmp = code(x, y) tmp = ((y * y) * 3.0) * x; end
code[x_, y_] := N[(N[(N[(y * y), $MachinePrecision] * 3.0), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(y \cdot y\right) \cdot 3\right) \cdot x
\end{array}
Initial program 99.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.1
Applied rewrites90.1%
(FPCore (x y) :precision binary64 (* (* x (* 3.0 y)) y))
double code(double x, double y) {
return (x * (3.0 * y)) * y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * (3.0d0 * y)) * y
end function
public static double code(double x, double y) {
return (x * (3.0 * y)) * y;
}
def code(x, y): return (x * (3.0 * y)) * y
function code(x, y) return Float64(Float64(x * Float64(3.0 * y)) * y) end
function tmp = code(x, y) tmp = (x * (3.0 * y)) * y; end
code[x_, y_] := N[(N[(x * N[(3.0 * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot \left(3 \cdot y\right)\right) \cdot y
\end{array}
herbie shell --seed 2024329
(FPCore (x y)
:name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, B"
:precision binary64
:alt
(! :herbie-platform default (* (* x (* 3 y)) y))
(* (* (* x 3.0) y) y))