Python | sympy.expand_trig() method
With the help of sympy.expand_trig(expn) method, we are able to expand the trigonometric equations.
Syntax :
sympy.expand_trig(expn)
Return : Return the expanded trigonometric expression.
Example #1 :
In this example we can see that by using sympy.expand_trig(expn) method, we are able to find the expanded form of trigonometric function.
# Import sympy from sympy import * # Define symbols and trigo expression x, y = symbols('x y') expn = sin(2 * x) + cos(2 * x) # Use sympy.expand_trig(expn) method gfg = expand_trig(expn) print(gfg) |
Output :
2*sin(x)*cos(x) + 2*cos(x)**2 – 1
Example #2 :
# Import sympy from sympy import * # Define symbols and trigo expression x, y = symbols('x y') expn = sin(2 * x)**2 + cos(2 * x)**2 # Use sympy.expand_trig(expn) method gfg = expand_trig(expn) print(gfg) |
Output :
(2*cos(x)**2 – 1)**2 + 4*sin(x)**2*cos(x)**2
Recommended Posts:
- class method vs static method in Python
- Python | next() method
- Python | os.dup() method
- Python | set() method
- Python | os.getsid() method
- Python | os.chroot() method
- Python | sympy.lcm() method
- Python | os.setregid() method
- Python | os.pwrite() method
- Python | PyTorch tan() method
- Python | getattr() method
- Python | os.fchmod() method
- Python | os.fork() method
- Python | os.confstr() method
- Python | os.nice() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

