test_deriv.php deriv, rderiv, nuderiv

// deriv.php includes deriv, rderiv, nuderiv  require_once 'deriv.php';
//          order is order of derivative, 1 = first derivative, 2 = second 
//          points is number of points where value of function is known    
//          f(x0), f(x1), f(x2) ... f(x points-1)                          
//          point is the term where derivative is computed                 
//          f'(x0) = (1/bh^order)*( a(0)*f(x0) + a(1)*f(x1)                
//                   + ... + a(points-1)*f(x points-1)                     
//          uniformly spaced points x1=x0+h, x2=x1+h=x1+2*h, ...           
//                                                                         
//          rderiv returns c[0]=(1/bh^order)*a[0]  ...                     
//                                                                         
//          nuderiv works for non-uniformly spaced points                  
//                                                                         
// algorithm: use divided differences to get polynomial p(x) that          
//            approximates  f(x).  f(x)=p(x)+error term                    
//            f'(x) = p'(x) + error term'                                  
//            substitute xj = x0 + j*h                                     
//            substitute x = x0 to get  p'(x0) etc                         
test_deriv.php running 
gcd(6,9)=3
gcd(9,6)=3
gcd(8,2)=2
gcd(2,8)=2
deriv(2, 3, 1)
array(4) { [0]=> int(1) [1]=> int(-2) [2]=> int(1) [3]=> int(1) } b=1
a[0]=1
a[1]=-2
a[2]=1
deriv(4, 5, 2)
array(6) { [0]=> int(1) [1]=> int(-4) [2]=> int(6) [3]=> int(-4) [4]=> int(1) [5]=> int(1) } b=1
a[0]=1
a[1]=-4
a[2]=6
a[3]=-4
a[4]=1
rderiv(4, 5, 2, 0.1)
c[0]=10000
c[1]=-40000
c[2]=60000
c[3]=-40000
c[4]=10000

nuderiv(4,5,2,a)
c[0]=10000
c[1]=-40000.000000001
c[2]=60000.000000001
c[3]=-40000.000000001
c[4]=10000

rderiv(2,8,4,0.1)
c[0]=0
c[1]=1.1111111111111
c[2]=-15
c[3]=150
c[4]=-272.22222222222
c[5]=150
c[6]=-15
c[7]=1.1111111111111

nuderiv(2,8,4,a)
c[0]=9.9134922493249E-11
c[1]=1.1111111104474
c[2]=-14.999999998166
c[3]=149.99999999735
c[4]=-272.22222221969
c[5]=149.99999999873
c[6]=-14.999999999589
c[7]=1.1111111110586

nuderiv(2,10,4,a)
c[0]=-0.14464314622575
c[1]=2.057146969782
c[2]=-16.200032393965
c[3]=129.60025918762
c[4]=-230.62546123317
c[5]=129.60025918383
c[6]=-16.20003239013
c[7]=2.0571469673796
c[8]=-0.14464314548331
c[9]=-1.0101075531566E-10