In  (long sentence here, watch for the period)

       ]data =: 3 ^~ i. 11
0 1 8 27 64 125 216 343 512 729 1000

    p =: 3 interp data

    p   NB. conjunction interp embedded
(3) (2 : '(y !~ i. >: m) +/ . * {. (>: m) difftb n') 0 1 8 27 64 125 216 343 
512 
729 1000

the conjunction interp is supposed to look at the difference table

    4 difftb data   NB. successive differences of first column, see note [1]
  0  1  6 6
  1  7 12 0
  8 19  0 0
27  0  0 0

and, reading the first line, produce the equivalent of

    q =: 0 1 6 6 +/ . * (i.4) ! ]   NB. A Newton series, see note [2]
.

Conjunction interp _does_ produce an equivalent:

    (p"0 ,: q"0) i. 11
0 1 8 27 64 125 216 343 512 729 1000
0 1 8 27 64 125 216 343 512 729 1000

But I don't want p to recreate the difference table every time it is called.  
Is 
there a way to rewrite conjunction interp so that

    q =: 3 interp1 data

    q
0 1 6 6 +/ .* 0 1 2 3 ! ]

?

Kip

----------


[1] x difftb y is an x by x table whose kth column has
     kth differences for vector x {. y  (y is a vector and x <: #y)

    difftb =: 4 : '|: diff^:(i.x) x {. y'


[2] In algebra notation q is the third degree Newton series

     q(x) = 0 + 1 x/1  + 6 (x*(x-1))/(1*2) + 6 (x*(x-1)*(x-2))/(1*2*3)

     This one simplifies to q(x) = x^3 .

For Newton series, see pages 190-191 of Graham, Knuth, and Patashnik, Concrete 
Mathematics Second Edition.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to