home *** CD-ROM | disk | FTP | other *** search
-
- (*********************************************************************
-
- Adapted from
- Roman E. Maeder: Programming in Mathematica,
- Second Edition, Addison-Wesley, 1991.
-
- *********************************************************************)
-
-
- BeginPackage["TrigDefine`"]
-
- TrigDefine::usage = "TrigDefine.m defines global rules for putting
- products of trigonometric functions into normal form."
-
- Begin["`Private`"] (* set the private context *)
-
- (* unprotect any system functions for which rules will be defined *)
-
- protected = Unprotect[Sin, Cos, Tan]
-
- (* linearization *)
-
- Sin/: Sin[x_] Cos[y_] := Sin[x+y]/2 + Sin[x-y]/2
- Sin/: Sin[x_] Sin[y_] := Cos[x-y]/2 - Cos[x+y]/2
- Cos/: Cos[x_] Cos[y_] := Cos[x+y]/2 + Cos[x-y]/2
-
- Sin/: Sin[x_]^n_Integer?Positive := Expand[(1/2 - Cos[2x]/2) Sin[x]^(n-2)]
- Cos/: Cos[x_]^n_Integer?Positive := Expand[(1/2 + Cos[2x]/2) Cos[x]^(n-2)]
-
- Protect[ Evaluate[protected] ] (* restore protection of system symbols *)
-
- End[] (* end the private context *)
-
- EndPackage[] (* end the package context *)
- (*********************************************************************
-
- Adapted from
- Roman E. Maeder: Programming in Mathematica,
- Second Edition, Addison-Wesley, 1991.
-
- *********************************************************************)
-
-
- BeginPackage["TrigDefine`"]
-
- TrigDefine::usage = "TrigDefine.m defines global rules for putting
- products of trigonometric functions into normal form."
-
- Begin["`Private`"] (* set the private context *)
-
- (* unprotect any system functions for which rules will be defined *)
-
- protected = Unprotect[Sin, Cos, Tan]
-
- (* linearization *)
-
- Sin/: Sin[x_] Cos[y_] := Sin[x+y]/2 + Sin[x-y]/2
- Sin/: Sin[x_] Sin[y_] := Cos[x-y]/2 - Cos[x+y]/2
- Cos/: Cos[x_] Cos[y_] := Cos[x+y]/2 + Cos[x-y]/2
-
- Sin/: Sin[x_]^n_Integer?Positive := Expand[(1/2 - Cos[2x]/2) Sin[x]^(n-2)]
- Cos/: Cos[x_]^n_Integer?Positive := Expand[(1/2 + Cos[2x]/2) Cos[x]^(n-2)]
-
- Protect[ Evaluate[protected] ] (* restore protection of system symbols *)
-
- End[] (* end the private context *)
-
- EndPackage[] (* end the package context *)
-