# Pi in R Tutorial with Example

There are a few characters “constants” in R and Pi is one of the most used mathematics constants.

## What is Pi in Mathematics

The pi, which is written as the Greek letter for p or π, is the ratio of the circumference of any circle to the diameter of that circle.

The circumference of a circle is equal to pi times the diameter (c = πd).

The pi is an irrational number, meaning that its decimal form neither ends (like 1/4 = 0.25) nor becomes repetitive (like 1/6 = 0.166666…).

Pi is an irrational number that’s crucial to many mathematical formulas.

## Pi in R

Pi is an inbuilt R constant whose value is 3.141593. The pi constant is a 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

`` 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, use the exp() function.

`` 23.14069``

#### Output

`` 23.14069``

## Calculate the cos value of pi

To calculate the cosine value of pi in R, use the cos() function.

``cos(pi)``

#### Output

`` -1``

## Find sine value of pi.

To find the sine value of pi in R, use the sin() function.

``sin(pi)``

#### Output

`` 1.224647e-16``

## Find the tangent of pi in R

To calculate the tangent of pi in R, use the tan() function.

``tan(pi)``

#### Output

`` -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

`````` NaN
Warning message:
In acos(pi) : NaNs produced``````

It returns NaN value.

## Compute the arcsin value of pi

To calculate the arccos value of pi in R, use the asin() function.

``asin(pi)``

#### Output

`````` 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.262627``

## sinpi() in R

The sinpi() function in R is used to compute the sine value of the input, which is the multiples of pi.

### Syntax

``sinpi(x)``

### Parameters

The sinpi() function takes as a numeric value, array, or vector.

### Example

``````sinpi(0.75)
sinpi(0.5)
sinpi(1)``````

#### Output

`````` 0.7071068
 1
 0``````

### Example 2

``````sinpi(1 / 4)
sinpi(1 / 5)
sinpi(2 / 5)``````

#### Output

`````` 0.7071068
 0.5877853
 0.9510565``````

That is it for universal constant pi in R.

Categories R