我在 MAPLE 中写了一个简单的 Legendre 求积来计算积分
restart; with(orthopoly): with(LinearAlgebra):
legendre_quad := proc (n, digits)
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
,这样
(weights, location) := legendre_quad(10, 50);
int := DotProduct(location^~2, weights)
,这导致0.666666635631640303。但这只能精确到 7 位数,甚至翻倍digits
我怎样才能提高这个正交的准确性?