Pi in R
Pi is a built-in R constant whose value is 3.141593. The pi constant is the ratio of the circumference of a circle to its diameter. When you define a pi, please note that p of pi is in lowercase.
Syntax
pi
Example
print(pi)
Output
[1] 3.141593
The value of the pi constant in R is 3.141593.
Calculate the exponential value of pi in R
To calculate the exponential value of pi in R, you can use the exp() function.
[1] 23.14069
Output
[1] 23.14069
Calculate the cos value of pi
To calculate the cosine value of pi in R, you can use the cos() function.
cos(pi)
Output
[1] -1
Find the sine value of pi.
To find the sine value of pi in R, you can use the sin() function.
sin(pi)
Output
[1] 1.224647e-16
Find the tangent of pi in R
To calculate the tangent of pi in R, you can use the tan() function.
tan(pi)
Output
[1] -1.224647e-16
Compute the arccos value of pi
To calculate the arccos value of pi in R, use the acos() function.
acos(pi)
Output
[1] NaN
Warning message:
In acos(pi) : NaNs produced
It returns the NaN value.
Compute the arcsin value of pi
To calculate the arccos value of pi in R, use the asin() function.
asin(pi)
Output
[1] NaN
Warning message:
In asin(pi) : NaNs produced
It returns NaN too.
Compute the arctan value of pi
To calculate the arccos value of pi in R, use the atan() function.
atan(pi)
Output
[1] 1.262627
sinpi() in R
The sinpi() function in R is used to compute the sine value of the input, which is the multiple of pi.
Syntax
sinpi(x)
Parameters
The sinpi() function takes x as a numeric value, array, or vector.
Example
sinpi(0.75)
sinpi(0.5)
sinpi(1)
Output
[1] 0.7071068
[1] 1
[1] 0
Example 2
sinpi(1 / 4)
sinpi(1 / 5)
sinpi(2 / 5)
Output
[1] 0.7071068
[1] 0.5877853
[1] 0.9510565
That is it for the universal constant pi in R.

Krunal Lathiya is a Software Engineer with over eight years of experience. He has developed a strong foundation in computer science principles and a passion for problem-solving. In addition, Krunal has excellent knowledge of Data Science and Machine Learning, and he is an expert in R Language.