
(FPCore (x y) :precision binary64 (- (* 9.0 (pow x 4.0)) (* (* y y) (- (* y y) 2.0))))
double code(double x, double y) {
return (9.0 * pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (9.0d0 * (x ** 4.0d0)) - ((y * y) * ((y * y) - 2.0d0))
end function
public static double code(double x, double y) {
return (9.0 * Math.pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0));
}
def code(x, y): return (9.0 * math.pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0))
function code(x, y) return Float64(Float64(9.0 * (x ^ 4.0)) - Float64(Float64(y * y) * Float64(Float64(y * y) - 2.0))) end
function tmp = code(x, y) tmp = (9.0 * (x ^ 4.0)) - ((y * y) * ((y * y) - 2.0)); end
code[x_, y_] := N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
9 \cdot {x}^{4} - \left(y \cdot y\right) \cdot \left(y \cdot y - 2\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)) (* (* y y) (- (* y y) 2.0))))
double code(double x, double y) {
return (9.0 * pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (9.0d0 * (x ** 4.0d0)) - ((y * y) * ((y * y) - 2.0d0))
end function
public static double code(double x, double y) {
return (9.0 * Math.pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0));
}
def code(x, y): return (9.0 * math.pow(x, 4.0)) - ((y * y) * ((y * y) - 2.0))
function code(x, y) return Float64(Float64(9.0 * (x ^ 4.0)) - Float64(Float64(y * y) * Float64(Float64(y * y) - 2.0))) end
function tmp = code(x, y) tmp = (9.0 * (x ^ 4.0)) - ((y * y) * ((y * y) - 2.0)); end
code[x_, y_] := N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[(N[(y * y), $MachinePrecision] * N[(N[(y * y), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
9 \cdot {x}^{4} - \left(y \cdot y\right) \cdot \left(y \cdot y - 2\right)
\end{array}
(FPCore (x y) :precision binary64 (let* ((t_0 (* (pow x 2.0) 3.0))) (- (* (- t_0 (pow y 2.0)) (+ t_0 (pow y 2.0))) (* (pow y 2.0) -2.0))))
double code(double x, double y) {
double t_0 = pow(x, 2.0) * 3.0;
return ((t_0 - pow(y, 2.0)) * (t_0 + pow(y, 2.0))) - (pow(y, 2.0) * -2.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (x ** 2.0d0) * 3.0d0
code = ((t_0 - (y ** 2.0d0)) * (t_0 + (y ** 2.0d0))) - ((y ** 2.0d0) * (-2.0d0))
end function
public static double code(double x, double y) {
double t_0 = Math.pow(x, 2.0) * 3.0;
return ((t_0 - Math.pow(y, 2.0)) * (t_0 + Math.pow(y, 2.0))) - (Math.pow(y, 2.0) * -2.0);
}
def code(x, y): t_0 = math.pow(x, 2.0) * 3.0 return ((t_0 - math.pow(y, 2.0)) * (t_0 + math.pow(y, 2.0))) - (math.pow(y, 2.0) * -2.0)
function code(x, y) t_0 = Float64((x ^ 2.0) * 3.0) return Float64(Float64(Float64(t_0 - (y ^ 2.0)) * Float64(t_0 + (y ^ 2.0))) - Float64((y ^ 2.0) * -2.0)) end
function tmp = code(x, y) t_0 = (x ^ 2.0) * 3.0; tmp = ((t_0 - (y ^ 2.0)) * (t_0 + (y ^ 2.0))) - ((y ^ 2.0) * -2.0); end
code[x_, y_] := Block[{t$95$0 = N[(N[Power[x, 2.0], $MachinePrecision] * 3.0), $MachinePrecision]}, N[(N[(N[(t$95$0 - N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Power[y, 2.0], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{2} \cdot 3\\
\left(t_0 - {y}^{2}\right) \cdot \left(t_0 + {y}^{2}\right) - {y}^{2} \cdot -2
\end{array}
\end{array}
(FPCore (x y) :precision binary64 (- (cbrt (pow (- (* 9.0 (pow x 4.0)) (pow y 4.0)) 3.0)) (* (pow y 2.0) -2.0)))
double code(double x, double y) {
return cbrt(pow(((9.0 * pow(x, 4.0)) - pow(y, 4.0)), 3.0)) - (pow(y, 2.0) * -2.0);
}
public static double code(double x, double y) {
return Math.cbrt(Math.pow(((9.0 * Math.pow(x, 4.0)) - Math.pow(y, 4.0)), 3.0)) - (Math.pow(y, 2.0) * -2.0);
}
function code(x, y) return Float64(cbrt((Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) ^ 3.0)) - Float64((y ^ 2.0) * -2.0)) end
code[x_, y_] := N[(N[Power[N[Power[N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision] - N[(N[Power[y, 2.0], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{{\left(9 \cdot {x}^{4} - {y}^{4}\right)}^{3}} - {y}^{2} \cdot -2
\end{array}
(FPCore (x y) :precision binary64 (- (- (* 9.0 (pow x 4.0)) (pow y 4.0)) (* (pow y 2.0) -2.0)))
double code(double x, double y) {
return ((9.0 * pow(x, 4.0)) - pow(y, 4.0)) - (pow(y, 2.0) * -2.0);
}
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 ** 2.0d0) * (-2.0d0))
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(y, 2.0) * -2.0);
}
def code(x, y): return ((9.0 * math.pow(x, 4.0)) - math.pow(y, 4.0)) - (math.pow(y, 2.0) * -2.0)
function code(x, y) return Float64(Float64(Float64(9.0 * (x ^ 4.0)) - (y ^ 4.0)) - Float64((y ^ 2.0) * -2.0)) end
function tmp = code(x, y) tmp = ((9.0 * (x ^ 4.0)) - (y ^ 4.0)) - ((y ^ 2.0) * -2.0); end
code[x_, y_] := N[(N[(N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision] - N[(N[Power[y, 2.0], $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(9 \cdot {x}^{4} - {y}^{4}\right) - {y}^{2} \cdot -2
\end{array}
(FPCore (x y) :precision binary64 (* 9.0 (pow x 4.0)))
double code(double x, double y) {
return 9.0 * pow(x, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 9.0d0 * (x ** 4.0d0)
end function
public static double code(double x, double y) {
return 9.0 * Math.pow(x, 4.0);
}
def code(x, y): return 9.0 * math.pow(x, 4.0)
function code(x, y) return Float64(9.0 * (x ^ 4.0)) end
function tmp = code(x, y) tmp = 9.0 * (x ^ 4.0); end
code[x_, y_] := N[(9.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
9 \cdot {x}^{4}
\end{array}
(FPCore (x y) :precision binary64 (- (pow y 4.0)))
double code(double x, double y) {
return -pow(y, 4.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -(y ** 4.0d0)
end function
public static double code(double x, double y) {
return -Math.pow(y, 4.0);
}
def code(x, y): return -math.pow(y, 4.0)
function code(x, y) return Float64(-(y ^ 4.0)) end
function tmp = code(x, y) tmp = -(y ^ 4.0); end
code[x_, y_] := (-N[Power[y, 4.0], $MachinePrecision])
\begin{array}{l}
\\
-{y}^{4}
\end{array}
herbie shell --seed 2024010
(FPCore (x y)
:name "From Rump in a 1983 paper, rewritten"
:precision binary64
:pre (and (== x 10864.0) (== y 18817.0))
(- (* 9.0 (pow x 4.0)) (* (* y y) (- (* y y) 2.0))))