Open In App

Different uses of cosine function in Julia – cospi() and cosc() Method

Improve
Improve
Like Article
Like
Save
Share
Report
The cospi() is an inbuilt function in julia which is used to compute the value of $\cos(\pi x)$ which is more accurately than cos(\pi*x), where x is the large value.
Syntax: cospi(x) Parameters:
  • x: Specified large value.
Returns: It returns the value of $\cos(\pi x)$ which is more accurately than cos(\pi*x).
Example:
# Julia program to illustrate 
# the use of cospi() method
  
# Getting the value of cos(pi x)
println(cospi(55))
println(cospi(22.7))
println(cospi(3.17))
println(cospi(22 / 7))

                    
Output:
-1.0
-0.5877852522924714
-0.8607420270039438
-0.9009688679024193

cosc()

The cosc() is an inbuilt function in julia which is used to compute the value of $\cos(\pi x) / x - \sin(\pi x) / (\pi x^2)$ which is the derivative of sinc(x).
Syntax: cosc(x) Parameters:
  • x: Specified value.
Returns: It returns the value of $\cos(\pi x) / x - \sin(\pi x) / (\pi x^2)$.
Example:
# Julia program to illustrate 
# the use of cosc() method
  
# Getting the value of cos(pi x)/x-sin(pi x)/(pi x ^ 2)
println(cosc(0))
println(cosc(1))
println(cosc(3.14))
println(cosc(22 / 7))

                    
Output:
0.0
-1.0
-0.27441551248588253
-0.2726897540491998


Last Updated : 21 Apr, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads