If one wants a polynomial solution to a series there is always matrix
divide.
p=.3 : '(>:0 i:~0=r){.r=.y%.(i.x:#y)^/i.x:#y'
p 0 1 8 27 64 125 216 343 512 729 1000
0 0 0 1
On Fri, Aug 21, 2009 at 7:37 AM, Bo Jacoby <[email protected]> wrote:
> How to use involutoric newtontransform to extrapolate a list of numbers.
>
> ]data =. 3 ^~ i. 4 NB. test data
> 0 1 8 27
> T data NB. transform once
> 0 _1 6 _6
> T T data NB. transform twice, reproducing data
> 0 1 8 27
> T NB. transform using only '-', neither '*' nor '%' nor even '+'.
> 3 : 0
> a =. 0 $ 0
> while. # y do.
> a =. a , {. y
> y =. ( }: - }. ) y
> end.
> a
> )
> etc NB. extend transform with zeroes and transform back.
> [: T [ {. [: T ]
> 11 etc data
> 0 1 8 27 64 125 216 343 512 729 1000
>
> - Bo
>
> --- Den fre 21/8/09 skrev Kip Murray <[email protected]>:
>
> > Fra: Kip Murray <[email protected]>
> > Emne: Re: [Jprogramming] A better conjunction
> > Til: "Programming forum" <[email protected]>
> > Dato: fredag 21. august 2009 14.41
> > And, of course,
> >
> > diff =: 2&(-~/\) NB. differences of a vector
> >
> > (For the notes at the end)
> >
> > Kip Murray wrote:
> > > 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
> >
>
>
> Find din nye laptop på kelkoo.dk. Se de gode tilbud her -
> http://dk.yahoo.com/r/pat/mm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm