Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168695
Image: ubuntu2004
#illustration of minimax problem of interpolation #using chebyshev roots from numpy import linspace x = var('x') #Chebyshev roots between -1.0 and 1.0 n = 9 xpoints = [cos(((2.0*i -1)*float(pi))/(2.0*n)) for i in range(1,n+1)] #xpoints = [cos for i in range(xpoints.size) #create an array of the terms for interpolation error polynomial terms = [x- i for i in xpoints] #multiply the terms together and place in a fuction func = prod(terms) p = plot(func) #create tuple of points for which y(x) = 0 pointsAtZero = [[i,0] for i in xpoints] p1 = list_plot(pointsAtZero, rgbcolor = (1,0,0)) (p + p1).show(ymax = .02, ymin = -.02)