
(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 (+ (* 2.0 (* y y)) (fma (* (- y) y) (* y y) (* 9.0 (pow x 4.0)))))
double code(double x, double y) {
return (2.0 * (y * y)) + fma((-y * y), (y * y), (9.0 * pow(x, 4.0)));
}
function code(x, y) return Float64(Float64(2.0 * Float64(y * y)) + fma(Float64(Float64(-y) * y), Float64(y * y), Float64(9.0 * (x ^ 4.0)))) end
code[x_, y_] := N[(N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[((-y) * y), $MachinePrecision] * N[(y * y), $MachinePrecision] + N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(y \cdot y\right) + \mathsf{fma}\left(\left(-y\right) \cdot y, y \cdot y, 9 \cdot {x}^{4}\right)
\end{array}
Initial program 18.8%
lift-*.f64N/A
lift-pow.f64N/A
sqr-powN/A
associate-*r*N/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f6418.8
Applied rewrites18.8%
Applied rewrites21.8%
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (+ (- (* (* (* (* x x) 9.0) x) x) (pow y 4.0)) (* 2.0 (* y y))))
double code(double x, double y) {
return (((((x * x) * 9.0) * x) * x) - 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 = (((((x * x) * 9.0d0) * x) * x) - (y ** 4.0d0)) + (2.0d0 * (y * y))
end function
public static double code(double x, double y) {
return (((((x * x) * 9.0) * x) * x) - Math.pow(y, 4.0)) + (2.0 * (y * y));
}
def code(x, y): return (((((x * x) * 9.0) * x) * x) - math.pow(y, 4.0)) + (2.0 * (y * y))
function code(x, y) return Float64(Float64(Float64(Float64(Float64(Float64(x * x) * 9.0) * x) * x) - (y ^ 4.0)) + Float64(2.0 * Float64(y * y))) end
function tmp = code(x, y) tmp = (((((x * x) * 9.0) * x) * x) - (y ^ 4.0)) + (2.0 * (y * y)); end
code[x_, y_] := N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 9.0), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot x\right) \cdot 9\right) \cdot x\right) \cdot x - {y}^{4}\right) + 2 \cdot \left(y \cdot y\right)
\end{array}
Initial program 18.8%
lift-*.f64N/A
lift-pow.f64N/A
sqr-powN/A
associate-*r*N/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f6418.8
Applied rewrites18.8%
(FPCore (x y) :precision binary64 (+ (fma (* (* -9.0 x) x) (* x x) (pow y 4.0)) (* 2.0 (* y y))))
double code(double x, double y) {
return fma(((-9.0 * x) * x), (x * x), pow(y, 4.0)) + (2.0 * (y * y));
}
function code(x, y) return Float64(fma(Float64(Float64(-9.0 * x) * x), Float64(x * x), (y ^ 4.0)) + Float64(2.0 * Float64(y * y))) end
code[x_, y_] := N[(N[(N[(N[(-9.0 * x), $MachinePrecision] * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(-9 \cdot x\right) \cdot x, x \cdot x, {y}^{4}\right) + 2 \cdot \left(y \cdot y\right)
\end{array}
Initial program 18.8%
lift-*.f64N/A
lift-pow.f64N/A
sqr-powN/A
associate-*r*N/A
metadata-evalN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
lower-*.f6418.8
Applied rewrites18.8%
Applied rewrites11.1%
(FPCore (x y) :precision binary64 (- (* (* (* x x) 9.0) (* x x)) (* 2.0 (* y y))))
double code(double x, double y) {
return (((x * x) * 9.0) * (x * x)) - (2.0 * (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (((x * x) * 9.0d0) * (x * x)) - (2.0d0 * (y * y))
end function
public static double code(double x, double y) {
return (((x * x) * 9.0) * (x * x)) - (2.0 * (y * y));
}
def code(x, y): return (((x * x) * 9.0) * (x * x)) - (2.0 * (y * y))
function code(x, y) return Float64(Float64(Float64(Float64(x * x) * 9.0) * Float64(x * x)) - Float64(2.0 * Float64(y * y))) end
function tmp = code(x, y) tmp = (((x * x) * 9.0) * (x * x)) - (2.0 * (y * y)); end
code[x_, y_] := N[(N[(N[(N[(x * x), $MachinePrecision] * 9.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(2.0 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot x\right) \cdot 9\right) \cdot \left(x \cdot x\right) - 2 \cdot \left(y \cdot y\right)
\end{array}
Initial program 18.8%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-pow.f641.5
Applied rewrites1.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f649.6
Applied rewrites9.6%
Applied rewrites9.6%
lift-*.f64N/A
fabs-sqr-revN/A
lift-*.f64N/A
neg-fabsN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqr-revN/A
sqr-powN/A
unpow19.6
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-neg.f649.6
Applied rewrites9.6%
Final simplification9.6%
(FPCore (x y) :precision binary64 (* (* (* x x) 9.0) (* x x)))
double code(double x, double y) {
return ((x * x) * 9.0) * (x * x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * x) * 9.0d0) * (x * x)
end function
public static double code(double x, double y) {
return ((x * x) * 9.0) * (x * x);
}
def code(x, y): return ((x * x) * 9.0) * (x * x)
function code(x, y) return Float64(Float64(Float64(x * x) * 9.0) * Float64(x * x)) end
function tmp = code(x, y) tmp = ((x * x) * 9.0) * (x * x); end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] * 9.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot x\right) \cdot 9\right) \cdot \left(x \cdot x\right)
\end{array}
Initial program 18.8%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-pow.f641.5
Applied rewrites1.5%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f649.6
Applied rewrites9.6%
Applied rewrites9.6%
lift-*.f64N/A
count-2-revN/A
lift-*.f64N/A
cancel-sign-sub-invN/A
lift-neg.f64N/A
lift-*.f64N/A
unpow1N/A
sqr-powN/A
fabs-sqr-revN/A
sqr-powN/A
unpow1N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
neg-fabsN/A
lift-*.f64N/A
fabs-sqr-revN/A
lift-*.f64N/A
+-inverses9.6
Applied rewrites9.6%
Final simplification9.6%
herbie shell --seed 2024312
(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))))