trigsimp.tex 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. \chapter[TRIGSIMP: Trigonometric simplification]%
  2. {TRIGSIMP: Simplification and factorisation of trigonometric
  3. and hyperbolic functions}
  4. \label{TRIGSIMP}
  5. \typeout{{TRIGSIMP: Simplification and factorisation of trigonometric
  6. and hyperbolic functions}}
  7. {\footnotesize
  8. \begin{center}
  9. Wolfram Koepf, Andreas Bernig and Herbert Melenk\\
  10. Konrad--Zuse--Zentrum f\"ur Informationstechnik Berlin \\
  11. Takustra\"se 7 \\
  12. D--14195 Berlin--Dahlem, Germany \\[0.05in]
  13. e--mail: Koepf@zib.de
  14. \end{center}
  15. }
  16. \ttindex{TRIGSIMP}
  17. There are three
  18. procedures included in TRIGSIMP: trigsimp, trigfactorize and triggcd.
  19. The first is for finding simplifications of trigonometric or
  20. hyperbolic expressions with many options, the second for factorising
  21. them and the third
  22. for finding the greatest common divisor of two trigonometric or
  23. hyperbolic polynomials.
  24. \section{Simplifiying trigonometric expressions}
  25. As there is no normal form for trigonometric and hyperbolic functions,
  26. the same function can convert in many different directions, {\em e.g. }
  27. $\sin(2x) \leftrightarrow 2\sin(x)\cos(x)$.
  28. The user has the possibility to give several parameters to the
  29. procedure {\tt trigsimp} in order to influence the direction of
  30. transformations. The decision whether a rational expression in
  31. trigonometric and hyperbolic functions vanishes or not is possible.
  32. \ttindex{trigsimp}
  33. To simplify a function {\tt f}, one uses {\tt trigsimp(f[,options])}. Example:
  34. \begin{verbatim}
  35. 2: trigsimp(sin(x)^2+cos(x)^2);
  36. 1
  37. \end{verbatim}
  38. Possible options are (* denotes the default):
  39. \begin{enumerate}
  40. \item {\tt sin} (*) or {\tt cos}\index{trigsimp ! sin}\index{trigsimp ! cos}
  41. \item {\tt sinh} (*) or {\tt cosh}\index{trigsimp ! sinh}\index{trigsimp ! cosh}
  42. \item {\tt expand} (*) or {\tt combine} or {\tt compact}\index{trigsimp ! expand}\index{trigsimp ! combine}\index{trigsimp ! compact}
  43. \item {\tt hyp} or {\tt trig} or {\tt expon}\index{trigsimp ! hyp}\index{trigsimp ! trig}\index{trigsimp ! expon}
  44. \item {\tt keepalltrig}\index{trigsimp ! keepalltrig}
  45. \end{enumerate}
  46. From each group one can use at most one option, otherwise an error
  47. message will occur. The first group fixes the preference used while
  48. transforming a trigonometric expression.
  49. The second group is the equivalent for the hyperbolic functions.
  50. The third group determines the type of transformations. With
  51. the default {\tt expand}, an expression is written in a form only using
  52. single arguments and no sums of arguments. With {\tt combine},
  53. products of trigonometric functions are transformed to trigonometric
  54. functions involving sums of arguments.
  55. \begin{verbatim}
  56. trigsimp(sin(x)^2,cos);
  57. 2
  58. - cos(x) + 1
  59. trigsimp(sin(x)*cos(y),combine);
  60. sin(x - y) + sin(x + y)
  61. -------------------------
  62. 2
  63. \end{verbatim}
  64. With {\tt compact}, the \REDUCE\ operator {\tt compact} (see
  65. chapter~\ref{COMPACT}) is applied to {\tt f}.
  66. This leads often to a simple form, but in contrast to {\tt expand} one
  67. doesn't get a normal form.
  68. \begin{verbatim}
  69. trigsimp((1-sin(x)**2)**20*(1-cos(x)**2)**20,compact);
  70. 40 40
  71. cos(x) *sin(x)
  72. \end{verbatim}
  73. With the fourth group each expression is transformed to a
  74. trigonometric, hyperbolic or exponential form:
  75. \begin{verbatim}
  76. trigsimp(sin(x),hyp);
  77. - sinh(i*x)*i
  78. trigsimp(e^x,trig);
  79. x x
  80. cos(---) + sin(---)*i
  81. i i
  82. \end{verbatim}
  83. Usually, {\tt tan}, {\tt cot}, {\tt sec}, {\tt csc} are expressed in terms of
  84. {\tt sin} and {\tt cos}. It can
  85. be sometimes useful to avoid this, which is handled by the option
  86. {\tt keepalltrig}:
  87. \begin{verbatim}
  88. trigsimp(tan(x+y),keepalltrig);
  89. - (tan(x) + tan(y))
  90. ----------------------
  91. tan(x)*tan(y) - 1
  92. \end{verbatim}
  93. It is possible to use the options of different groups simultaneously.
  94. \section{Factorising trigonometric expressions}
  95. With {\tt trigfactorize(p,x)} one can factorise the trigonometric or
  96. hyperbolic polynomial {\tt p} with respect to the argument x. Example:
  97. \ttindex{trigfactorize}
  98. \begin{verbatim}
  99. trigfactorize(sin(x),x/2);
  100. x x
  101. {2,cos(---),sin(---)}
  102. 2 2
  103. \end{verbatim}
  104. If the polynomial is not coordinated or balanced the output will equal
  105. the input. In this case, changing the value for x can help to find a
  106. factorisation:
  107. \begin{verbatim}
  108. trigfactorize(1+cos(x),x);
  109. {cos(x) + 1}
  110. trigfactorize(1+cos(x),x/2);
  111. x x
  112. {2,cos(---),cos(---)}
  113. 2 2
  114. \end{verbatim}
  115. \section{GCDs of trigonometric expressions}
  116. The operator {\tt triggcd}\ttindex{triggcd} is an application of {\tt
  117. trigfactorize}. With its help the user can find the greatest common
  118. divisor of two trigonometric or hyperbolic polynomials. The syntax is: {\tt
  119. triggcd(p,q,x)}, where p and q are the polynomials and x is the
  120. smallest unit to use. Example:
  121. \begin{verbatim}
  122. triggcd(sin(x),1+cos(x),x/2);
  123. x
  124. cos(---)
  125. 2
  126. triggcd(sin(x),1+cos(x),x);
  127. 1
  128. \end{verbatim}
  129. See also the ASSIST package (chapter~\ref{ASSIST}).