[Scipy-tickets] [SciPy] #1488: scipy.interpolate.lagrange issue

SciPy Trac scipy-tickets@scipy....
Sun Aug 7 20:09:40 CDT 2011


#1488: scipy.interpolate.lagrange issue
-------------------------------+--------------------------------------------
 Reporter:  kvnsmth            |       Owner:  somebody   
     Type:  defect             |      Status:  new        
 Priority:  normal             |   Milestone:  Unscheduled
Component:  scipy.interpolate  |     Version:  0.9.0      
 Keywords:                     |  
-------------------------------+--------------------------------------------

Comment(by warren.weckesser):

 The problem is that len(lag) returns the order of the polynomial, not the
 number of coefficients.  (Yes, that's surprising to me, too.)  Change this
 line
 {{{
         for j in xrange(len(lag)):
 }}}
 to this
 {{{
         for j in xrange(len(lag) + 1):
 }}}
 Or, even better replace these lines
 {{{
     yf = np.zeros(101)
     xf = np.linspace(min(x)-1, max(x)+1, 101)
     for i in xrange(len(yf)):
         for j in xrange(len(lag)):
             yf[i] += xf[i]**(j) * lag[j]
 }}}
 with this:
 {{{
     xf = np.linspace(min(x)-1, max(x)+1, 101)
     yf = lag(xf)
 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1488#comment:1>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list