Cos

Description

Returns the cosine of an angle, in radians.

Category

Mathematical functions

Syntax


Cos(number) 

See also

Sin, Tan, Pi

Parameters

Parameter
Description
number
Angle, in radians, for which you want the cosine

Usage

The range of the result is -1 to 1.

To convert degrees to radians, multiply degrees by π/180. To convert radians to degrees, multiply radians by 180/π.

Example

<!--- This snippet shows how to use Cos --->

<html>

<head>

<title>Cos Example</title>

</head>

<body bgcolor = silver>

<H3>Cos Example</H3>



<!--- output its Cos value --->

<cfif IsDefined("FORM.CosNum")>

  <cfif IsNumeric(#FORM.CosNum#)>

    Cos(<cfoutput>#FORM.CosNum#</cfoutput>) = 

    <cfoutput>#Cos(FORM.cosNum)# 

    radians = #Evaluate(Cos(FORM.cosNum) * 180/PI())#

    Degrees</cfoutput>

  <cfelse>

<!--- if it is empty, output an error message --->

    <H4>Please enter a number between -1 and 1</H4>

  </cfif>

</cfif>



<form action = "cos.cfm" method = "POST">

<P>Type in a number to get its cosine in Radians and Degrees

<BR><input type = "Text" name = "cosNum" size = "25">

<P><input type = "Submit" name = ""> <input type = "RESET">

</FORM>

</body>

</html>    



Banner.Novgorod.Ru