Saturday, December 28, 2024
Google search engine
HomeLanguagesPython | sympy.cos() method

Python | sympy.cos() method

In sympy, cos() method is cosine function. Using the cos(x) method in the sympy module, we can compute the cosine of x.

Syntax : sympy.cos(x)

Return : Returns the cosine of x 

Code #1: Below is the example using cos() method to find cosine function. 

Python3




# importing sympy library
from sympy import *
 
# calling cos() method on expression
geek1 = cos(-1)
geek2 = cos(pi / 3)
geek3 = cos(pi)
 
print(geek1)
print(geek2)
print(geek3)


Output: 

cos(1)
1/2
-1

  Code #2: 

Python3




# importing sympy library
from sympy import *
 
 
# calling cos() method on expression
geek = cos(2 + 5j)
print(geek)


Output: 

-30.8822353189167 - 67.4727884405875*I
RELATED ARTICLES

Most Popular

Recent Comments