Trigonometric functions: Difference between revisions
Content deleted Content added
added scheme |
m →{{header|BASIC}}: Syntax highlighting |
||
Line 57: | Line 57: | ||
{{works with|QuickBasic|4.5}} |
{{works with|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]. |
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]. |
||
⚫ | |||
radians = pi / 4 'a.k.a. 45 degrees |
|||
⚫ | |||
degrees = 45 * pi / 180 'convert 45 degrees to radians once |
|||
⚫ | |||
degrees = 45 * pi / 180 'convert 45 degrees to radians once |
|||
PRINT COS(radians) + " " + COS(degrees) 'cosine |
|||
PRINT TAN(radians) + " " + TAN (degrees) 'tangent |
|||
⚫ | |||
⚫ | |||
arcsin = 2 * ATN(SIN(radians)) * radians / (1 + SQR(1 - radians ^ 2)) |
|||
⚫ | |||
PRINT arcsin + " " + arcsin * 180 / pi |
|||
⚫ | |||
PRINT arcsin + " " + arcsin * 180 / pi |
|||
arccos = 2 * ATN(COS(radians)) * SQR(1 - radians ^ 2) / (1 + radians) |
|||
⚫ | |||
PRINT arccos + " " + arccos * 180 / pi |
|||
PRINT ATN(TAN(radians)) + " " + ATN(TAN(radians)) * 180 / pi 'arctan</qbasic> |
|||
PRINT ATN(TAN(radians)) + " " + ATN(TAN(radians)) * 180 / pi 'arctan |
|||
=={{header|C}}== |
=={{header|C}}== |