# Expansion cos(3x)

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

Expansion cos(3x)

add a comment

2

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,

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

Asked: ** 2024-10-11 13:15:20 +0100 **

Seen: **112 times**

Last updated: **Oct 11**

complex exponential/trigonometric

Trigonometric Equation Solving: Not Terminating

Sage cannot simplify arccos, but can simplify arcsin?

Calculus graphing. Urgent help appreciated! [closed]

Simplify produces an incorrect result.

Sage fails to evaluate this expression.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.