Perl Newbies

  1. Perl
  2. Functions
  3. here

sin function - calculate the sine value

sin function calculates the sine value. The angle is specified by arc degree method using π (pi function).

use Math::Trig 'pi';

sin(pi/2);

The pi function is defined in Math::Trig module.

sin function programming example

The following is a sin function programming example.

use strict;
use warnings;
use Math::Trig 'pi';

# sin(90°) = 1;
print "sin(π/2) = " . sin(pi/2) . "\n";

Other trigonometric functions

Perl also has cos function in core functions.

The following article explains how to use other trigonometric functions such as tangent.

Menu