Sun Jun  8 19:43:58 MDT 1997
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

% ---------- Operators ----------
procedure f(x); exp(x);


f

Time: 0 ms

procedure g(x); x^2;


g

Time: 10 ms

% (f + 2 g)(y) => e^y + 2 y^2
(f + 2*g)(y);
***** f + 2*g invalid as operator


Cont? (Y or N)


?y
Time: 0 ms

% (f o g)(y) => e^(y^2)
(f * g)(y);
***** f*g invalid as operator


Cont? (Y or N)


?y
Time: 0 ms

clear f, g;


Time: 0 ms

% Truncated Taylor series operator
operator f, g;


Time: 0 ms

procedure T(f, x, a);
   for k:= 0:2 sum sub(x = a, df(f, x, k))/factorial(k) * (x - a)^k$


Time: 0 ms

%  sum(sub(x = a, df(f, x, k))/factorial(k) * (x - a)^k, k, 0, 2)$
on factor;


Time: 0 ms

% => f(a) + f'(a) (x - a) + f''(a) (x - a)^2/2
T(f(x), x, a);


                                                     2
  - (2*((a - x)*sub(x=a,df(f(x),x)) - f(a)) - (a - x) *sub(x=a,df(f(x),x,2)))
------------------------------------------------------------------------------
                                      2

Time: 100 ms

% => g(b) + g'(b) (y - b) + g''(b) (y - b)^2/2
T(g(y), y, b);


                                                     2
  - (2*((b - y)*sub(y=b,df(g(y),y)) - g(b)) - (b - y) *sub(y=b,df(g(y),y,2)))
------------------------------------------------------------------------------
                                      2

Time: 20 ms

% => sin(c) + cos(c) (z - c) - sin(c) (z - c)^2/2
T(sin(z), z, c);


                                          2
  - (2*((c - z)*cos(c) - sin(c)) + (c - z) *sin(c))
----------------------------------------------------
                         2

Time: 20 ms

off factor;


Time: 0 ms

clear T;


Time: 0 ms

% Define the binary infix operator ~ so that x ~ y => sqrt(x^2 + y^2)
% (| is used here, because ~ already has a meaning.)
infix |$


Time: 0 ms

procedure |(x, y);
   sqrt(x^2 + y^2)$


Time: 0 ms

3 | 4;


5

Time: 0 ms

% Make it associative: 3 ~ 4 ~ 12 => 13
3 | 4 | 12;


13

Time: 10 ms

% Define the matchfix pair of operators | and | so that | x | => abs(x)
% ---------- Quit ----------
quit;

Quitting

real 5.82
user 0.23
sys 0.89
