# coding: utf-8 # # Vandermonde Conditioning # In[20]: import numpy as np import numpy.linalg as la import scipy.special as sp import matplotlib.pyplot as pt # In[21]: n = 5 nodes = np.linspace(-1, 1, n) #nodes = sp.legendre(n).weights[:, 0] pt.plot(nodes, 0*nodes, "o") #### Monomials # In[22]: exponents = np.arange(n) exponents # In[23]: exponents[:, np.newaxis] # In[24]: vdm = nodes ** exponents[:, np. newaxis] if n < 5: print(vdm) # In[29]: print(la.cond(vdm)) #### Legendre polynomials # In[30]: vdm = np.array([sp.eval_legendre(i, nodes) for i in range(n)]).T print(la.cond(vdm))