Sat Jul 11 23:29:25 MDT 1998
aquarius% reduce
REDUCE 3.6, 15-Jul-95, patched to 15 Apr 96 ...

1: % ----------[ R e d u c e ]----------
% ---------- Initialization ----------
on time;


Time: 0 ms

% ---------- Series ----------
% Taylor series---this first example comes from special relativity
% => 1 + 1/2 (v/c)^2 + 3/8 (v/c)^4 + 5/16 (v/c)^6 + O((v/c)^8)
load_package(taylor)$


Time: 110 ms

taylorprintterms:= all$


Time: 0 ms

1/sqrt(1 - (v/c)^2);


    abs(c)
---------------
       2    2
 sqrt(c  - v )

Time: 10 ms

taylor(ws, v, 0, 7);


      1     2     3     4      5     6      8
1 + ------*v  + ------*v  + -------*v  + O(v )
        2           4            6
     2*c         8*c         16*c

Time: 10 ms

taylorcombine(1/ws^2);


     1    2      8
1 - ----*v  + O(v )
      2
     c

Time: 0 ms

% Note: sin(x) = x - x^3/6 + x^5/120 - x^7/5040 + O(x^9)
%       cos(x) = 1 - x^2/2 + x^4/24 - x^6/720 + O(x^8)
%       tan(x) = x + x^3/3 + 2/15 x^5 + 17/315 x^7 + O(x^9)
tsin:= taylor(sin(x), x, 0, 7);


             1   3     1    5     1     7      8
tsin := x - ---*x  + -----*x  - ------*x  + O(x )
             6        120        5040

Time: 20 ms

tcos:= taylor(cos(x), x, 0, 7);


             1   2    1    4     1    6      8
tcos := 1 - ---*x  + ----*x  - -----*x  + O(x )
             2        24        720

Time: 30 ms

% Note that additional terms will be computed as needed
taylorcombine(tsin/tcos);


     1   3    2    5    17    7      8
x + ---*x  + ----*x  + -----*x  + O(x )
     3        15        315

Time: 0 ms

taylor(tan(x), x, 0, 7);


     1   3    2    5    17    7      8
x + ---*x  + ----*x  + -----*x  + O(x )
     3        15        315

Time: 10 ms

clear tsin, tcos;


Time: 0 ms

% => -x^2/6 - x^4/180 - x^6/2835 - O(x^8)
taylor(log(sin(x)/x), x, 0, 7);


    1   2     1    4     1     6      8
 - ---*x  - -----*x  - ------*x  + O(x )
    6        180        2835

Time: 30 ms

taylor(sin(x)/x, x, 0, 7);


     1   2     1    4     1     6      8
1 - ---*x  + -----*x  - ------*x  + O(x )
     6        120        5040

Time: 10 ms

taylorcombine(log(ws));


    1   2     1    4     1     6      8
 - ---*x  - -----*x  - ------*x  + O(x )
    6        180        2835

Time: 10 ms

% => [a f'(a d) + g(b d) + integrate(h(c y), y = 0..d)]
%    + [a^2 f''(a d) + b g'(b d) + h(c d)] (x - d)
operator f, g, h;


Time: 0 ms

df(f(a*x), x) + g(b*x) + int(h(c*y), y, 0, x);


df(f(a*x),x) + g(b*x) + int(h(c*y),y,0,x)

Time: 140 ms

taylor(ws, x, d, 1);


g(b*d) + sub(x=d,df(f(a*x),x)) + sub(x=d,int(h(c*y),y,0,x)) + (

   sub(x=d,df(f(a*x),x,2)) + sub(x=d,df(g(b*x),x))

                                                           2
    + sub(x=d,df(int(h(c*y),y,0,x),x)))*(x - d) + O((x - d) )

Time: 20 ms

% Taylor series of nonscalar objects (noncommutative multiplication)
% => (B A - A B) t^2/2 + O(t^3)   [Stanly Steinberg]
operator A, B;


Time: 10 ms

noncom A, B;


Time: 0 ms

e^((A() + B())*t) - e^(A()*t) * e^(B()*t);


0

Time: 0 ms

taylor(e^((A() + B())*t) - e^(A()*t) * e^(B()*t), t, 0, 4);


0

Time: 10 ms

clear A, B;


Time: 0 ms

% Laurent series:
% => sum( Bernoulli[k]/k! x^(k - 2), k = 1..infinity )
%    = 1/x^2 - 1/(2 x) + 1/12 - x^2/720 + x^4/30240 + O(x^6)
%    [Levinson and Redheffer, p. 173]
taylor(1/(x*(exp(x) - 1)), x, 0, 8);


 -2    1   -1    1       1    2      1     4       1      6       1       8
x   - ---*x   + ---- - -----*x  + -------*x  - ---------*x  + ----------*x
       2         12     720        30240        1209600        47900160

      9
 + O(x )

Time: 20 ms

% Puiseux series (terms with fractional degree):
% => 1/sqrt(x - 3/2 pi) + (x - 3/2 pi)^(3/2) / 12 + O([x - 3/2 pi]^(7/2))
taylor(sqrt(sec(x)), x, 3/2*pi, 3);


      3*pi   - 1/2    1         3*pi  3/2           3*pi  7/2
(x - ------)       + ----*(x - ------)    + O((x - ------)   )
       2              12         2                   2

Time: 40 ms

% Generalized Taylor series => sum( [x log x]^k/k!, k = 0..infinity )
taylor(x^x, x, 0, 3);


        4
 x + O(x )
x

Time: 10 ms

% Compare the generalized Taylor series of two different formulations of a
% function => log(z) + log(cosh(w)) + tanh(w) z + O(z^2)
s1:= taylor(log(sinh(z)) + log(cosh(z + w)), z, 0, 1);


                                sinh(w)         2
s1 := log(z) + (log(cosh(w)) + ---------*z + O(z ))
                                cosh(w)

Time: 30 ms

s2:= taylor(log(sinh(z) * cosh(z + w)), z, 0, 1);


s2 := taylor(log(cosh(w + z)*sinh(z)),z,0,1)

Time: 20 ms

taylorcombine(s1 - s2);


log(z) - taylor(log(cosh(w + z)*sinh(z)),z,0,1)

                    sinh(w)         2
 + (log(cosh(w)) + ---------*z + O(z ))
                    cosh(w)

Time: 10 ms

clear s1, s2;


Time: 0 ms

% Look at the generalized Taylor series around x = 1
% => (x - 1)^a/e^b [1 - (a + 2 b) (x - 1) / 2 + O((x - 1)^2)]
log(x)^a*exp(-b*x);


       a
 log(x)
---------
   b*x
  e

Time: 10 ms

taylor(ws, x, 1, 2);


       a   1       - a - 2*b                     2
(x - 1) *(---- + ------------*(x - 1) + O((x - 1) ))
            b           b
           e         2*e

Time: 20 ms

% Asymptotic expansions => sqrt(2) x + O(1/x)
taylor(sqrt(2*x^2 + 1), x, infinity, 0);


          1        1
sqrt(2)*----- + O(---)
          -1       x
         x

Time: 10 ms

% Wallis' product => 1/sqrt(pi n) + ...   [Knopp, p. 385]
load_package(specfn)$


*** psi already defined as operator 

*** ci already defined as operator 

*** si already defined as operator 

Time: 1460 ms  plus GC time: 40 ms
taylor(1/2^(2*n) * Binomial(2*n, n), n, infinity, 0);


        binomial(2*n,n)
taylor(-----------------,n,infinity,0)
              2*n
             2

Time: 30 ms

% => 0!/x - 1!/x^2 + 2!/x^3 - 3!/x^4 + O(1/x^5)   [Knopp, p. 544]
exp(x) * int(exp(-t)/t, t, x, infinity);


 x      exp( - t)
e *int(-----------,t,x,infinity)
            t

Time: 0 ms

taylor(ws, x, infinity, 5);


***** Zero divisor 

***** Error during expansion (possible singularity!) 

Cont? (Y or N)


?y
Time: 10 ms

% Multivariate Taylor series expansion => 1 - (x^2 + 2 x y + y^2)/2 + O(x^4)
taylor(cos(x + y), {x, y}, 0, 3);


     1   2          1   2          4
1 - ---*y  - y*x - ---*x  + O({x,y} )
     2              2

Time: 50 ms

% Power series (compute the general formula)
load_package(fps)$


Time: 250 ms

FPS(log(sin(x)/x), x);


         sin(x)
fps(log(--------),x,0)
           x

Time: 5260 ms  plus GC time: 690 ms
FPS(exp(-x)*sin(x), x);


            k  k/2      k*pi
         - x *2   *sin(------)
                         4
infsum(------------------------,k,0,infinity)
             factorial(k)

Time: 910 ms  plus GC time: 70 ms
taylor(ws, x, 0, 7);



***** Syntax error: 0()()(infsum(0,k,0,infinity)(
***** Bus Error in inprint

Cont? (Y or N)


?y
Time: 60 ms

% Derive an explicit Taylor series solution of y as a function of x from the
% following implicit relation:
% y = x - 1 + (x - 1)^2/2 + 2/3 (x - 1)^3 + (x - 1)^4 + 17/10 (x - 1)^5 + ...
x = sin(y) + cos(y);


x=cos(y) + sin(y)$

Time: 10 ms

taylor(rhs(ws), y, 0, 7);


taylor(1 + y - 1/2*y**2 - 1/6*y**3 + 1/24*y**4 + 1/120*y**5 - 1/720*y**6 - 1/
5040*y**7,y,0,7)$

Time: 60 ms

y = taylorrevert(ws, y, x);


y=taylor(x - 1 + 1/2*(x - 1)**2 + 2/3*(x - 1)**3 + (x - 1)**4 + 17/10*(x - 1)**5
 + 37/12*(x - 1)**6 + 41/7*(x - 1)**7,x,1,7)$

Time: 50 ms

% Pade (rational function) approximation => (2 - x)/(2 + x)
load_package(rataprx)$


Time: 70 ms

pade(exp(-x), x, 0, 1, 1);


( - x + 2)/(x + 2)$

Time: 60 ms

% Fourier series of f(x) of period 2 p over the interval [-p, p]
load_package(camal)$


Time: 30 ms

% => - (2 p / pi) sum( (-1)^n sin(n pi x / p) / n, n = 1..infinity )
%fourier(x, x, p);
fourier(x);


[(x)]$

Time: 0 ms

% => p / 2
% - (2 p / pi^2) sum( [1 - (-1)^n] cos(n pi x / p) / n^2, n = 1..infinity )
%fourier(abs(x), x, p);
fourier(abs(x));


***** Unknown function 
***** Bus Error in calling prin2

Cont? (Y or N)


?y
Time: 0 ms

% ---------- Quit ----------
quit;

Quitting

real 38.76
user 9.80
sys 3.01

-------------------------------------------------------------------------------

Sat Jul 11 23:38:30 MDT 1998
aquarius% reduce
REDUCE 3.6, 15-Jul-95, patched to 15 Apr 96 ...

1: % ----------[ R e d u c e ]----------
% ---------- Initialization ----------
on time;


Time: 0 ms

% ---------- Series ----------
load_package(taylor)$


Time: 110 ms

taylorprintterms:= all$


Time: 0 ms

% Derive an explicit Taylor series solution of y as a function of x from the
% following implicit relation:
% y = x - 1 + (x - 1)^2/2 + 2/3 (x - 1)^3 + (x - 1)^4 + 17/10 (x - 1)^5 + ...
x = sin(y) + cos(y);


x=cos(y) + sin(y)

Time: 0 ms

taylor(rhs(ws), y, 0, 7);


         1   2    1   3    1    4     1    5     1    6     1     7      8
1 + y - ---*y  - ---*y  + ----*y  + -----*y  - -----*y  - ------*y  + O(y )
         2        6        24        120        720        5040

Time: 40 ms

y = taylorrevert(ws, y, x);


           1         2    2         3          4    17         5    37         6
y=x - 1 + ---*(x - 1)  + ---*(x - 1)  + (x - 1)  + ----*(x - 1)  + ----*(x - 1)
           2              3                         10              12

    41         7            8
 + ----*(x - 1)  + O((x - 1) )
    7

Time: 20 ms

% Pade (rational function) approximation => (2 - x)/(2 + x)
load_package(rataprx)$


Time: 230 ms

pade(exp(-x), x, 0, 1, 1);


  - x + 2
----------
  x + 2

Time: 40 ms

% Fourier series of f(x) of period 2 p over the interval [-p, p]
load_package(camal)$


Time: 30 ms

% => - (2 p / pi) sum( (-1)^n sin(n pi x / p) / n, n = 1..infinity )
%fourier(x, x, p);
fourier(x);


[(x)]

Time: 10 ms

% => p / 2
% - (2 p / pi^2) sum( [1 - (-1)^n] cos(n pi x / p) / n^2, n = 1..infinity )
%fourier(abs(x), x, p);
fourier(abs(x));


***** Unknown function 
***** Bus Error in calling prin2

Cont? (Y or N)


?y
Time: 0 ms

% ---------- Quit ----------
quit;

Quitting

real 11.21
user 0.56
sys 1.15
