How to increase precision of Gauss-Legendre Quadrature in MAPLE? [closed]

I've written a simple legendre quadrature in MAPLE to compute the integral

$\int_{-1}^1 r^2 dr = \frac{r^3}{3} |_{-1}^1=\frac{2}{3}$

restart; with(orthopoly): with(LinearAlgebra):
local i, s, w, location;
w := Vector(n, fill = 0);
location := Vector(sort([evalf[digits](solve(P(n, x) = 0, x))], <));
for i to n do
w[i] := eval[digits](2/((1-location[i]^2)*(diff(P(n, x), x))^2), [x = location[i]])
end do;
s := (w, location)
end proc

,such that

• Since Legendre-Gauss quadrature of order 10 would be exact for $x^2$, it's not truncation error, and since doubling the number of digits doesn't increase accuracy, it's not roundoff error. I can't replicate your results with Mathematica either. So it's likely a programming error, although I don't see it in your code. I don't have Maple, but are you absolutely sure that evalf[digits] and eval[digits] (what's the difference?) both produce sufficiently accurate results? Because the default precision seems to be 10 digits, which would be consistent with getting 7 accurate digits. Dec 23 '16 at 21:12