Ask Your Question
0

Expansion cos(3x)

asked 2024-10-11 13:15:20 +0200

antrock1999 gravatar image

Is there a way in the Sagemath language to expand expression like cos(n*x) in terms of sin(x) and cos(x)?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2024-10-11 13:37:43 +0200

Emmanuel Charpentier gravatar image

updated 2024-10-11 13:47:47 +0200

Well...

sage: cos(3*x).trig_expand()
cos(x)^3 - 3*cos(x)*sin(x)^2

Sage has a lot of tutorials ; a (somewhat helicopteric) tour of Sage, a main tutorial, and many more indexed here. There is also an excellent (while slightly outdated) book introducing a lot of Sage concepts in various branches of mathematical computing (warmingly recommended).

The reference manual is also easily accessible "inline" : typing

sage: x.trig_expand?

displays about 4 screenfuls of description and examples, starting with :

Docstring:     
   Expand trigonometric and hyperbolic functions of sums of angles and
   of multiple angles occurring in "self".

   For best results, "self" should already be expanded.

   INPUT:

   * "full" -- boolean (default: "False"); to enhance user control of
     simplification, this function expands only one level at a time by
     default, expanding sums of angles or multiple angles. To obtain
     full expansion into sines and cosines immediately, set the
     optional parameter full to "True".

   * "half_angles" -- boolean (default: "False"); if "True", causes
     half-angles to be simplified away

   * "plus" -- boolean (default: "True"); controls the sum rule.
     Expansion of sums (e.g. \sin(x + y)) will take place only if
     "plus" is "True".

   * "times" -- boolean (default: "True"); controls the product rule,
     expansion of products (e.g. \sin(2 x)) will take place only if

[ elided... ]

In other words, RTFM...

HTH,

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2024-10-11 13:15:20 +0200

Seen: 55 times

Last updated: Oct 11