Open In App

Python | sympy.expand_trig() method

Last Updated : 18 Jun, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads