[SciPy-dev] scipy.interpolate.fitpack patch

Nils Wagner nwagner@iam.uni-stuttgart...
Thu Feb 8 05:44:18 CST 2007


John Travers wrote:
> On 07/02/07, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
>   
>> John Travers wrote:
>>     
>>> Hi all,
>>>
>>> Bugs are very welcome!
>>>
>>>       
> ...
>   
>> Arrays are not almost equal
>>
>> (shapes (4,), (5,) mismatch)
>>  x: array([  3.14181593,   6.28332425,   9.42469672,  12.56632768])
>>  y: array([  0.        ,   3.14159265,   6.28318531,   9.42477796,
>> 12.56637061])
>>     
>
> Hi Nils,
> This seems strange to me. It is not finding the first root.Can you run
>
> /usr/lib64/python2.4/site-packages/scipy/interpolate/fitpack.py 3
>
> and
>
> /usr/lib64/python2.4/site-packages/scipy/sandbox/spline/fitpack.py 3
>
> and post the output please.
>
> Thanks!
> John
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>   
Sure.
python -i /usr/lib64/python2.4/site-packages/scipy/sandbox/spline/fitpack.py
******************************************
        Tests of splrep and splev
******************************************

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=9.9999999999999995e-07 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  8.1e-04 7.3e-02
 2 :  2.3e-05 3.3e-04 2.3e-01
 3 :  7.1e-07 4.4e-05 2.4e-03 2.9e-01
 4 :  9.2e-07 1.1e-04 6.3e-03 1.3e-01 1.4e+00
 5 :  8.8e-07 6.9e-05 3.5e-03 7.0e-02 6.0e-01 2.4e+00

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  7.8e-04 7.3e-02
 2 :  1.5e-07 9.3e-04 1.6e-01
 3 :  2.3e-09 3.7e-06 4.3e-04 7.5e-02
 4 :  4.7e-11 1.4e-06 2.8e-04 1.5e-02 4.4e-01
 5 :  7.5e-13 2.8e-08 6.1e-06 3.9e-04 1.0e-02 1.7e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 Evaluation at knots
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  0.0e+00 2.5e-01
 2 :  1.9e-07 1.9e-03 3.6e-01
 3 :  2.0e-31 5.6e-06 1.4e-03 2.6e-01
 4 :  6.9e-11 2.7e-06 5.4e-04 3.0e-02 7.1e-01
 5 :  5.0e-31 5.4e-08 1.2e-05 7.7e-04 1.8e-02 3.5e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=1 s=0 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  7.8e-04 7.3e-02
 2 :  1.5e-07 9.3e-04 1.6e-01
 3 :  2.3e-09 3.7e-06 4.3e-04 7.5e-02
 4 :  4.7e-11 1.4e-06 2.8e-04 1.5e-02 4.4e-01
 5 :  7.5e-13 2.8e-08 6.1e-06 3.9e-04 1.0e-02 1.7e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=1 s=0 Evaluation at knots
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  0.0e+00 2.5e-01
 2 :  1.9e-07 1.9e-03 3.6e-01
 3 :  2.0e-31 5.6e-06 1.4e-03 2.6e-01
 4 :  6.9e-11 2.7e-06 5.4e-04 3.0e-02 7.1e-01
 5 :  5.0e-31 5.4e-08 1.2e-05 7.7e-04 1.8e-02 3.5e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 4.7119999999999997] > [0.0,
4.7119999999999997]
 per=0 s=0 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  2.4e-04 5.1e-02
 2 :  5.9e-08 5.8e-05 4.6e-02
 3 :  3.2e-10 5.6e-06 1.5e-03 1.2e-01
 4 :  1.8e-12 2.3e-08 6.2e-06 4.7e-04 8.3e-02
 5 :  3.7e-14 4.6e-09 1.9e-06 2.4e-04 1.3e-02 3.3e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
4.7119999999999997]
 per=1 s=0.10000000000000001 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  8.0e-02 1.4e+00
 2 :  9.4e-02 1.1e+00 4.8e+00
 3 :  6.4e-02 5.7e-01 3.8e+00 9.2e+00
 4 :  4.7e-03 1.2e-01 1.6e+00 7.4e+00 1.2e+01
 5 :  1.9e-04 4.3e-03 1.0e-01 1.1e+00 4.9e+00 9.9e+00
******************************************
        Tests of splint and spalde
******************************************

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 N=20 [a, b] = [0.0, 6.2830000000000004]  dx=0.628
 k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
 1    0.00000000   7.3e-17  0.0e+00  1.3e-01
 2    0.00000000   3.1e-17  2.2e-16  3.1e-03  1.7e-02
 3   -0.00000000   3.8e-18  2.2e-16  9.8e-05  1.1e-02  1.3e-01
 4    0.00000000   6.7e-16  2.2e-16  1.2e-04  8.9e-04  1.1e-02  1.3e-01
 5    0.00000000   1.1e-16  0.0e+00  1.4e-05  9.5e-05  1.1e-03  1.5e-02 
4.6e-02

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=1 s=0 N=20 [a, b] = [0.0, 6.2830000000000004]  dx=0.628
 k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
 1    0.00000000   7.3e-17  0.0e+00  1.3e-01
 2    0.00000000   3.1e-17  2.2e-16  3.1e-03  1.7e-02
 3   -0.00000000   3.8e-18  2.2e-16  9.8e-05  1.1e-02  1.3e-01
 4    0.00000000   6.7e-16  2.2e-16  1.2e-04  8.9e-04  1.1e-02  1.3e-01
 5    0.00000000   1.1e-16  0.0e+00  1.4e-05  9.5e-05  1.1e-03  1.5e-02 
4.6e-02

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 N=20 [a, b] = [0.628, 3.1419999999999999]  dx=0.628
 k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
 1    1.79411389   1.5e-02  0.0e+00  1.3e-01
 2    1.80893734   8.0e-05  2.2e-16  3.1e-03  1.7e-02
 3    1.80899266   2.4e-05  2.2e-16  9.8e-05  1.1e-02  1.3e-01
 4    1.80901586   1.1e-06  2.2e-16  1.2e-04  8.9e-04  1.1e-02  1.3e-01
 5    1.80901683   1.6e-07  0.0e+00  1.4e-05  9.5e-05  1.1e-03  1.5e-02 
4.6e-02

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 N=50 [a, b] = [0.628, 3.1419999999999999]  dx=0.628
 k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
 1    1.80663580   2.4e-03  0.0e+00  4.8e-02
 2    1.80901480   2.2e-06  2.2e-16  6.6e-04  6.3e-04
 3    1.80901636   6.3e-07  0.0e+00  1.5e-06  1.3e-03  4.7e-02
 4    1.80901699   1.2e-09  0.0e+00  1.6e-07  4.0e-06  6.0e-04  3.4e-03
 5    1.80901699   2.3e-10  0.0e+00  3.9e-09  4.4e-07  1.3e-06  1.4e-03 
4.8e-02
******************************************
        Tests of sproot
******************************************
  k  :     Roots of s(x) approx sin(x)  x in [0.0,15.0]:
  3  : [3.1418159268145143, 6.283324249558861, 9.4246967197029239,
12.566327676063914]
Note that if k is not 3, some roots are missed or incorrect
******************************************
        Tests of splprep, splrep, and splev
******************************************
 u = 0.628   N = 20
  k  :  [x(u), sin(x(u))]  Error of splprep  Error of splrep
  1  :  [3.867, -0.65600000000000003]    7.3e-03           7.3e-03
  2  :  [3.863, -0.66100000000000003]    2.4e-04           2.2e-04
  3  :  [3.863, -0.66100000000000003]    5.4e-05           1.4e-05
  4  :  [3.863, -0.66100000000000003]    7.9e-06           5.8e-07
  5  :  [3.863, -0.66100000000000003]    2.1e-05           2.8e-08
Derivatives of parametric cubic spline at u (first function):
 6.10627991049  11.9027895435  116.204926832
 u = 0.628   N = 50
  k  :  [x(u), sin(x(u))]  Error of splprep  Error of splrep
  1  :  [3.8650000000000002, -0.66100000000000003]    9.5e-04          
9.5e-04
  2  :  [3.8639999999999999, -0.66100000000000003]    2.3e-05          
1.1e-05
  3  :  [3.8639999999999999, -0.66100000000000003]    8.2e-07          
2.2e-07
  4  :  [3.8639999999999999, -0.66100000000000003]    1.5e-08          
4.4e-09
  5  :  [3.8639999999999999, -0.66100000000000003]    1.8e-09          
7.7e-11
Derivatives of parametric cubic spline at u (first function):
 6.11128630809  11.8744428128  111.000018594
******************************************
        Tests of bisplrep, bisplev
******************************************
5.77570681504e-06

----------------------------------------------------------------------------------------------------------------------------



python -i /usr/lib64/python2.4/site-packages/scipy/interpolate/fitpack.py
******************************************
        Tests of splrep and splev
******************************************

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=9.9999999999999995e-07 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  8.1e-04 7.3e-02
 2 :  2.3e-05 3.3e-04 2.3e-01
 3 :  7.1e-07 4.4e-05 2.4e-03 2.9e-01
 4 :  9.2e-07 1.1e-04 6.3e-03 1.3e-01 1.4e+00
 5 :  8.8e-07 6.9e-05 3.5e-03 7.0e-02 6.0e-01 2.4e+00

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  7.8e-04 7.3e-02
 2 :  1.5e-07 9.3e-04 1.6e-01
 3 :  2.3e-09 3.7e-06 4.3e-04 7.5e-02
 4 :  4.7e-11 1.4e-06 2.8e-04 1.5e-02 4.4e-01
 5 :  7.5e-13 2.8e-08 6.1e-06 3.9e-04 1.0e-02 1.7e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 Evaluation at knots
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  0.0e+00 2.5e-01
 2 :  1.9e-07 1.9e-03 3.6e-01
 3 :  2.0e-31 5.6e-06 1.4e-03 2.6e-01
 4 :  6.9e-11 2.7e-06 5.4e-04 3.0e-02 7.1e-01
 5 :  5.0e-31 5.4e-08 1.2e-05 7.7e-04 1.8e-02 3.5e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=1 s=0 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  7.8e-04 7.3e-02
 2 :  1.5e-07 9.3e-04 1.6e-01
 3 :  2.2e-09 5.2e-07 4.4e-05 7.0e-02
 4 :  4.1e-12 2.4e-08 6.3e-07 7.6e-04 1.6e-01
 5 :  1.2e-14 3.7e-12 2.5e-10 5.1e-07 4.3e-05 7.0e-02

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=1 s=0 Evaluation at knots
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  6.3e-32 2.5e-01
 2 :  2.0e-06 1.9e-03 3.7e-01
 3 :  8.1e-31 3.3e-08 6.8e-04 2.5e-01
 4 :  1.4e-10 3.1e-08 1.3e-06 1.7e-03 3.6e-01
 5 :  5.9e-31 4.2e-13 1.9e-09 1.8e-08 6.8e-04 2.5e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 4.7119999999999997] > [0.0,
4.7119999999999997]
 per=0 s=0 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  2.4e-04 5.1e-02
 2 :  5.9e-08 5.8e-05 4.6e-02
 3 :  3.2e-10 5.6e-06 1.5e-03 1.2e-01
 4 :  1.8e-12 2.3e-08 6.2e-06 4.7e-04 8.3e-02
 5 :  3.7e-14 4.6e-09 1.9e-06 2.4e-04 1.3e-02 3.3e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
4.7119999999999997]
 per=1 s=0.10000000000000001 Evaluation at the middle of nodes
 k :  |f-s|^2  |f'-s'| |f''-.. |f'''-. |f''''- |f'''''
 1 :  9.8e-01 1.0e+01
 2 :  7.2e-01 1.3e+01 2.5e+02
 3 :  7.2e-01 9.3e+00 1.5e+02 5.9e+03
 4 :  7.1e-01 1.2e+01 1.1e+02 8.9e+03 1.5e+05
 5 :  6.8e-01 1.0e+01 1.0e+02 2.5e+03 2.8e+05 1.5e+07
******************************************
        Tests of splint and spalde
******************************************

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 N=20 [a, b] = [0.0, 6.2830000000000004]  dx=0.628
 k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
 1    0.00000000   7.3e-17  0.0e+00  1.3e-01
 2    0.00000000   3.1e-17  2.2e-16  3.1e-03  1.7e-02
 3   -0.00000000   3.8e-18  2.2e-16  9.8e-05  1.1e-02  1.3e-01
 4    0.00000000   6.7e-16  2.2e-16  1.2e-04  8.9e-04  1.1e-02  1.3e-01
 5    0.00000000   1.1e-16  0.0e+00  1.4e-05  9.5e-05  1.1e-03  1.5e-02 
4.6e-02

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=1 s=0 N=20 [a, b] = [0.0, 6.2830000000000004]  dx=0.628
 k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
 1    0.00000000   1.1e-16  0.0e+00  1.3e-01
 2   -0.00000000   4.3e-16  2.2e-16  3.1e-03  1.7e-02
 3   -0.00000000   2.9e-16  4.4e-16  5.5e-05  8.3e-03  1.2e-01
 4   -0.00000000   4.5e-16  4.4e-16  1.6e-05  2.7e-04  2.3e-03  3.9e-02
 5   -0.00000000   1.1e-16  0.0e+00  2.0e-07  1.4e-05  4.1e-05  8.3e-03 
1.2e-01

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 N=20 [a, b] = [0.628, 3.1419999999999999]  dx=0.628
 k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
 1    1.79411389   1.5e-02  0.0e+00  1.3e-01
 2    1.80893734   8.0e-05  2.2e-16  3.1e-03  1.7e-02
 3    1.80899266   2.4e-05  2.2e-16  9.8e-05  1.1e-02  1.3e-01
 4    1.80901586   1.1e-06  2.2e-16  1.2e-04  8.9e-04  1.1e-02  1.3e-01
 5    1.80901683   1.6e-07  0.0e+00  1.4e-05  9.5e-05  1.1e-03  1.5e-02 
4.6e-02

f = sin(x)  s=S_k(x;t,c)  x in [0.0, 6.2830000000000004] > [0.0,
6.2830000000000004]
 per=0 s=0 N=50 [a, b] = [0.628, 3.1419999999999999]  dx=0.628
 k :  int(s,[a,b]) Int.Error   Rel. error of s^(d)(dx) d = 0, .., k
 1    1.80663580   2.4e-03  0.0e+00  4.8e-02
 2    1.80901480   2.2e-06  2.2e-16  6.6e-04  6.3e-04
 3    1.80901636   6.3e-07  0.0e+00  1.5e-06  1.3e-03  4.7e-02
 4    1.80901699   1.2e-09  0.0e+00  1.6e-07  4.0e-06  6.0e-04  3.4e-03
 5    1.80901699   2.3e-10  0.0e+00  3.9e-09  4.4e-07  1.3e-06  1.4e-03 
4.8e-02
******************************************
        Tests of sproot
******************************************
  k  :     Roots of s(x) approx sin(x)  x in [0.0,15.0]:
  1  : [3.8917895437452752, 7.0333244206998957, 10.174697656280109,
13.316162856466082]
  2  : [3.5167921082175266, 6.6583244127250936, 9.7996976309412744,
12.948449169566704]
  3  : [3.1418159268145143, 6.283324249558861, 9.4246967197029239,
12.566327676063914]
  4  : [3.5377683941038813, 6.6583251439401883, 9.7996965906036593,
12.991740973097126]
  5  : [6.1161081418555904e-18, 4.0693671011759172, 7.0333276059930698,
10.174703377002832, 13.532636947291909]
Note that if k is not 3, some roots are missed or incorrect
******************************************
        Tests of splprep, splrep, and splev
******************************************
 u = 0.628   N = 20
  k  :  [x(u), sin(x(u))]  Error of splprep  Error of splrep
  1  :  [3.867, -0.65600000000000003]    7.3e-03           7.3e-03
  2  :  [3.863, -0.66100000000000003]    2.4e-04           2.2e-04
  3  :  [3.863, -0.66100000000000003]    5.4e-05           1.4e-05
  4  :  [3.863, -0.66100000000000003]    7.9e-06           5.8e-07
  5  :  [3.863, -0.66100000000000003]    2.1e-05           2.8e-08
Derivatives of parametric cubic spline at u (first function):
 6.10627991049  11.9027895435  116.204926832
 u = 0.628   N = 50
  k  :  [x(u), sin(x(u))]  Error of splprep  Error of splrep
  1  :  [3.8650000000000002, -0.66100000000000003]    9.5e-04          
9.5e-04
  2  :  [3.8639999999999999, -0.66100000000000003]    2.3e-05          
1.1e-05
  3  :  [3.8639999999999999, -0.66100000000000003]    8.2e-07          
2.2e-07
  4  :  [3.8639999999999999, -0.66100000000000003]    1.5e-08          
4.4e-09
  5  :  [3.8639999999999999, -0.66100000000000003]    1.8e-09          
7.7e-11
Derivatives of parametric cubic spline at u (first function):
 6.11128630809  11.8744428128  111.000018594
******************************************
        Tests of bisplrep, bisplev
******************************************
5.77570681504e-06


Nils



More information about the Scipy-dev mailing list