Anonymous user
Trigonometric functions: Difference between revisions
→{{header|Run BASIC}}
m (→{{header|REXX}}: optimized some of the subroutines.) |
|||
Line 3,606:
=={{header|Run BASIC}}==
<lang runbasic>' Find these three ratios: Sine, Cosine, Tangent. (These ratios have NO units.)
' Run BASIC works in radians. Convert deg and rad as shown.▼
rad = deg*d2r▼
deg = 45.0
print "Ratios for a "; deg; " degree angle, (or "; rad; " radian angle.)"
print "
print "
print "
{{out}}▼
<pre>Sine: 0.707106781 0.707106781▼
Cosine: 0.707106781 0.707106781▼
Tangent: 1.0 1.0▼
print "Inverse Functions - - (Using above ratios)"
' Now, use those ratios to work backwards to show their original angle in radians.
' Also, use this: rad / (atn(1)/45) = deg (To change radians to degrees.)
print "Arcsine: "; ASN(SIN(rad)); " radians, (or "; ASN(SIN(rad))/(atn(1)/45); " degrees)"
print "Arccosine: "; ACS(COS(rad)); " radians, (or "; ACS(COS(rad))/(atn(1)/45); " degrees)"
print "Arctangent: "; ATN(TAN(rad)); " radians, (or "; ATN(TAN(rad))/(atn(1)/45); " degrees)"
' This code also works in Liberty BASIC
</lang>
▲{{out}}
<pre>Ratios for a 45.0 degree angle, (or 0.785398163 radian angle.)
Inverse Functions - - (Using above ratios)
Arcsine: 0.785398163 radians, (or 45.0 degrees)
Arccosine: 0.785398163 radians, (or 45.0 degrees)
|