
(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 (* 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(y * Float64(Float64(y * 3.0) * x)) end
function tmp = code(x, y) tmp = y * ((y * 3.0) * x); end
code[x_, y_] := N[(y * N[(N[(y * 3.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(\left(y \cdot 3\right) \cdot x\right)
\end{array}
Initial program 99.3%
add-cbrt-cube83.2%
pow383.2%
*-commutative83.2%
associate-*l*83.2%
Applied egg-rr83.2%
rem-cbrt-cube99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x y) :precision binary64 (* 3.0 (* y (* y x))))
double code(double x, double y) {
return 3.0 * (y * (y * x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 3.0d0 * (y * (y * x))
end function
public static double code(double x, double y) {
return 3.0 * (y * (y * x));
}
def code(x, y): return 3.0 * (y * (y * x))
function code(x, y) return Float64(3.0 * Float64(y * Float64(y * x))) end
function tmp = code(x, y) tmp = 3.0 * (y * (y * x)); end
code[x_, y_] := N[(3.0 * N[(y * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(y \cdot \left(y \cdot x\right)\right)
\end{array}
Initial program 99.3%
associate-*l*99.7%
associate-*l*86.1%
Simplified86.1%
Taylor expanded in x around 0 86.5%
unpow286.5%
associate-*l*99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y) :precision binary64 (* (* y 3.0) (* y x)))
double code(double x, double y) {
return (y * 3.0) * (y * x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y * 3.0d0) * (y * x)
end function
public static double code(double x, double y) {
return (y * 3.0) * (y * x);
}
def code(x, y): return (y * 3.0) * (y * x)
function code(x, y) return Float64(Float64(y * 3.0) * Float64(y * x)) end
function tmp = code(x, y) tmp = (y * 3.0) * (y * x); end
code[x_, y_] := N[(N[(y * 3.0), $MachinePrecision] * N[(y * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y \cdot 3\right) \cdot \left(y \cdot x\right)
\end{array}
Initial program 99.3%
associate-*l*99.7%
associate-*l*86.1%
Simplified86.1%
associate-*l*86.1%
associate-*l*86.2%
add-sqr-sqrt55.9%
sqrt-unprod50.3%
pow250.3%
add-sqr-sqrt49.8%
pow249.8%
pow-pow49.8%
*-commutative49.8%
sqrt-prod38.2%
sqrt-prod17.1%
add-sqr-sqrt41.5%
metadata-eval41.5%
Applied egg-rr41.5%
sqrt-pow151.7%
metadata-eval51.7%
unpow251.7%
swap-sqr44.3%
add-sqr-sqrt86.2%
associate-*l*86.5%
associate-*r*99.7%
*-commutative99.7%
*-commutative99.7%
associate-*l*99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(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 2023196
(FPCore (x y)
:name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, B"
:precision binary64
:herbie-target
(* (* x (* 3.0 y)) y)
(* (* (* x 3.0) y) y))