Cos

Description

Cosine function.

Return value

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 to calculate 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

<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>Enter a number between -1 and 1</h4>
  </cfif>
</cfif>
<form action = "cos.cfm" method="post">
<p>Enter 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>

Comments