Difference between revisions of "COS"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
imported>Clippy
Line 10: Line 10:
COS(x) is calculated in either single or double precision depending on its argument.   
COS(x) is calculated in either single or double precision depending on its argument.   


COS(4)  
: COS(4)  
-.6536436
: -.6536436


COS(4#)
: COS(4#)
-.6536436208636119
: -.6536436208636119


'''Example 1:'''
'''Example 1:'''


X=2*COS(.4)
: X = 2 * COS(.4)
PRINT X
: PRINT X
 
''Result:'' 1.842122
 


RUN
1.842122
'''Example 2:'''
'''Example 2:'''


PI=3.141593
: PI = 3.141593
PRINT COS(PI)
: PRINT COS(PI)
DEGREES=180
: DEGREES = 180
RADIANS=DEGREES*PI/180
: RADIANS = DEGREES * PI / 180
PRINT COS(RADIANS)
: PRINT COS(RADIANS)
 
''Result:''


RUN
: -1
-1
: -1
-1





Revision as of 19:12, 7 September 2009

Purpose: To return the cosine of the of a radian angle.

Syntax: COS(x)

Comments: x must be the radians. COS is the trigonometric cosine function. To convert from degrees to radians, multiply by π/180.

COS(x) is calculated in either single or double precision depending on its argument.

COS(4)
-.6536436
COS(4#)
-.6536436208636119

Example 1:

X = 2 * COS(.4)
PRINT X

Result: 1.842122


Example 2:

PI = 3.141593
PRINT COS(PI)
DEGREES = 180
RADIANS = DEGREES * PI / 180
PRINT COS(RADIANS)

Result:

-1
-1


See also: SIN, ATN, TAN


Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage