$SPAD/src/input psgenfcn.input

Clifton J. Williamson and Timothy Daly

December 3, 2016

Abstract

Contents

2

1 License

— license —

--Copyright The Numerical Algorithms Group Limited 1991.

———-

— * —

)set break resume
)spool psgenfcn.output
)set message test on
)set message auto off
)clear all

———-

2 Power Series Generating Functions

We obtain Fibonacci numbers, Bernoulli numbers and polynomials, and Euler numbers and polynomials as power series coefficients

We will compute power series in two different ways, then test equality of coefficients up to a specified order. The function that tests ’approximate equality’ will return an error message if the test fails.

— * —

--S 1 of 19
ORD := 20
--R
--R
--R   (1)  20
--R                                                        Type: PositiveInteger
--E 1
--S 2 of 19
approximateEquality(series1,series2) ==
  -- tests that 2 series are equal to order ORD
  uts1 := series1 :: UTS(EXPR INT,'t,0)
  uts2 := series2 :: UTS(EXPR INT,'t,0)
  flag := (order(uts1 - uts2,ORD) = ORD) :: Boolean
  flag => true
  error "series do not agree to specified order"
--R
--R                                                                   Type: Void
--E 2
--S 3 of 19

bernoulliPolynomial(n) ==
  -- returns the nth Bernoulli polynomial as an EXPR INT
  sup := bernoulli(n)$(PNTHEORY)
  p : POLY FRAC INT := multivariate(sup,'x)
  p :: (EXPR INT)
--R
--R                                                                   Type: Void
--E 3
--S 4 of 19
eulerPolynomial(n) ==
  -- returns the nth Euler polynomial as an EXPR INT
  sup := euler(n)$(PNTHEORY)
  p : POLY FRAC INT := multivariate(sup,'x)
  p :: (EXPR INT)
--R
--R                                                                   Type: Void
--E 4
--S 5 of 19
f1 := taylor(t/(1 - t - t**2))
--R
--R
--R             2     3     4     5     6      7      8      9      10      11
--R   (5)  t + t  + 2t  + 3t  + 5t  + 8t  + 13t  + 21t  + 34t  + 55t   + O(t  )
--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 5
--S 6 of 19
f2 := taylor(n +-> fibonacci(n),t = 0)
--R
--R
--R             2     3     4     5     6      7      8      9      10      11
--R   (6)  t + t  + 2t  + 3t  + 5t  + 8t  + 13t  + 21t  + 34t  + 55t   + O(t  )
--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 6
--S 7 of 19
approximateEquality(f1,f2)
--R
--R   Compiling function approximateEquality with type (Any,Any) ->
--R      Boolean
--R
--R   (7)  true
--R                                                                Type: Boolean
--E 7
--S 8 of 19
g1 := taylor(t/(exp(t) - 1))
--R

--R
--R   (8)
--R       1      1  2    1   4     1    6      1     8       1     10      11
--R   1 - - t + -- t  - --- t  + ----- t  - ------- t  + -------- t   + O(t  )
--R       2     12      720      30240      1209600      47900160
--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 8
--S 9 of 19
g2 := taylor(n +-> bernoulli(n)/factorial(n),t = 0)
--R
--R
--R   (9)
--R       1      1  2    1   4     1    6      1     8       1     10      11
--R   1 - - t + -- t  - --- t  + ----- t  - ------- t  + -------- t   + O(t  )
--R       2     12      720      30240      1209600      47900160
--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 9
--S 10 of 19
approximateEquality(g1,g2)
--R
--R
--R   (10)  true
--R                                                                Type: Boolean
--E 10
--S 11 of 19
gg1 := taylor(t*exp(t*x)/(exp(t) - 1),t = 0)
--R
--R
--R   (11)
--R                      2                 3     2
--R         2x - 1     6x  - 6x + 1  2   2x  - 3x  + x  3
--R     1 + ------ t + ------------ t  + ------------- t
--R            2            12                 12
--R   +
--R        4      3      2            5      4      3
--R     30x  - 60x  + 30x  - 1  4   6x  - 15x  + 10x  - x  5
--R     ---------------------- t  + --------------------- t
--R               720                        720
--R   +
--R        6       5       4      2            7      6      5     3
--R     42x  - 126x  + 105x  - 21x  + 1  6   6x  - 21x  + 21x  - 7x  + x  7
--R     ------------------------------- t  + --------------------------- t
--R                  30240                              30240
--R   +
--R        8       7       6      4      2
--R     30x  - 120x  + 140x  - 70x  + 20x  - 1  8
--R     -------------------------------------- t

--R                     1209600
--R   +
--R        9      8      7      5      3
--R     10x  - 45x  + 60x  - 42x  + 20x  - 3x  9
--R     ------------------------------------- t
--R                    3628800
--R   +
--R        10       9       8       6       4      2
--R     66x   - 330x  + 495x  - 462x  + 330x  - 99x  + 5  10      11
--R     ------------------------------------------------ t   + O(t  )
--R                         239500800
--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 11
--S 12 of 19
gg2 := taylor(n +-> bernoulliPolynomial(n)/factorial(n),t = 0)
--R
--R   Compiling function bernoulliPolynomial with type Integer ->
--R      Expression(Integer)
--R
--R   (12)
--R                      2                 3     2
--R         2x - 1     6x  - 6x + 1  2   2x  - 3x  + x  3
--R     1 + ------ t + ------------ t  + ------------- t
--R            2            12                 12
--R   +
--R        4      3      2            5      4      3
--R     30x  - 60x  + 30x  - 1  4   6x  - 15x  + 10x  - x  5
--R     ---------------------- t  + --------------------- t
--R               720                        720
--R   +
--R        6       5       4      2            7      6      5     3
--R     42x  - 126x  + 105x  - 21x  + 1  6   6x  - 21x  + 21x  - 7x  + x  7
--R     ------------------------------- t  + --------------------------- t
--R                  30240                              30240
--R   +
--R        8       7       6      4      2
--R     30x  - 120x  + 140x  - 70x  + 20x  - 1  8
--R     -------------------------------------- t
--R                     1209600
--R   +
--R        9      8      7      5      3
--R     10x  - 45x  + 60x  - 42x  + 20x  - 3x  9
--R     ------------------------------------- t
--R                    3628800
--R   +
--R        10       9       8       6       4      2
--R     66x   - 330x  + 495x  - 462x  + 330x  - 99x  + 5  10      11
--R     ------------------------------------------------ t   + O(t  )
--R                         239500800

--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 12
--S 13 of 19
approximateEquality(gg1,gg2)
--R
--R
--R   (13)  true
--R                                                                Type: Boolean
--E 13
--S 14 of 19
h1 := taylor(2*exp(t/2)/(exp(t) + 1))
--R
--R
--R             1  2    5   4     61   6     277    8      50521    10      11
--R   (14)  1 - - t  + --- t  - ----- t  + ------- t  - ---------- t   + O(t  )
--R             8      384      46080      2064384      3715891200
--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 14
--S 15 of 19
h2 := taylor(n +-> euler(n)/(2**n * factorial(n)),t = 0)
--R
--R
--R             1  2    5   4     61   6     277    8      50521    10      11
--R   (15)  1 - - t  + --- t  - ----- t  + ------- t  - ---------- t   + O(t  )
--R             8      384      46080      2064384      3715891200
--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 15
--S 16 of 19
approximateEquality(h1,h2)
--R
--R
--R   (16)  true
--R                                                                Type: Boolean
--E 16
--S 17 of 19
hh1 := taylor(2*exp(t*x)/(exp(t) + 1),t = 0)
--R
--R
--R   (17)
--R                     2            3     2           4     3
--R         2x - 1     x  - x  2   4x  - 6x  + 1  3   x  - 2x  + x  4
--R     1 + ------ t + ------ t  + ------------- t  + ------------ t
--R            2          2              24                24
--R   +
--R       5     4     2           6     5     3

--R     2x  - 5x  + 5x  - 1  5   x  - 3x  + 5x  - 3x  6
--R     ------------------- t  + ------------------- t
--R             240                      720
--R   +
--R       7      6      4      2            8     7      5      3
--R     8x  - 28x  + 70x  - 84x  + 17  7   x  - 4x  + 14x  - 28x  + 17x  8
--R     ----------------------------- t  + ---------------------------- t
--R                 40320                              40320
--R   +
--R       9     8      6       4       2
--R     2x  - 9x  + 42x  - 126x  + 153x  - 31  9
--R     ------------------------------------- t
--R                     725760
--R   +
--R      10     9      7       5       3
--R     x   - 5x  + 30x  - 126x  + 255x  - 155x  10      11
--R     --------------------------------------- t   + O(t  )
--R                     3628800
--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 17
--S 18 of 19
hh2 := taylor(n +-> eulerPolynomial(n)/factorial(n),t = 0)
--R
--R   Compiling function eulerPolynomial with type Integer -> Expression(
--R      Integer)
--R
--R   (18)
--R                     2            3     2           4     3
--R         2x - 1     x  - x  2   4x  - 6x  + 1  3   x  - 2x  + x  4
--R     1 + ------ t + ------ t  + ------------- t  + ------------ t
--R            2          2              24                24
--R   +
--R       5     4     2           6     5     3
--R     2x  - 5x  + 5x  - 1  5   x  - 3x  + 5x  - 3x  6
--R     ------------------- t  + ------------------- t
--R             240                      720
--R   +
--R       7      6      4      2            8     7      5      3
--R     8x  - 28x  + 70x  - 84x  + 17  7   x  - 4x  + 14x  - 28x  + 17x  8
--R     ----------------------------- t  + ---------------------------- t
--R                 40320                              40320
--R   +
--R       9     8      6       4       2
--R     2x  - 9x  + 42x  - 126x  + 153x  - 31  9
--R     ------------------------------------- t
--R                     725760
--R   +
--R      10     9      7       5       3
--R     x   - 5x  + 30x  - 126x  + 255x  - 155x  10      11

--R     --------------------------------------- t   + O(t  )
--R                     3628800
--R                        Type: UnivariateTaylorSeries(Expression(Integer),t,0)
--E 18
--S 19 of 19
approximateEquality(hh1,hh2)
--R
--R
--R   (19)  true
--R                                                                Type: Boolean
--E 19
)spool
)lisp (bye)

———-

References^{[1] nothing}

10