Home arrow MySQL arrow Page 2 - Optimizing Queries with Operators, Branching and Functions, continued

Trigonometric Functions - MySQL

This article will give you a good grounding in operators, branching and functions in MySQL, so you can make the database, instead of your own code, do the bulk of the work. It is the second of three parts, and excerpted from chapter four of Beginning MySQL Database Design and Optimization: From Novice to Professional, written by Jon Stephens and Chad Russell (Apress; ISBN: 1590593324).

TABLE OF CONTENTS:
  1. Optimizing Queries with Operators, Branching and Functions, continued
  2. Trigonometric Functions
  3. Other Math Functions
  4. Conversion of Numbers Between Bases
  5. String Functions and Regular Expressions
  6. Pattern-Matching and Regular Expressions
By: Apress Publishing
Rating: starstarstarstarstar / 6
April 06, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The trigonometric functions are useful for calculating lengths, arcs, and angles, as well as plotting curves and performing complex calculations involving waves.


NOTE
 We won’t attempt to provide definitions or to explain trigonometry here. If you don’t already know what they are or how to use them, check out the MathWorld web site, starting from
http://mathworld.wolfram.com/Trigonometry. html.

MySQL provides the following trigonometric functions, where X is an angle expressed in radians:

SIN(X): Sine of X

COS(X): Cosine of X

TAN(X): Tangent of X

COT(X): Cotangent of X


NOTE 
The secant and cosecant trigonometric functions (often written as sec and csc in mathematical notation) can be obtained in MySQL by using the expressions 1 / COS(X) and 1 / SIN(X) , respectively.

The radian is a unit of angular measure defined such that 180 degrees is equal to p (pi) radians. (The number p is represented in MySQL as PI().) To convert radians to degrees, you can use the DEGREES() function, and to convert from degrees to radians, use the RADIANS() function.

The inverse trigonometric functions all return angle values expressed in radians:

ASIN(X): Arcsine of X

ACOS(X): Arccosine of X

ATAN(X): Arctangent of X

ATAN(X,  Y) or ATAN2(X,  Y): Arctangent of Y / X


NOTE
   MySQL stores p and e as double-precision floating-point values. This should be of sufficient accuracy for 99% of all applications requiring the use of these values.

 



 
 
>>> More MySQL Articles          >>> More By Apress Publishing
 

blog comments powered by Disqus
   

MYSQL ARTICLES

- Xeround Releases Free Version of MySQL Cloud...
- Oracle Announces New MySQL Specialization
- Constant Contact Chooses SkySQL for MySQL Su...
- Revoke Statement in MySQL
- The Grant Statement in MySQL
- SuccessBricks Announces ClearDB Availability...
- Building a PHP ORM: Deploying a Blog
- TROSYS Launches Free MySQL Manager and Admin...
- Building an ORM in PHP: Domain Modeling
- Building an ORM in PHP
- MySQL Leads Open Source Market, Gets Cluster...
- Oracle Announces Milestone Release for MySQL
- How to Stop SQL Injection Attacks
- New Defragmentation Solution for SQL Server
- Comparison of MyISAM and InnoDB MySQL Databa...


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap

Dev Shed Tutorial Topics: