The first problem I would solve by determining the polynomial through the
initial points (k points give a pn of degree k) and then calculate the other
points. Elementary math only.


As far as your t is concerned, a more efficient solution is 

   tb=. [: ;@{. [: ([ ((, {.) ; ]) 2 - /\])&>/^:(<:@#@;@{:) ({. ; ])

   tb ^&5[i.6
0 _1 30 _150 240 _120

   t ^&5[i.6
0 _1 30 _150 240 _120

   tb tb ^&5[i.6
0 1 32 243 1024 3125

   etcb=.{.&.:(tb :.tb)

   ts '1000 etc ^&5[i.6'
0.060576443 13902976

   ts '1000 etcb ^&5[i.6'
0.042477318 35200

   dspl rnkng scores '1000 etc ^&5[i.6'; '1000 etcb ^&5[i.6'
+----+------+----+------+
|rank|et*sz |time|size  |
+----+------+----+------+
| 1  |598.25|1.51|394.97|
+----+------+----+------+
| 0  |  1.00|1.00|  1.00|
+----+------+----+------+


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens Bo Jacoby
> Verzonden: donderdag 10 juni 2010 10:54
> Aan: Programming forum
> Onderwerp: [Jprogramming] Polynomial extrapolation
> 
> Hello my friends
> 
> A program for polynomial extrapolation can be written
> 
>    etc=.{.&.:(t :.t=.[: {."1 (2-/\])^:([: i. #))
> 
> For example, the first 21 square numbers are extrapolated from 3 square
> numbers like this.
> 
>    21 etc 0 1 4
> 0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400
> 
> My first question is this: Can the program be written without naming the
> intermediate verb (t) ?
> 
> Note that t is an involution:
>    t t 0 1 4
> 0 1 4
> and the etc program just pads zeroes
>    21 {. t 0 1 4
> 0 _1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> before transforming back.
>    t 21 {. t 0 1 4
> 0 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400
> 
> The transformation (t) creates a space-consuming intermediate matrix
>    (2-/\])^:([: i. #) 1 4 9
>  1  4 9
> _3 _5 0
>  2  0 0
> where only the first row is input and only the first column is output. I
> want to compute in-place to save space:
>    1, 4 9 --> 1 _3, _5 --> 1 _3 2
> My second question: How is that done?
> 
> Venlig hilsen, Bo
> 
> 
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to