
(FPCore (x y) :precision binary64 -0.8273960599468214)
double code(double x, double y) {
return -0.8273960599468214;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -0.8273960599468214d0
end function
public static double code(double x, double y) {
return -0.8273960599468214;
}
def code(x, y): return -0.8273960599468214
function code(x, y) return -0.8273960599468214 end
function tmp = code(x, y) tmp = -0.8273960599468214; end
code[x_, y_] := -0.8273960599468214
\begin{array}{l}
\\
-0.8273960599468214
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y)
:precision binary64
(+
(+
(+
(* 333.75 (pow y 6.0))
(*
(* x x)
(-
(- (- (* (* (* (* 11.0 x) x) y) y) (pow y 6.0)) (* 121.0 (pow y 4.0)))
2.0)))
(* 5.5 (pow y 8.0)))
(/ x (* 2.0 y))))
double code(double x, double y) {
return (((333.75 * pow(y, 6.0)) + ((x * x) * (((((((11.0 * x) * x) * y) * y) - pow(y, 6.0)) - (121.0 * pow(y, 4.0))) - 2.0))) + (5.5 * pow(y, 8.0))) + (x / (2.0 * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (((333.75d0 * (y ** 6.0d0)) + ((x * x) * (((((((11.0d0 * x) * x) * y) * y) - (y ** 6.0d0)) - (121.0d0 * (y ** 4.0d0))) - 2.0d0))) + (5.5d0 * (y ** 8.0d0))) + (x / (2.0d0 * y))
end function
public static double code(double x, double y) {
return (((333.75 * Math.pow(y, 6.0)) + ((x * x) * (((((((11.0 * x) * x) * y) * y) - Math.pow(y, 6.0)) - (121.0 * Math.pow(y, 4.0))) - 2.0))) + (5.5 * Math.pow(y, 8.0))) + (x / (2.0 * y));
}
def code(x, y): return (((333.75 * math.pow(y, 6.0)) + ((x * x) * (((((((11.0 * x) * x) * y) * y) - math.pow(y, 6.0)) - (121.0 * math.pow(y, 4.0))) - 2.0))) + (5.5 * math.pow(y, 8.0))) + (x / (2.0 * y))
function code(x, y) return Float64(Float64(Float64(Float64(333.75 * (y ^ 6.0)) + Float64(Float64(x * x) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(11.0 * x) * x) * y) * y) - (y ^ 6.0)) - Float64(121.0 * (y ^ 4.0))) - 2.0))) + Float64(5.5 * (y ^ 8.0))) + Float64(x / Float64(2.0 * y))) end
function tmp = code(x, y) tmp = (((333.75 * (y ^ 6.0)) + ((x * x) * (((((((11.0 * x) * x) * y) * y) - (y ^ 6.0)) - (121.0 * (y ^ 4.0))) - 2.0))) + (5.5 * (y ^ 8.0))) + (x / (2.0 * y)); end
code[x_, y_] := N[(N[(N[(N[(333.75 * N[Power[y, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(11.0 * x), $MachinePrecision] * x), $MachinePrecision] * y), $MachinePrecision] * y), $MachinePrecision] - N[Power[y, 6.0], $MachinePrecision]), $MachinePrecision] - N[(121.0 * N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(5.5 * N[Power[y, 8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(333.75 \cdot {y}^{6} + \left(x \cdot x\right) \cdot \left(\left(\left(\left(\left(\left(11 \cdot x\right) \cdot x\right) \cdot y\right) \cdot y - {y}^{6}\right) - 121 \cdot {y}^{4}\right) - 2\right)\right) + 5.5 \cdot {y}^{8}\right) + \frac{x}{2 \cdot y}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ (* y (* x -2.0)) -0.5)) (t_1 (* y (* y y))))
(*
(/
(/ (+ 0.125 (* (* -8.0 (* x (* x x))) t_1)) (/ y x))
(+
0.015625
(*
(* (* x -2.0) (* y t_0))
(* (* x (* y (* y (* x 4.0)))) (* t_0 t_0)))))
(+ 0.0625 (* x (+ (* y -0.25) (* (* x t_1) (* x 8.0))))))))assert(x < y);
double code(double x, double y) {
double t_0 = (y * (x * -2.0)) + -0.5;
double t_1 = y * (y * y);
return (((0.125 + ((-8.0 * (x * (x * x))) * t_1)) / (y / x)) / (0.015625 + (((x * -2.0) * (y * t_0)) * ((x * (y * (y * (x * 4.0)))) * (t_0 * t_0))))) * (0.0625 + (x * ((y * -0.25) + ((x * t_1) * (x * 8.0)))));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
t_0 = (y * (x * (-2.0d0))) + (-0.5d0)
t_1 = y * (y * y)
code = (((0.125d0 + (((-8.0d0) * (x * (x * x))) * t_1)) / (y / x)) / (0.015625d0 + (((x * (-2.0d0)) * (y * t_0)) * ((x * (y * (y * (x * 4.0d0)))) * (t_0 * t_0))))) * (0.0625d0 + (x * ((y * (-0.25d0)) + ((x * t_1) * (x * 8.0d0)))))
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = (y * (x * -2.0)) + -0.5;
double t_1 = y * (y * y);
return (((0.125 + ((-8.0 * (x * (x * x))) * t_1)) / (y / x)) / (0.015625 + (((x * -2.0) * (y * t_0)) * ((x * (y * (y * (x * 4.0)))) * (t_0 * t_0))))) * (0.0625 + (x * ((y * -0.25) + ((x * t_1) * (x * 8.0)))));
}
[x, y] = sort([x, y]) def code(x, y): t_0 = (y * (x * -2.0)) + -0.5 t_1 = y * (y * y) return (((0.125 + ((-8.0 * (x * (x * x))) * t_1)) / (y / x)) / (0.015625 + (((x * -2.0) * (y * t_0)) * ((x * (y * (y * (x * 4.0)))) * (t_0 * t_0))))) * (0.0625 + (x * ((y * -0.25) + ((x * t_1) * (x * 8.0)))))
x, y = sort([x, y]) function code(x, y) t_0 = Float64(Float64(y * Float64(x * -2.0)) + -0.5) t_1 = Float64(y * Float64(y * y)) return Float64(Float64(Float64(Float64(0.125 + Float64(Float64(-8.0 * Float64(x * Float64(x * x))) * t_1)) / Float64(y / x)) / Float64(0.015625 + Float64(Float64(Float64(x * -2.0) * Float64(y * t_0)) * Float64(Float64(x * Float64(y * Float64(y * Float64(x * 4.0)))) * Float64(t_0 * t_0))))) * Float64(0.0625 + Float64(x * Float64(Float64(y * -0.25) + Float64(Float64(x * t_1) * Float64(x * 8.0)))))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
t_0 = (y * (x * -2.0)) + -0.5;
t_1 = y * (y * y);
tmp = (((0.125 + ((-8.0 * (x * (x * x))) * t_1)) / (y / x)) / (0.015625 + (((x * -2.0) * (y * t_0)) * ((x * (y * (y * (x * 4.0)))) * (t_0 * t_0))))) * (0.0625 + (x * ((y * -0.25) + ((x * t_1) * (x * 8.0)))));
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(N[(y * N[(x * -2.0), $MachinePrecision]), $MachinePrecision] + -0.5), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(y * y), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(N[(0.125 + N[(N[(-8.0 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] / N[(0.015625 + N[(N[(N[(x * -2.0), $MachinePrecision] * N[(y * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(N[(x * N[(y * N[(y * N[(x * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.0625 + N[(x * N[(N[(y * -0.25), $MachinePrecision] + N[(N[(x * t$95$1), $MachinePrecision] * N[(x * 8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot -2\right) + -0.5\\
t_1 := y \cdot \left(y \cdot y\right)\\
\frac{\frac{0.125 + \left(-8 \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot t\_1}{\frac{y}{x}}}{0.015625 + \left(\left(x \cdot -2\right) \cdot \left(y \cdot t\_0\right)\right) \cdot \left(\left(x \cdot \left(y \cdot \left(y \cdot \left(x \cdot 4\right)\right)\right)\right) \cdot \left(t\_0 \cdot t\_0\right)\right)} \cdot \left(0.0625 + x \cdot \left(y \cdot -0.25 + \left(x \cdot t\_1\right) \cdot \left(x \cdot 8\right)\right)\right)
\end{array}
\end{array}
Initial program 9.2%
Simplified3.1%
Taylor expanded in y around 0
/-lowering-/.f64N/A
associate-*r*N/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6410.8%
Simplified10.8%
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6410.8%
Applied egg-rr10.8%
Applied egg-rr10.8%
Taylor expanded in x around 0
Simplified17.8%
Final simplification17.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* x (+ (* x -2.0) (/ 0.5 y))))
assert(x < y);
double code(double x, double y) {
return x * ((x * -2.0) + (0.5 / y));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * ((x * (-2.0d0)) + (0.5d0 / y))
end function
assert x < y;
public static double code(double x, double y) {
return x * ((x * -2.0) + (0.5 / y));
}
[x, y] = sort([x, y]) def code(x, y): return x * ((x * -2.0) + (0.5 / y))
x, y = sort([x, y]) function code(x, y) return Float64(x * Float64(Float64(x * -2.0) + Float64(0.5 / y))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x * ((x * -2.0) + (0.5 / y));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x * N[(N[(x * -2.0), $MachinePrecision] + N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
x \cdot \left(x \cdot -2 + \frac{0.5}{y}\right)
\end{array}
Initial program 9.2%
Simplified3.1%
Taylor expanded in y around 0
/-lowering-/.f64N/A
associate-*r*N/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6410.8%
Simplified10.8%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6410.8%
Simplified10.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* x (* x -2.0)))
assert(x < y);
double code(double x, double y) {
return x * (x * -2.0);
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (x * (-2.0d0))
end function
assert x < y;
public static double code(double x, double y) {
return x * (x * -2.0);
}
[x, y] = sort([x, y]) def code(x, y): return x * (x * -2.0)
x, y = sort([x, y]) function code(x, y) return Float64(x * Float64(x * -2.0)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x * (x * -2.0);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x * N[(x * -2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
x \cdot \left(x \cdot -2\right)
\end{array}
Initial program 9.2%
Simplified3.1%
Taylor expanded in y around 0
/-lowering-/.f64N/A
associate-*r*N/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
associate-*l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6410.8%
Simplified10.8%
Taylor expanded in x around inf
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6410.8%
Simplified10.8%
herbie shell --seed 2024192
(FPCore (x y)
:name "Rump's expression from Stadtherr's award speech"
:precision binary64
:pre (and (== x 77617.0) (== y 33096.0))
(+ (+ (+ (* 333.75 (pow y 6.0)) (* (* x x) (- (- (- (* (* (* (* 11.0 x) x) y) y) (pow y 6.0)) (* 121.0 (pow y 4.0))) 2.0))) (* 5.5 (pow y 8.0))) (/ x (* 2.0 y))))