import numpy as np
import numpy.linalg as la
import scipy.special as sp
import matplotlib.pyplot as pt
n = 5
nodes = np.linspace(-1, 1, n)
#nodes = sp.legendre(n).weights[:, 0]
pt.plot(nodes, 0*nodes, "o")
[<matplotlib.lines.Line2D at 0x7f6ea415b438>]
exponents = np.arange(n)
exponents
array([0, 1, 2, 3, 4])
exponents[:, np.newaxis]
array([[0], [1], [2], [3], [4]])
vdm = nodes ** exponents[:, np. newaxis]
if n < 5:
print(vdm)
print(la.cond(vdm))
4.30037521416
vdm = np.array([sp.eval_legendre(i, nodes) for i in range(n)]).T
print(la.cond(vdm))
4.30037521416