Mon Feb 16 10:48:44 MST 1998 aquarius% mupad *----* MuPAD 1.4.0 -- Multi Processing Algebra Data Tool /| /| *----* | Copyright (c) 1997 - 98 by SciFace Software GmbH | *--|-* All rights reserved. |/ |/ *----* Licensed to: Michael Wester >> # ----------[ M u P A D ]---------- # >> # ---------- Initialization ---------- # >> TEXTWIDTH:= 80: >> read("../../Time.mupad"): >> # ---------- Operators ---------- # >> f:= proc(x) begin exp(x) end_proc; proc(x) name f; begin exp(x) end_proc Time: 90 msec Type: DOM_PROC >> g:= proc(x) begin x^2 end_proc; proc(x) name g; begin x^2 end_proc Time: 60 msec Type: DOM_PROC >> # (f + 2 g)(y) => e^y + 2 y^2 # >> (f + 2*g)(y); 2 exp(y) + 2 y Time: 130 msec Type: "_plus" >> # (f o g)(y) => e^(y^2) # >> (f @ g)(y); 2 exp(y ) Time: 60 msec Type: "exp" >> f:= NIL: >> g:= NIL: >> # Linear differential operator # >> L:= (D - id) @ (D + 2*id); (D - id)@(2 id + D) Time: 300 msec Type: "_fconcat" >> # => f'' + f' - 2 f # >> L(f); D(f) - 2 f + D(D(f)) Time: 220 msec Type: "_plus" >> # => g''(y) + g'(y) - 2 g(y) # >> L(g)(y); D(g)(y) - 2 g(y) + D(D(g))(y) Time: 80 msec Type: "_plus" >> # => 2 A [(1 + z) cos(z^2) - (1 + 2 z^2) sin(z^2)] # >> L(func(A * sin(z^2), z))(z); 2 2 2 2 2 2 A cos(z ) - 2 A sin(z ) + 2 A z cos(z ) - 4 A z sin(z ) Time: 770 msec Type: "_plus" >> # Truncated Taylor series operator # >> T:= proc(f, x, a) &> begin &> _plus(D([1 $ k], f)(a)/k! * (x - a)^k $ k = 0..2) &> end_proc: >> # => f(a) + f'(a) (x - a) + f''(a) (x - a)^2/2 # >> T(f); 2 (x - a) D([1, 1], f)(a) f(a) + D([1], f)(a) (x - a) + ------------------------ 2 Time: 170 msec Type: "_plus" >> # => g(b) + g'(b) (y - b) + g''(b) (y - b)^2/2 # >> T(g, y, b); 2 (y - b) D([1, 1], g)(b) g(b) + D([1], g)(b) (y - b) + ------------------------ 2 Time: 100 msec Type: "_plus" >> # => sin(c) + cos(c) (z - c) - sin(c) (z - c)^2/2 # >> T(sin, z, c); 2 sin(c) (z - c) sin(c) + cos(c) (z - c) - --------------- 2 Time: 110 msec Type: "_plus" >> TT:= proc(f) &> begin &> eval(subsop(hold(func(f, x, a)), &> 1 = _plus(f(a), _fconcat(D $ k)(f)(a)/k! * (x - a)^k &> $ k = 1..2))) &> end_proc: >> # => f(a) + f'(a) (x - a) + f''(a) (x - a)^2/2 # >> TT(f); func(f(a) + D(f)(a)*(a*(-1) + x) + D(D(f))(a)*(a*(-1) + x)^2*1/2, x, a) Time: 220 msec Type: "fun" >> # => g(b) + g'(b) (y - b) + g''(b) (y - b)^2/2 # >> TT(g)(y, b); 2 D(D(g))(b) (y - b) g(b) + D(g)(b) (y - b) + ------------------- 2 Time: 160 msec Type: "_plus" >> # => sin(c) + cos(c) (z - c) - sin(c) (z - c)^2/2 # >> TT(sin)(z, c); 2 sin(c) (z - c) sin(c) + cos(c) (z - c) - --------------- 2 Time: 150 msec Type: "_plus" >> L:= NIL: >> T:= NIL: >> TT:= NIL: >> # Define the binary infix operator ~ so that x ~ y => sqrt(x^2 + y^2) # >> tilde:= proc(x, y) begin sqrt(x^2 + y^2) end_proc: >> 3 &tilde 4; 5 Time: 490 msec Type: DOM_INT >> # Make it associative: 3 ~ 4 ~ 12 => 13 # >> 3 &tilde 4 &tilde 12; 5 Time: 80 msec Type: DOM_INT >> (3 &tilde 4) &tilde 12; 13 Time: 90 msec Type: DOM_INT >> # Define the matchfix pair of operators | and | so that | x | => abs(x) # >> # ---------- Quit ---------- # >> quit real 5.88 user 5.08 sys 0.61