Thursday, May 20, 2010

SQL SERVER – Trigonometric and Logarithmic Functions

Today we will Discuss various Trigonometric  and Logarithmic Functions, which can be consider as Mathematical Functions.  These Trigonometric functions will take the number of radians as an argument. Arguments for ASIN(), ACOS() ranges from –1 and +1.

In order to convert the radians to degrees, we can use the below  formula.

1 Radian = (1 Degree * pi) / 180     where pi=3.14

1. SIN() : Returns the Sine of a Radian expression.

Example : SELECT ROUND(SIN((0*3.14)/180),2) 'SIN 0', ROUND(SIN((90*3.14)/180),2) 'SIN 90'

Output :

image

2. COS() : Returns the Cosine of a Radian expression.

Example : SELECT ROUND(COS((0*3.14)/180),2) 'COS 0', ROUND(COS((90*3.14)/180),2) 'COS 90'

Output :

image

3. TAN() : Returns the Tangent of a Radian expression.

Example : SELECT ROUND(TAN((0*3.14)/180),2) 'TAN 0', ROUND(TAN((45*3.14)/180),2) 'TAN 45'

Output :

image

4. COT() : Returns the CoTangent of a Radian expression.

Example : SELECT ROUND(COT((90*3.14)/180),2) 'COT 90', ROUND(COT((45*3.14)/180),2) 'COT 45'

Output :

image

5. ASIN() : Returns the ArcSine of a Radian expression.

Example : SELECT ASIN(-.54) 'ASIN -.54'

Output :

image

6. ACOS() : Returns  ArcCoSine of a Radian expression.

Example : SELECT ACOS(-.54) 'ACOS -.54'

Output :

image

7. ATAN() : Returns  ArcTangent of a Radian expression.

Example : SELECT ATAN(4) 'ATAN 4'

Output :

image

8. ATN2() : Returns  the angular component of the polar coordinates (r, q) associated with (x, y)

Example : SELECT ATN2(35.17,150.2) 'ATN2 Value'

Output :

image

9. PI() :  Returns the Constant value of the PI i.e 22/7(3.14)

Example : SELECT PI() 'PI Value'

Output :

image

10. DEGREES() & RADIANS() : Used to convert among themselves i.e. From Degrees to Radians and From Radians to Degrees.

Example : SELECT DEGREES(PI() /2) 'Radians' ,        RADIANS(180/PI()) 'Degrees'

Output :

image

11. EXP() : Returns the Exponent value of specified float expression or Natural Logarithm.

Example : SELECT EXP(1) 'Exponent Value', EXP(LOG (20)) 'Exponent Of Log'

Output :

image

12. LOG() : Returns the Natural Logarithm value of specified float expression or Exponent value.

Example : SELECT LOG (10) 'Log Value', LOG(EXP (20)) 'Log of Exponent'

Output :

image

13. LOG10() : Returns the Logarithm value of Base 10.

Example : SELECT LOG10 (100) 'Log 100 Base 10'

Output :

image

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.