# Copyright (C) 2020 Andreas Kloeckner # #

# ## MIT License

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

# In[1]:
import numpy as np
import numpy.linalg as la
import matplotlib.pyplot as pt
# In[3]:
x = np.linspace(0, 1, 200)
# Now plot the monomial basis on the interval [0,1] up to $x^9$.
# In[4]:
n = 10
for i in range(n):
pt.plot(x, x**i)
pt.vlines(np.linspace(0, 1, n), 0, 1, alpha=0.5, linestyle="--")
# * How do the entries of the Vandermonde matrix relate to this plot?
# ------------------
# * Guess the condition number of the Vandermonde matrix for $n=5,10,20$:
# In[5]:
n = 5
V = np.array([np.linspace(0, 1, n)**i for i in range(n)]).T
la.cond(V)
# In[ ]: