
(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 4 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 (* (* x 3.0) y)))
double code(double x, double y) {
return y * ((x * 3.0) * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * ((x * 3.0d0) * y)
end function
public static double code(double x, double y) {
return y * ((x * 3.0) * y);
}
def code(x, y): return y * ((x * 3.0) * y)
function code(x, y) return Float64(y * Float64(Float64(x * 3.0) * y)) end
function tmp = code(x, y) tmp = y * ((x * 3.0) * y); end
code[x_, y_] := N[(y * N[(N[(x * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(\left(x \cdot 3\right) \cdot y\right)
\end{array}
Initial program 99.7%
Final simplification99.7%
(FPCore (x y) :precision binary64 (* 3.0 (* y (* x y))))
double code(double x, double y) {
return 3.0 * (y * (x * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 3.0d0 * (y * (x * y))
end function
public static double code(double x, double y) {
return 3.0 * (y * (x * y));
}
def code(x, y): return 3.0 * (y * (x * y))
function code(x, y) return Float64(3.0 * Float64(y * Float64(x * y))) end
function tmp = code(x, y) tmp = 3.0 * (y * (x * y)); end
code[x_, y_] := N[(3.0 * N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(y \cdot \left(x \cdot y\right)\right)
\end{array}
Initial program 99.7%
associate-*l*89.9%
associate-*l*89.8%
Simplified89.8%
Taylor expanded in x around 0 89.8%
add-sqr-sqrt56.4%
pow256.4%
*-commutative56.4%
sqrt-prod45.7%
unpow245.7%
sqrt-prod21.7%
add-sqr-sqrt50.1%
Applied egg-rr50.1%
unpow250.1%
*-commutative50.1%
associate-*r*50.1%
associate-*r*50.1%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (* y (* 3.0 (* x y))))
double code(double x, double y) {
return y * (3.0 * (x * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y * (3.0d0 * (x * y))
end function
public static double code(double x, double y) {
return y * (3.0 * (x * y));
}
def code(x, y): return y * (3.0 * (x * y))
function code(x, y) return Float64(y * Float64(3.0 * Float64(x * y))) end
function tmp = code(x, y) tmp = y * (3.0 * (x * y)); end
code[x_, y_] := N[(y * N[(3.0 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(3 \cdot \left(x \cdot y\right)\right)
\end{array}
Initial program 99.7%
Taylor expanded in x around 0 99.7%
Final simplification99.7%
(FPCore (x y) :precision binary64 (* (* 3.0 y) (* x y)))
double code(double x, double y) {
return (3.0 * y) * (x * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (3.0d0 * y) * (x * y)
end function
public static double code(double x, double y) {
return (3.0 * y) * (x * y);
}
def code(x, y): return (3.0 * y) * (x * y)
function code(x, y) return Float64(Float64(3.0 * y) * Float64(x * y)) end
function tmp = code(x, y) tmp = (3.0 * y) * (x * y); end
code[x_, y_] := N[(N[(3.0 * y), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 \cdot y\right) \cdot \left(x \cdot y\right)
\end{array}
Initial program 99.7%
associate-*l*89.9%
associate-*l*89.8%
Simplified89.8%
add-cube-cbrt89.2%
pow389.2%
associate-*r*89.1%
*-commutative89.1%
associate-*l*89.1%
pow289.1%
Applied egg-rr89.1%
rem-cube-cbrt89.8%
unpow289.8%
associate-*r*99.6%
associate-*l*99.7%
*-commutative99.7%
associate-*r*99.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 2024048
(FPCore (x y)
:name "Diagrams.Segment:$catParam from diagrams-lib-1.3.0.3, B"
:precision binary64
:alt
(* (* x (* 3.0 y)) y)
(* (* (* x 3.0) y) y))