1 /* Original version of this file copyright 1999 by Michael Wester,
2 * and retrieved from http://www.math.unm.edu/~wester/demos/Trigonometry/problems.macsyma
5 * Released under the terms of the GNU General Public License, version 2,
6 * per message dated 2007-06-03 from Michael Wester to Robert Dodier
7 * (contained in the file wester-gpl-permission-message.txt).
9 * See: "A Critique of the Mathematical Abilities of CA Systems"
10 * by Michael Wester, pp 25--60 in
11 * "Computer Algebra Systems: A Practical Guide", edited by Michael J. Wester
12 * and published by John Wiley and Sons, Chichester, United Kingdom, 1999.
14 /* ----------[ M a c s y m a ]---------- */
15 /* ---------- Initialization ---------- */
18 /* ---------- Trigonometry ---------- */
19 /* => - [(sqrt(5) + 1) sqrt(2)]/[(sqrt(5) - 1) sqrt(sqrt(5) + 5)]
20 = - sqrt[1 + 2/sqrt(5)]
21 From B. F. Caviness, Robert P. Gilbert, Wolfram Koepf, Roman Shtokhamer and
22 David W. Wood, _An Introduction to Applied Symbolic Computation using
23 MACSYMA_, University of Delaware, draft of December 14, 1993, section 2.3.3.
27 factor(rootscontract(%));
30 /* cos(n pi) + sin((4 n - 1)/2 pi) => (-1)^n - 1 for integer n */
32 cos(n*%pi) + sin((4*n - 1)/2 * %pi);
33 /* cos(cos(n pi) pi) + sin(cos(n pi) pi/2) => -1 + (-1)^n for integer n */
34 cos(cos(n*%pi)*%pi) + sin(cos(n*%pi)*%pi/2);
35 /* sin([n^5/5 + n^4/2 + n^3/3 - n/30] pi) => 0 for integer n
37 sin((n^5/5 + n^4/2 + n^3/3 - n/30) * %pi);
39 /* | cos x |, | sin x | => - cos x, - sin x for - 3 pi < x < - 5/2 pi */
40 assume(-3*%pi < x, x < -5/2*%pi)$
41 [abs(cos(x)), abs(sin(x))];
42 forget(-3*%pi < x, x < -5/2*%pi)$
43 /* Trigonometric manipulations---these are typically difficult for students */
45 /* => cos(x)^2 - 3 sin(x)^2 or similar */
46 ratsimp(trigexpand(r));
47 /* => 2 cos(2 x) - 1 */
48 poissimp(ratsimp(trigexpand(r)));
49 ratsimp(trigreduce(ratsimp(trigexpand(r))));
50 /* Use rewrite rules => cos(x)^2 - 3 sin(x)^2 */
51 matchdeclare(n, integerp, x, true)$
52 defrule(cos_angles, cos(n*x),
53 cos((n - 1)*x) * cos(x) - sin((n - 1)*x) * sin(x));
54 defrule(sin_angles, sin(n*x),
55 sin((n - 1)*x) * cos(x) + cos((n - 1)*x) * sin(x));
56 apply2(r, cos_angles, sin_angles);
59 /* Here is a tricky way of writing 0/0 */
60 expr: (tan(x)^2 + 1 - sec(x)^2)/(sin(x)^2 + cos(x)^2 - 1);
61 /* Let's try simplifying this expression! */
63 /* What is its limit at zero? */
65 /* What is the derivative? */