< Perl Programming < Keywords

The cos keyword

cos is the trigonometric function cose that assumes that X is in radians.

Syntax

  cos(X)

Examples

The code
*PI = \3.1415926535;
$a = 30;	# in degrees
$cos = cos($a/180*$PI);

print "cos(" . $a . "°) = " . $cos . "\n";
prints the cosine of the angle of 30 degrees:
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.