
(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 2 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 (let* ((t_0 (* 3.0 (* x x)))) (+ (* (+ t_0 (* y y)) (- t_0 (* y y))) (* (* y y) 2.0))))
double code(double x, double y) {
double t_0 = 3.0 * (x * x);
return ((t_0 + (y * y)) * (t_0 - (y * y))) + ((y * y) * 2.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = 3.0d0 * (x * x)
code = ((t_0 + (y * y)) * (t_0 - (y * y))) + ((y * y) * 2.0d0)
end function
public static double code(double x, double y) {
double t_0 = 3.0 * (x * x);
return ((t_0 + (y * y)) * (t_0 - (y * y))) + ((y * y) * 2.0);
}
def code(x, y): t_0 = 3.0 * (x * x) return ((t_0 + (y * y)) * (t_0 - (y * y))) + ((y * y) * 2.0)
function code(x, y) t_0 = Float64(3.0 * Float64(x * x)) return Float64(Float64(Float64(t_0 + Float64(y * y)) * Float64(t_0 - Float64(y * y))) + Float64(Float64(y * y) * 2.0)) end
function tmp = code(x, y) t_0 = 3.0 * (x * x); tmp = ((t_0 + (y * y)) * (t_0 - (y * y))) + ((y * y) * 2.0); end
code[x_, y_] := Block[{t$95$0 = N[(3.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(t$95$0 + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(y * y), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 3 \cdot \left(x \cdot x\right)\\
\left(t\_0 + y \cdot y\right) \cdot \left(t\_0 - y \cdot y\right) + \left(y \cdot y\right) \cdot 2
\end{array}
\end{array}
Initial program 18.8%
add-sqr-sqrt18.8%
sqr-pow18.8%
difference-of-squares100.0%
sqrt-prod100.0%
metadata-eval100.0%
sqrt-pow1100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
sqrt-prod100.0%
metadata-eval100.0%
sqrt-pow1100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (+ (* (* y y) 2.0) (- (* 9.0 (* (* x x) (* x x))) (* (* y y) (* y y)))))
double code(double x, double y) {
return ((y * y) * 2.0) + ((9.0 * ((x * x) * (x * x))) - ((y * y) * (y * y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((y * y) * 2.0d0) + ((9.0d0 * ((x * x) * (x * x))) - ((y * y) * (y * y)))
end function
public static double code(double x, double y) {
return ((y * y) * 2.0) + ((9.0 * ((x * x) * (x * x))) - ((y * y) * (y * y)));
}
def code(x, y): return ((y * y) * 2.0) + ((9.0 * ((x * x) * (x * x))) - ((y * y) * (y * y)))
function code(x, y) return Float64(Float64(Float64(y * y) * 2.0) + Float64(Float64(9.0 * Float64(Float64(x * x) * Float64(x * x))) - Float64(Float64(y * y) * Float64(y * y)))) end
function tmp = code(x, y) tmp = ((y * y) * 2.0) + ((9.0 * ((x * x) * (x * x))) - ((y * y) * (y * y))); end
code[x_, y_] := N[(N[(N[(y * y), $MachinePrecision] * 2.0), $MachinePrecision] + N[(N[(9.0 * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y * y), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y \cdot y\right) \cdot 2 + \left(9 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) - \left(y \cdot y\right) \cdot \left(y \cdot y\right)\right)
\end{array}
Initial program 18.8%
metadata-eval18.8%
pow-sqr18.8%
pow218.8%
pow218.8%
metadata-eval18.8%
pow-sqr18.8%
pow218.8%
pow218.8%
Applied egg-rr18.8%
Final simplification18.8%
herbie shell --seed 2024097
(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))))