Programming Problems 
Author Message
 Programming Problems


Ken Iverson writes on Saturday, March 23:

Quote:
> The Bureau of Standards Handbook of Mathematical Functions (edited by
> Abramowitz and Stegun) provides a host of expressions that are easy to
> state, of practical use, and interesting to program. I would suggest it as a
> source of problems for discussions of APL programming.
> For example, Article 3.6.8 (on page 14 in my edition) states that (1+x) to
> the power a can be expressed as the sum of a series using the binomial
> coefficients. Moreover, the binomial coefficients are expressed (in 3.6.9)
> as quotients with numerators given by the falling factorial function 1, a,
> a(a-1), a(a-1)(a-2) ... and with denominators given by the factorials. This
> is the form that was used in one or more of the recent messages on the
> binomial coefficients.
> However, the Handbook continues (3.6.10-14) with the infinite series
> obtained for negative and fractional values of the exponent a, showing the
> first few values of the numerators and denominators (expressed in lowest
> terms). For example, 3.6.12 (with a set to minus one-half) gives the
> numerators as 1 _1 3 _5 35 _63 and the denominators as powers of 2.
> I would invite APL programs for generating these results for the cases
> treated in the Handbook (a set to _1, 1r2, _1r2, 1r3, _1r3). I would
> particularly like to see a solution in MATLAB; in spite of the recent flurry
> of interest in it, no sample program has appeared.

The k-th coefficient of the power series for (1+x)^a is the ratio  
(*/a - i.k) % !k where k>0.  If a is the rational number p%q,
the ratio becomes (*/p - q*i.k) % q*!k.  Therefore:






coeff=: num (,: %"1 +.) den

   10 coeff 1 2
1 1 _1  1  _5   7  _21   33  _429   715
1 2  8 16 128 256 1024 2048 32768 65536

   10 num 1 2
1 1 _1 3 _15 105 _945 10395 _135135 2027025
   10 den 1 2
1 2 8 48 384 3840 46080 645120 1.03219e7 1.85795e8

   [ d=. (10 num 1 2) +. 10 den 1 2   NB. GCD
1 1 1 3 3 15 45 315 315 2835

   (10 num 1 2) % d
1 1 _1 1 _5 7 _21 33 _429 715
   (10 den 1 2) % d
1 2 8 16 128 256 1024 2048 32768 65536

   ((10 num 1 2),:10 den 1 2) %"1 d
1 1 _1  1  _5   7  _21   33  _429   715
1 2  8 16 128 256 1024 2048 32768 65536

   NB. Abramowitz & Stegun 3.6.10 to 3.6.14

   10 coeff"0 1 > _1 1; 1 2; _1 2; 1 3; _1 3
1 _1  1  _1   1  _1    1    _1     1        _1
1  1  1   1   1   1    1     1     1         1

1  1 _1   1  _5   7  _21    33  _429       715
1  2  8  16 128 256 1024  2048 32768     65536

1 _1  3  _5  35 _63  231  _429  6435    _12155
1  2  8  16 128 256 1024  2048 32768     65536

1  1 _1   5 _10  22 _154   374  _935     21505
1  3  9  81 243 729 6561 19683 59049 1.59432e6

1 _1  2 _14  35 _91  728 _1976  5434   _135850
1  3  9  81 243 729 6561 19683 59049 1.59432e6



Mon, 14 Sep 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Fun APL/J Programming Problem

2. Interesting Programming Problem, Need Some Help

3. MVS memory programming problem

4. MVS memory programming problem

5. more APL/J programming problems

6. Programming Problems

7. Please help with PL/I programming problem

8. Creating Conversion Program - Problems (C5EE)

9. Dict File Conversion Program Problem

10. Terminal server-C55 programs problem

11. Install program problems

12. Clipper dbase program problems with WIN2K

 

 
Powered by phpBB® Forum Software