Trigonometric functions: Difference between revisions

Added BASIC example.
(Added BASIC example.)
Line 60:
45.00000 0.78540
</pre>
 
=={{header|BASIC}}==
'''Compiler''': [[QuickBasic]] 4.5
 
QuickBasic 4.5 does not have arcsin and arccos built in. They are defined by identities found [http://en.wikipedia.org/wiki/Arctan#Relationships_among_the_inverse_trigonometric_functions here].
 
pi = 3.141592653589793#
radians = pi / 4 'a.k.a. 45 degrees
degrees = 45 * pi / 180 'convert 45 degrees to radians once
PRINT SIN(radians) + " " + SIN(degrees) 'sine
PRINT COS(radians) + " " + COS(degrees) 'cosine
PRINT TAN(radians) + " " + TAN (degrees) 'tangent
'arcsin
PRINT 2 * ATN * radians / (1 + SQR(1 - radians ^ 2)) + " " + 2 * ATN * (degrees * pi / 180) / (1 + SQR(1 - (degrees * pi / 180) ^ 2))
'arccos
PRINT 2 * ATN * SQR(1 - radians ^ 2) / (1 + radians) + " " + 2 * ATN * SQR(1 - (degrees * pi / 180) ^ 2) / (1 + (degrees * pi / 180))
PRINT ATN(radians) + " " + ATN (degrees) 'arctan
 
=={{header|Forth}}==
Anonymous user