Exemple #1
0
def unifvscheb(n):
	"""\
	unifvscheb(n):
	graphs the function (x-x0)...(x-x_{n-1}) for unif and cheb
	point in [0,1].
	n must be even.
	functions nmlzed to be 1 at 0.
	"""
	import gridpts as gr
	import numpy as np
	from matplotlib import pyplot as plt
	
	assert n%2 == 0
        x = gr.unif(n)
        xx = np.linspace(-1,1,200)*0.99+1e-6
        yy = gr.evalprod(x, xx)
        
        zero = np.array([0]) #nmlz
        yy = yy/gr.evalprod(x, zero)

        plt.subplot(211) 
        plt.plot(xx, yy)
        plt.title('nmlz prod poly with ' + str(n) + ' unif points')
        
        x = gr.cheb(n)
        yy = gr.evalprod(x, xx)
        
        yy = yy/gr.evalprod(x, zero) #nmlz

        
        plt.subplot(212) 
        plt.plot(xx, yy)
        plt.title('nmlz prod poly with ' + str(n) + ' cheb points')
Exemple #2
0
import numpy as np
from matplotlib import pyplot as plt

import sys, os

sys.path.append(os.getcwd() + "/..")

import gridpts
import lgrng

x = gridpts.cheb(20)
y = np.sin(np.sin(x))
plt.plot(x, y, "ro")

xx = gridpts.unif(200)
xx = xx * 0.999 + 1e-6
yy = lgrng.interp(x, y, xx)
plt.plot(xx, yy, "k")
plt.axis("tight")
plt.show()