Trigonometric functions: Difference between revisions

Added an ActionScript version.
No edit summary
(Added an ActionScript version.)
Line 2:
If your language has a library or built-in functions for trigonometry, show examples of sine, cosine, tangent, and their inverses using the same angle in radians and degrees. For the non-inverse functions, each radian/degree pair should use arguments that evaluate to the same angle (that is, it's not necessary to use the same angle for all three regular functions as long as the two sine calls use the same angle). For the inverse functions, use the same number and convert its answer to radians and degrees. If your language does not have trigonometric functions available or only has some available, write functions to calculate the functions based on any [http://en.wikipedia.org/wiki/Trigonometric_function known approximation or identity].
 
=={{header|ActionScript}}==
Actionscript supports basic trigonometric and inverse trigonometric functions via the Math class, including the atan2 function, but not the hyperbolic functions.
<lang ActionScript>trace("Radians:");
trace("sin(Pi/4) = ", Math.sin(Math.PI/4));
trace("cos(Pi/4) = ", Math.cos(Math.PI/4));
trace("tan(Pi/4) = ", Math.tan(Math.PI/4));
trace("arcsin(0.5) = ", Math.asin(0.5));
trace("arccos(0.5) = ", Math.acos(0.5));
trace("arctan(0.5) = ", Math.atan(0.5));
trace("arctan2(-1,-2) = ", Math.atan2(-1,-2));
trace("\nDegrees")
trace("sin(45) = ", Math.sin(45 * Math.PI/180));
trace("cos(45) = ", Math.cos(45 * Math.PI/180));
trace("tan(45) = ", Math.tan(45 * Math.PI/180));
trace("arcsin(0.5) = ", Math.asin(0.5)*180/Math.PI);
trace("arccos(0.5) = ", Math.acos(0.5)*180/Math.PI);
trace("arctan(0.5) = ", Math.atan(0.5)*180/Math.PI);
trace("arctan2(-1,-2) = ", Math.atan2(-1,-2)*180/Math.PI);
</lang>
=={{header|Ada}}==
Ada provides library trig functions which default to radians along with corresponding library functions for which the cycle can be specified. The examples below specify the cycle for degrees and for radians. The output of the inverse trig functions is in units of the specified cycle (degrees or radians).
Anonymous user