Thu Feb 25 18:59:15 MST 1999 aquarius% maple |\^/| Maple V Release 5.1 (WMI Campus Wide License) ._|\| |/|_. Copyright (c) 1981-1998 by Waterloo Maple Inc. All rights \ MAPLE / reserved. Maple and Maple V are registered trademarks of <____ ____> Waterloo Maple Inc. | Type ? for help. # ----------[ M a p l e ]---------- #interface(echo = 3); # ---------- Initialization ---------- > readlib(showtime): > _Envadditionally:= true: > on; # ---------- Calculus ---------- # Calculus on a non-smooth (but well defined) function => x/|x| or sign(x) O1 := diff(abs(x), x); abs(1, x) time = 0.13, bytes = 314574 # Calculus on a piecewise defined function O2 := a:= proc(x) if x < 0 then -x else x fi end: time = 0.00, bytes = 9366 # => if x < 0 then -1 else 1 O3 := D(a); proc(x) if x < 0 then -1 else 1 fi end time = 0.08, bytes = 92870 O4 := a:= proc(x) piecewise(x < 0, -x, x) end: time = 0.01, bytes = 5150 O5 := diff(a(x), x); bytes used=1174952, alloc=982860, time=0.68 { -1 x < 0 { { undefined x = 0 { { 1 0 < x time = 0.53, bytes = 784430 O6 := a:= 'a': time = 0.01, bytes = 4474 # Derivative of a piecewise defined function at a point [Herbert Fischer]. # f(x) = x^2 - 1 for x = 1 otherwise x^3. f(1) = 0 and f'(1) = 3 O7 := f:= proc(x) if x = 1 then x^2 - 1 else x^3 fi end: time = 0.01, bytes = 14826 O8 := f(1); 0 time = 0.00, bytes = 4146 O9 := diff(f(x), x); 2 3 x time = 0.00, bytes = 4642 O10 := subs(x = 1, %); 3 time = 0.01, bytes = 4218 O11 := f:= proc(x) piecewise(x = 1, x^2 - 1, x^3) end: time = 0.00, bytes = 4902 O12 := f(1); 0 time = 0.01, bytes = 4366 O13 := diff(f(x), x); 2 3 x time = 0.11, bytes = 89350 O14 := subs(x = 1, %); 3 time = 0.00, bytes = 3746 O15 := f:= proc(x) piecewise(x <> 1, x^3, x^2 - 1) end: time = 0.01, bytes = 4570 O16 := f(1); 0 time = 0.01, bytes = 4406 O17 := diff(f(x), x); Error, Arguments not of right type time = 0.01, bytes = 6330 O18 := f:= 'f': time = 0.01, bytes = 4002 # d^n/dx^n(x^n) => n! O19 := assume(n, integer): time = 0.01, bytes = 11314 O20 := diff(x^n, x$n); n~ diff(x , x $ n~) time = 0.01, bytes = 4418 O21 := n:= 'n': time = 0.00, bytes = 4358 # Apply the chain rule---this is important for PDEs and many other # applications => y_xx (x_t)^2 + y_x x_tt O22 := diff(y(x(t)), t$2); / 2 \ (2) /d \2 |d | (D )(y)(x(t)) |-- x(t)| + D(y)(x(t)) |--- x(t)| \dt / | 2 | \dt / time = 0.05, bytes = 40502 # => f(h(x)) dh/dx - f(g(x)) dg/dx O23 := int(f(y), y = g(x)..h(x)); h(x) / | | f(y) dy | / g(x) time = 0.24, bytes = 377450 O24 := diff(%, x); /d \ /d \ |-- h(x)| f(h(x)) - |-- g(x)| f(g(x)) \dx / \dx / time = 0.01, bytes = 9326 # Exact differential => d(V(P, T)) => dV/dP DP + dV/dT DT O25 := diff(V(P, T)); Error, wrong number (or type) of parameters in function diff time = 0.02, bytes = 9078 O26 := D(V(P, T)); D(V(P, T)) time = 0.02, bytes = 17834 # Implicit differentiation => dy/dx = [1 - y sin(x y)] / [1 + x sin(x y)] O27 := y = cos(x*y) + x; y = cos(x y) + x time = 0.02, bytes = 15218 O28 := implicitdiff(%, y, x); bytes used=2175364, alloc=1572576, time=1.69 sin(x y) y - 1 - -------------- 1 + sin(x y) x time = 0.43, bytes = 203890 # => 2 (x + y) g'(x^2 + y^2) O29 := diff(f(x, y), x) + diff(f(x, y), y); /d \ /d \ |-- f(x, y)| + |-- f(x, y)| \dx / \dy / time = 0.01, bytes = 8230 O30 := factor(subs(f(x, y) = g(x^2 + y^2), %)); 2 2 2 D(g)(x + y ) (x + y) time = 0.07, bytes = 74410 # Residue => - 9/4 O31 := readlib(residue): time = 0.01, bytes = 9690 O32 := residue((z^3 + 5)/((z^4 - 1)*(z + 1)), z = -1); -9/4 time = 0.03, bytes = 44522 # Differential forms O33 := with(difforms): time = 0.03, bytes = 33518 # (2 dx + dz) /\ (3 dx + dy + dz) /\ (dx + dy + 4 dz) => 8 dx /\ dy /\ dz O34 := defform(dx = 1, dy = 1, dz = 1): time = 0.03, bytes = 41326 O35 := (2*dx + dz) &^ (3*dx + dy + dz) &^ (dx + dy + 4*dz); 8 &^(dx, dy, dz) time = 0.11, bytes = 115014 # d(3 x^5 dy /\ dz + 5 x y^2 dz /\ dx + 8 z dx /\ dy) # => (15 x^4 + 10 x y + 8) dx /\ dy /\ dz O36 := defform(x = 1, y = 1, z = 1): time = 0.05, bytes = 31710 O37 := d(3*x^5 &^ (d(y) &^ d(z)) + 5*x*y^2 &^ (d(z) &^ d(x)) + 8*z &^ (d(x) &^ d(y))); Error, form used as exponent time = 0.03, bytes = 28602 O38 := d(3*x^5 &^ (d(y) &^ d(z))); Error, form used as exponent time = 0.00, bytes = 5410 O39 := d(5*x*y^2 &^ (d(z) &^ d(x))); Error, form used as exponent time = 0.01, bytes = 6798 O40 := d(8*z &^ (d(x) &^ d(y))); 8 &^(d(z), d(x), d(y)) time = 0.02, bytes = 18990 # => 1 - 3/8 2^(1/3) = 0.5275296 O41 := minimize(x^4 - x + 1); bytes used=3176052, alloc=2096768, time=2.96 3 1 - 3/4 RootOf(4 _Z - 1, .6299605249) time = 0.74, bytes = 501242 O42 := evalf(%); .5275296063 time = 0.00, bytes = 3954 # => [0, 1] O43 := [minimize(1/(x^2 + y^2 + 1)), maximize(1/(x^2 + y^2 + 1))]; [-infinity, infinity] time = 0.47, bytes = 360634 # Minimize on [-1, 1] x [-1, 1]: # => min(a - b - c + d, a - b + c - d, a + b - c - d, a + b + c + d) O44 := minimize(a + b*x + c*y + d*x*y, {x, y}, {x = -1..1, y = -1..1}); a - b - c + d, a - b + c - d, a + b - c - d, a + b + c + d time = 0.32, bytes = 253474 # => [-1, 1] O45 := [minimize(x^2*y^3, {x, y}, {x = -1..1, y = -1..1}), O45 := maximize(x^2*y^3, {x, y}, {x = -1..1, y = -1..1})]; Error, invalid arguments time = 0.16, bytes = 119098 # Linear programming: minimize the objective function z subject to the # variables xi being non-negative along with an additional set of constraints. # See William R. Smythe, Jr. and Lynwood A. Johnson, _Introduction to Linear # Programming, with Applications_, Prentice Hall, Inc., 1966, p. 117: # minimize z = 4 x1 - x2 + 2 x3 - 2 x4 => {x1, x2, x3, x4} = {2, 0, 2, 4} # with zmin = 4 O46 := simplex[minimize](4*x1 - x2 + 2*x3 - 2*x4, {2*x1 + x2 + x3 + x4 <= 10, O46 := x1 - 2*x2 - x3 + x4 >= 4, x1 + x2 + 3*x3 - x4 >= 4}, O46 := NONNEGATIVE); bytes used=4176280, alloc=2424388, time=4.53 {x1 = 2, x4 = 4, x3 = 2, x2 = 0} time = 0.58, bytes = 196734 O47 := subs(%, 4*x1 - x2 + 2*x3 - 2*x4); 4 time = 0.01, bytes = 3726 # ---------- Quit ---------- O48 := quit bytes used=4232308, alloc=2424388, time=4.61 real 5.87 user 4.65 sys 1.17