Mon Feb 16 10:37:30 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"): >> # ---------- Trigonometry ---------- # >> # => - [(sqrt(5) + 1) sqrt(2)]/[(sqrt(5) - 1) sqrt(sqrt(5) + 5)] &> = - sqrt[1 + 2/sqrt(5)] &> From B. F. Caviness, Robert P. Gilbert, Wolfram Koepf, Roman Shtokhamer and &> David W. Wood, _An Introduction to Applied Symbolic Computation using &> MACSYMA_, University of Delaware, draft of December 14, 1993, section 2.3.3. &> # >> tan(7*PI/10); / 3 PI \ - tan| ---- | \ 10 / Time: 3840 msec Type: "_mult" >> normal(simplify(expand(%))); / 3 PI \ 8 sin| ---- | \ 10 / - ----------------------------------------------------------- / PI \ 1/2 / PI \ / PI \ 1/2 1/2 5 cos| -- | + 5 cos| -- | - 3 sin| -- | (10 - 2 5 ) \ 10 / \ 10 / \ 10 / Time: 7290 msec Type: "_mult" >> # => - cos 3 # >> sqrt((1 + cos(6))/2); / cos(6) \1/2 | ------ + 1/2 | \ 2 / Time: 210 msec Type: "_power" >> # cos(n pi) + sin((4 n - 1)/2 pi) => (-1)^n - 1 for integer n # >> assume(n, Type::Integer): >> cos(n*PI) + sin((4*n - 1)/2 * PI); cos(n PI) + sin(PI (2 n - 1/2)) Time: 1290 msec Type: "_plus" >> expand(%); 2 2 cos(n PI) - cos(n PI) + sin(n PI) Time: 180 msec Type: "_plus" >> # cos(cos(n pi) pi) + sin(cos(n pi) pi/2) => -1 + (-1)^n for integer n # >> cos(cos(n*PI)*PI) + sin(cos(n*PI)*PI/2); / PI cos(n PI) \ cos(PI cos(n PI)) + sin| ------------ | \ 2 / Time: 150 msec Type: "_plus" >> # sin([n^5/5 + n^4/2 + n^3/3 - n/30] pi) => 0 for integer n &> [Paul Zimmermann] # >> sin((n^5/5 + n^4/2 + n^3/3 - n/30) * PI); / / 3 4 5 \ \ | | n n n n | | sin| PI | -- - -- + -- + -- | | \ \ 3 30 2 5 / / Time: 160 msec Type: "sin" >> unassume(n, Type::Integer): >> # | cos x |, | sin x | => - cos x, - sin x for - 3 pi < x < - 5/2 pi # >> assume(-3*PI < x): >> assume(x < -5/2*PI): >> [abs(cos(x)), abs(sin(x))]; [abs(cos(x)), abs(sin(x))] Time: 6290 msec Type: DOM_LIST >> unassume(x): >> # Trigonometric manipulations---these are typically difficult for students # >> r:= cos(3*x)/cos(x); cos(3 x) -------- cos(x) Time: 310 msec Type: "_mult" >> # => cos(x)^2 - 3 sin(x)^2 or similar # >> expand(r); 2 2 cos(x) - 3 sin(x) Time: 170 msec Type: "_plus" >> # => 2 cos(2 x) - 1 # >> simplify(expand(r)); 2 cos(2 x) - 1 Time: 410 msec Type: "_plus" >> combine(expand(r), sincos); 2 cos(2 x) - 1 Time: 190 msec Type: "_plus" >> # Use rewrite rules => cos(x)^2 - 3 sin(x)^2 # >> d:= domain("match"): >> d::FREEVARIABLE:= TRUE: >> n:= new(d, "n", func(testtype(m, DOM_INT), m)): >> cos_Angles:= proc(e) local s; &> begin &> s:= match(e, cos(n*x)); &> if s <> FAIL then &> subs(hold(cos(("n" - 1)*x) * cos(x) - sin(("n" - 1)*x) * sin(x)), s) &> else &> e &> end_if &> end_proc: >> sin_Angles:= proc(e) local s; &> begin &> s:= match(e, sin(n*x)); &> if s <> FAIL then &> subs(hold(sin(("n" - 1)*x) * cos(x) + cos(("n" - 1)*x) * sin(x)), s) &> else &> e &> end_if &> end_proc: >> sincos_Angles:= proc(e) &> begin &> if op(e) = e then &> e &> else &> map(sin_Angles(cos_Angles(e)), sincos_Angles) &> end_if &> end_proc: >> expand(sincos_Angles(r)); 2 2 cos(x) - 3 sin(x) Time: 1280 msec Type: "_plus" >> d:= NIL: >> n:= NIL: >> r:= NIL: >> # Here is a tricky way of writing 0/0 # >> xpr:= (tan(x)^2 + 1 - sec(x)^2)/(sin(x)^2 + cos(x)^2 - 1); 2 1 tan(x) - ------- + 1 2 cos(x) --------------------- 2 2 cos(x) + sin(x) - 1 Time: 620 msec Type: "_mult" >> # Let's try simplifying this expression! # >> simplify(xpr); Error: Division by zero [_power]; in procedure 'funcattr(proc(e, p) name combine; local _t, f, l, i, n, b, _e; begin if e::combine <> FAIL then return(e::combine(e, args(2..args(0)))) end_if; case args(0) of 1 do break of 2 do if type(p) = DOM_LIST then for _t in p do e:=combine(e, _t) end_for; return(e) else if traperror((p:=funcattr(combine, expr2text(ar' >> combine(%, sincos); Error: Division by zero [_power]; in procedure 'funcattr(proc(e, p) name combine; local _t, f, l, i, n, b, _e; begin if e::combine <> FAIL then return(e::combine(e, args(2..args(0)))) end_if; case args(0) of 1 do break of 2 do if type(p) = DOM_LIST then for _t in p do e:=combine(e, _t) end_for; return(e) else if traperror((p:=funcattr(combine, expr2text(ar' >> # What is its limit at zero? # >> limit(xpr, x = 0); Error: division by zero [Puiseux::_invert] >> # What is the derivative? # >> diff(xpr, x); 2 2 sin(x) 2 tan(x) (tan(x) + 1) - -------- 3 cos(x) --------------------------------- 2 2 cos(x) + sin(x) - 1 Time: 13610 msec Type: "_mult" >> simplify(%); Error: Division by zero [_power]; in procedure 'funcattr(proc(e, p) name combine; local _t, f, l, i, n, b, _e; begin if e::combine <> FAIL then return(e::combine(e, args(2..args(0)))) end_if; case args(0) of 1 do break of 2 do if type(p) = DOM_LIST then for _t in p do e:=combine(e, _t) end_for; return(e) else if traperror((p:=funcattr(combine, expr2text(ar' >> combine(%, sincos); Error: Division by zero [_power]; in procedure 'funcattr(proc(e, p) name combine; local _t, f, l, i, n, b, _e; begin if e::combine <> FAIL then return(e::combine(e, args(2..args(0)))) end_if; case args(0) of 1 do break of 2 do if type(p) = DOM_LIST then for _t in p do e:=combine(e, _t) end_for; return(e) else if traperror((p:=funcattr(combine, expr2text(ar' >> xpr:= NIL: >> # ---------- Quit ---------- # >> quit real 39.80 user 38.83 sys 0.76