I wrote a small script to find the Gaussian integral points and weights:
FindInstance[{Table[x[i]^j, {j, 0, 2 # + 1}, {i, 0, #}].Table[
w[i], {i, 0, #}] ==
Table[Integrate[x^i, {x, -1, 1}], {i, 0, 2 # + 1}],
Less @@ Table[x[i], {i, 0, #}]} ,
Flatten[{Table[x[i], {i, 0, #}], Table[w[i], {i, 0, #}]}]] &[n]
For $n$ is small the script is working:
n=1
{{x[0] -> -(1/Sqrt[3]), x[1] -> 1/Sqrt[3], w[0] -> 1, w[1] -> 1}}
n=2
{{x[0] -> -Sqrt[(3/5)], x[1] -> 0, x[2] -> Sqrt[3/5], w[0] -> 5/9,
w[1] -> 8/9, w[2] -> 5/9}}
but for $n\ge5$, the script is extremely slow.
Is it possible to speed up the script? If not, is it possible if I only want numerical results?
GaussianQuadratureWeights
in the document. $\endgroup$LegendreP[]
is built-in? $\endgroup$