0% found this document useful (0 votes)
93 views5 pages

Math - Cos Method Double : Syntax

The Math.Cos method returns the cosine of a specified angle measured in radians. It takes a double parameter representing the angle and returns a double value for the cosine. Acceptable angle values range from approximately -9223372036854775295 to 9223372036854775295 radians. The method is static and defined in the System namespace in the mscorlib assembly.

Uploaded by

Faizal Amiruddin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views5 pages

Math - Cos Method Double : Syntax

The Math.Cos method returns the cosine of a specified angle measured in radians. It takes a double parameter representing the angle and returns a double value for the cosine. Acceptable angle values range from approximately -9223372036854775295 to 9223372036854775295 radians. The method is static and defined in the System namespace in the mscorlib assembly.

Uploaded by

Faizal Amiruddin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Math.

Cos Method Double


.NET Framework 4.6 and 4.5

Returns the cosine of the specified angle.


Namespace: System
Assembly: mscorlib in mscorlib.dll

Syntax
VB
PublicSharedFunctionCos(

dAsDouble
)AsDouble

Parameters
d

Type: System.Double
An angle, measured in radians.

Return Value
Type: System.Double
The cosine of d. If d is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN.

Remarks
The angle, d, must be in radians. Multiply by Math.PI/180 to convert degrees to radians.
Acceptable values of d range from approximately 9223372036854775295 to approximately
9223372036854775295. For values outside this range, the Cos method returns d unchanged rather than throwing
an exception.

Examples
The following example uses Cos to evaluate certain trigonometric identities for selected angles.
VB
'ExampleforthetrigonometricMath.Sin(Double)andMath.Cos(Double)methods.
ImportsSystem
ImportsMicrosoft.VisualBasic

ModuleSinCos
SubMain()
Console.WriteLine(_
"Thisexampleoftrigonometric"&_
"Math.Sin(double)andMath.Cos(double)"&vbCrLf&_
"generatesthefollowingoutput."&vbCrLf)
Console.WriteLine(_
"ConvertselectedvaluesforXtoradians"&vbCrLf&_
"andevaluatethesetrigonometricidentities:")
Console.WriteLine(_
"sin^2(X)+cos^2(X)=1"&vbCrLf&_
"sin(2*X)=2*sin(X)*cos(X)")
Console.WriteLine("cos(2*X)=cos^2(X)sin^2(X)")
UseSineCosine(15.0)
UseSineCosine(30.0)
UseSineCosine(45.0)
Console.WriteLine(_
vbCrLf&"ConvertselectedvaluesforXandYtoradians"&_
vbCrLf&"andevaluatethesetrigonometricidentities:")
Console.WriteLine("sin(X+Y)=sin(X)*cos(Y)+cos(X)*sin(Y)")
Console.WriteLine("cos(X+Y)=cos(X)*cos(Y)sin(X)*sin(Y)")
UseTwoAngles(15.0,30.0)
UseTwoAngles(30.0,45.0)
EndSub'Main
'Evaluatetrigonometricidentitieswithagivenangle.
SubUseSineCosine(degreesAsDouble)
DimangleAsDouble=Math.PI*degrees/180.0
DimsinAngleAsDouble=Math.Sin(angle)
DimcosAngleAsDouble=Math.Cos(angle)
'Evaluatesin^2(X)+cos^2(X)=1.
Console.WriteLine(_
vbCrLf&"Math.Sin({0}deg)={1:E16}"&_
vbCrLf&"Math.Cos({0}deg)={2:E16}",_
degrees,Math.Sin(angle),Math.Cos(angle))
Console.WriteLine(_
"(Math.Sin({0}deg))^2+(Math.Cos({0}deg))^2={1:E16}",_
degrees,sinAngle*sinAngle+cosAngle*cosAngle)
'Evaluatesin(2*X)=2*sin(X)*cos(X).
Console.WriteLine(_
"Math.Sin({0}deg)={1:E16}",_
2.0*degrees,Math.Sin(2.0*angle))
Console.WriteLine(_
"2*Math.Sin({0}deg)*Math.Cos({0}deg)={1:E16}",_
degrees,2.0*sinAngle*cosAngle)
'Evaluatecos(2*X)=cos^2(X)sin^2(X).
Console.WriteLine(_
"Math.Cos({0}deg)={1:E16}",_
2.0*degrees,Math.Cos(2.0*angle))

Console.WriteLine(_
"(Math.Cos({0}deg))^2(Math.Sin({0}deg))^2={1:E16}",_
degrees,cosAngle*cosAnglesinAngle*sinAngle)
EndSub'UseSineCosine
'Evaluatetrigonometricidentitiesthatarefunctionsoftwoangles.
SubUseTwoAngles(degreesXAsDouble,degreesYAsDouble)
DimangleXAsDouble=Math.PI*degreesX/180.0
DimangleYAsDouble=Math.PI*degreesY/180.0
'Evaluatesin(X+Y)=sin(X)*cos(Y)+cos(X)*sin(Y).
Console.WriteLine(_
vbCrLf&"Math.Sin({0}deg)*Math.Cos({1}deg)+"&_
vbCrLf&"Math.Cos({0}deg)*Math.Sin({1}deg)={2:E16}",_
degreesX,degreesY,Math.Sin(angleX)*Math.Cos(angleY)+_
Math.Cos(angleX)*Math.Sin(angleY))
Console.WriteLine(_
"Math.Sin({0}deg)={1:E16}",_
degreesX+degreesY,Math.Sin(angleX+angleY))
'Evaluatecos(X+Y)=cos(X)*cos(Y)sin(X)*sin(Y).
Console.WriteLine(_
"Math.Cos({0}deg)*Math.Cos({1}deg)"&vbCrLf&_
"Math.Sin({0}deg)*Math.Sin({1}deg)={2:E16}",_
degreesX,degreesY,Math.Cos(angleX)*Math.Cos(angleY)_
Math.Sin(angleX)*Math.Sin(angleY))
Console.WriteLine(_
"Math.Cos({0}deg)={1:E16}",_
degreesX+degreesY,Math.Cos(angleX+angleY))
EndSub'UseTwoAngles
EndModule'SinCos
'ThisexampleoftrigonometricMath.Sin(double)andMath.Cos(double)
'generatesthefollowingoutput.
'
'ConvertselectedvaluesforXtoradians
'andevaluatethesetrigonometricidentities:
'sin^2(X)+cos^2(X)=1
'sin(2*X)=2*sin(X)*cos(X)
'cos(2*X)=cos^2(X)sin^2(X)
'
'Math.Sin(15deg)=2.5881904510252074E001
'Math.Cos(15deg)=9.6592582628906831E001
'(Math.Sin(15deg))^2+(Math.Cos(15deg))^2=1.0000000000000000E+000
'Math.Sin(30deg)=4.9999999999999994E001
'2*Math.Sin(15deg)*Math.Cos(15deg)=4.9999999999999994E001
'Math.Cos(30deg)=8.6602540378443871E001
'(Math.Cos(15deg))^2(Math.Sin(15deg))^2=8.6602540378443871E001
'
'Math.Sin(30deg)=4.9999999999999994E001
'Math.Cos(30deg)=8.6602540378443871E001
'(Math.Sin(30deg))^2+(Math.Cos(30deg))^2=1.0000000000000000E+000
'Math.Sin(60deg)=8.6602540378443860E001
'2*Math.Sin(30deg)*Math.Cos(30deg)=8.6602540378443860E001

'Math.Cos(60deg)=5.0000000000000011E001
'(Math.Cos(30deg))^2(Math.Sin(30deg))^2=5.0000000000000022E001
'
'Math.Sin(45deg)=7.0710678118654746E001
'Math.Cos(45deg)=7.0710678118654757E001
'(Math.Sin(45deg))^2+(Math.Cos(45deg))^2=1.0000000000000000E+000
'Math.Sin(90deg)=1.0000000000000000E+000
'2*Math.Sin(45deg)*Math.Cos(45deg)=1.0000000000000000E+000
'Math.Cos(90deg)=6.1230317691118863E017
'(Math.Cos(45deg))^2(Math.Sin(45deg))^2=2.2204460492503131E016
'
'ConvertselectedvaluesforXandYtoradians
'andevaluatethesetrigonometricidentities:
'sin(X+Y)=sin(X)*cos(Y)+cos(X)*sin(Y)
'cos(X+Y)=cos(X)*cos(Y)sin(X)*sin(Y)
'
'Math.Sin(15deg)*Math.Cos(30deg)+
'Math.Cos(15deg)*Math.Sin(30deg)=7.0710678118654746E001
'Math.Sin(45deg)=7.0710678118654746E001
'Math.Cos(15deg)*Math.Cos(30deg)
'Math.Sin(15deg)*Math.Sin(30deg)=7.0710678118654757E001
'Math.Cos(45deg)=7.0710678118654757E001
'
'Math.Sin(30deg)*Math.Cos(45deg)+
'Math.Cos(30deg)*Math.Sin(45deg)=9.6592582628906831E001
'Math.Sin(75deg)=9.6592582628906820E001
'Math.Cos(30deg)*Math.Cos(45deg)
'Math.Sin(30deg)*Math.Sin(45deg)=2.5881904510252085E001
'Math.Cos(75deg)=2.5881904510252096E001

Version Information
Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

See Also
Math Class
System Namespace

Return to top

2015 Microsoft

You might also like