- Perl ›
- builtin functions ›
- here

## cos function - find cosine

You can use the ** cos function ** to find the cosine. The angle is easy to specify in radians using π (pi function).

use Math::Trig 'pi'; cos(pi/3);

The pi function to get π in radians is explained in Math::Trig.

### Cos function programming example

This is a programming example using the cos function.

use strict; use warnings; use Math::Trig 'pi'; # cos(60 °) = 1/2; print "cos(π/3) =" . Cos (pi/3) . "\n";

### Other trigonometric functions

Perl has sin function as builtin functions in addition to the cos function.

Details on how to use other trigonometric functions such as tangent can be found on the following pages.