
(FPCore (x y) :precision binary64 (+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* 2.0 (* y y))))
double code(double x, double y) {
return ((9.0 * pow(x, 4.0)) - pow(y, 4.0)) + (2.0 * (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((9.0d0 * (x ** 4.0d0)) - (y ** 4.0d0)) + (2.0d0 * (y * y))
end function
public static double code(double x, double y) {
return ((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0)) + (2.0 * (y * y));
}
def code(x, y): return ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0)) + (2.0 * (y * y))
function code(x, y) return Float64(Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) + Float64(2.0 * Float64(y * y))) end
function tmp = code(x, y) tmp = ((9.0 * (x ^ 4.0)) - (y ^ 4.0)) + (2.0 * (y * y)); end
code[x_, y_] := N[(N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* 2.0 (* y y))))
double code(double x, double y) {
return ((9.0 * pow(x, 4.0)) - pow(y, 4.0)) + (2.0 * (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((9.0d0 * (x ** 4.0d0)) - (y ** 4.0d0)) + (2.0d0 * (y * y))
end function
public static double code(double x, double y) {
return ((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0)) + (2.0 * (y * y));
}
def code(x, y): return ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0)) + (2.0 * (y * y))
function code(x, y) return Float64(Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) + Float64(2.0 * Float64(y * y))) end
function tmp = code(x, y) tmp = ((9.0 * (x ^ 4.0)) - (y ^ 4.0)) + (2.0 * (y * y)); end
code[x_, y_] := N[(N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right)
\end{array}
(FPCore (x y) :precision binary64 (+ (fma (pow y 2.0) (- (pow y 2.0)) (* 9.0 (pow x 4.0))) (* 2.0 (* y y))))
double code(double x, double y) {
return fma(pow(y, 2.0), -pow(y, 2.0), (9.0 * pow(x, 4.0))) + (2.0 * (y * y));
}
function code(x, y) return Float64(fma((y ^ 2.0), Float64(-(y ^ 2.0)), Float64(9.0 * (x ^ 4.0))) + Float64(2.0 * Float64(y * y))) end
code[x_, y_] := N[(N[(N[Power[y, 2.0], $MachinePrecision] * (-N[Power[y, 2.0], $MachinePrecision]) + N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left({y}^{2}, -{y}^{2}, 9 \cdot {x}^{4}\right) + 2 \cdot \left(y \cdot y\right)
\end{array}
Initial program 18.8%
sub-neg18.8%
+-commutative18.8%
metadata-eval18.8%
pow-prod-up18.8%
pow218.8%
pow218.8%
distribute-rgt-neg-in18.8%
fma-define100.0%
pow2100.0%
pow2100.0%
Applied egg-rr100.0%
(FPCore (x y) :precision binary64 (+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (pow (* (pow y 6.0) 8.0) 0.3333333333333333)))
double code(double x, double y) {
return ((9.0 * pow(x, 4.0)) - pow(y, 4.0)) + pow((pow(y, 6.0) * 8.0), 0.3333333333333333);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((9.0d0 * (x ** 4.0d0)) - (y ** 4.0d0)) + (((y ** 6.0d0) * 8.0d0) ** 0.3333333333333333d0)
end function
public static double code(double x, double y) {
return ((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0)) + Math.pow((Math.pow(y, 6.0) * 8.0), 0.3333333333333333);
}
def code(x, y): return ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0)) + math.pow((math.pow(y, 6.0) * 8.0), 0.3333333333333333)
function code(x, y) return Float64(Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) + (Float64((y ^ 6.0) * 8.0) ^ 0.3333333333333333)) end
function tmp = code(x, y) tmp = ((9.0 * (x ^ 4.0)) - (y ^ 4.0)) + (((y ^ 6.0) * 8.0) ^ 0.3333333333333333); end
code[x_, y_] := N[(N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Power[y, 6.0], $MachinePrecision] * 8.0), $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(9 \cdot {x}^{4} - {y}^{4}\right) + {\left({y}^{6} \cdot 8\right)}^{0.3333333333333333}
\end{array}
Initial program 18.8%
add-cbrt-cube18.7%
pow1/318.8%
pow218.8%
pow218.8%
pow-prod-up18.8%
metadata-eval18.8%
pow218.8%
pow-prod-up18.8%
metadata-eval18.8%
Applied egg-rr18.8%
pow-pow18.8%
metadata-eval18.8%
add-cbrt-cube18.7%
pow1/318.8%
pow218.8%
pow218.8%
pow218.8%
pow318.8%
pow218.8%
*-commutative18.8%
unpow-prod-down18.8%
pow218.8%
pow-prod-down18.8%
pow-sqr18.8%
metadata-eval18.8%
metadata-eval18.8%
Applied egg-rr18.8%
(FPCore (x y) :precision binary64 (+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* 2.0 (pow (pow y 6.0) 0.3333333333333333))))
double code(double x, double y) {
return ((9.0 * pow(x, 4.0)) - pow(y, 4.0)) + (2.0 * pow(pow(y, 6.0), 0.3333333333333333));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((9.0d0 * (x ** 4.0d0)) - (y ** 4.0d0)) + (2.0d0 * ((y ** 6.0d0) ** 0.3333333333333333d0))
end function
public static double code(double x, double y) {
return ((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0)) + (2.0 * Math.pow(Math.pow(y, 6.0), 0.3333333333333333));
}
def code(x, y): return ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0)) + (2.0 * math.pow(math.pow(y, 6.0), 0.3333333333333333))
function code(x, y) return Float64(Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) + Float64(2.0 * ((y ^ 6.0) ^ 0.3333333333333333))) end
function tmp = code(x, y) tmp = ((9.0 * (x ^ 4.0)) - (y ^ 4.0)) + (2.0 * ((y ^ 6.0) ^ 0.3333333333333333)); end
code[x_, y_] := N[(N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[Power[N[Power[y, 6.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(9 \cdot {x}^{4} - {y}^{4}\right) + 2 \cdot {\left({y}^{6}\right)}^{0.3333333333333333}
\end{array}
Initial program 18.8%
add-cbrt-cube18.7%
pow1/318.8%
pow218.8%
pow218.8%
pow-prod-up18.8%
metadata-eval18.8%
pow218.8%
pow-prod-up18.8%
metadata-eval18.8%
Applied egg-rr18.8%
(FPCore (x y) :precision binary64 (+ (* 2.0 (* y y)) (- (* 9.0 (pow x 4.0)) (pow y 4.0))))
double code(double x, double y) {
return (2.0 * (y * y)) + ((9.0 * pow(x, 4.0)) - pow(y, 4.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (2.0d0 * (y * y)) + ((9.0d0 * (x ** 4.0d0)) - (y ** 4.0d0))
end function
public static double code(double x, double y) {
return (2.0 * (y * y)) + ((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0));
}
def code(x, y): return (2.0 * (y * y)) + ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0))
function code(x, y) return Float64(Float64(2.0 * Float64(y * y)) + Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0))) end
function tmp = code(x, y) tmp = (2.0 * (y * y)) + ((9.0 * (x ^ 4.0)) - (y ^ 4.0)); end
code[x_, y_] := N[(N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(y \cdot y\right) + \left(9 \cdot {x}^{4} - {y}^{4}\right)
\end{array}
Initial program 18.8%
Final simplification18.8%
(FPCore (x y) :precision binary64 (* 2.0 (* y y)))
double code(double x, double y) {
return 2.0 * (y * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 2.0d0 * (y * y)
end function
public static double code(double x, double y) {
return 2.0 * (y * y);
}
def code(x, y): return 2.0 * (y * y)
function code(x, y) return Float64(2.0 * Float64(y * y)) end
function tmp = code(x, y) tmp = 2.0 * (y * y); end
code[x_, y_] := N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(y \cdot y\right)
\end{array}
Initial program 18.8%
Taylor expanded in x around 0 1.5%
neg-mul-11.5%
Simplified1.5%
Taylor expanded in y around 0 11.1%
unpow211.1%
Applied egg-rr11.1%
herbie shell --seed 2024143
(FPCore (x y)
:name "From Rump in a 1983 paper"
:precision binary64
:pre (and (== x 10864.0) (== y 18817.0))
(+ (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* 2.0 (* y y))))