Trigonometric functions: Difference between revisions

Content added Content deleted
Line 967:
=={{header|Liberty BASIC}}==
<lang lb>' [RC] Trigonometric functions.
' LBLiberty Basic works in radians. All six functions are available.
global pi
pi' Optional =information. 4 *atn(You 1)may--
' 1. Run as is, for fixed 45 degree 'input'.
 
' 2. Put other degrees ( 0 to 90) into line 2. ( For '90', the tangent = infinity. )
' LB works in radians. All six functions are available.
' 3. 'Shorten' decimal places for less accuracy.
 
' 4. Put radians into line 4. ( 0 to 1.5707963267948966 ). Just delete the 'rem',
mainwin 80 16
' by the Rad example. Now, line 4 data will replace line 2 and 3 data.
 
value2 Deg = 45
3 Rad = Deg / 57.295779513082343
 
4 rem Rad = 1.27
print "When the angle = "; using("####.###", (Rad) * 57.29577951); " degrees,"
print " (or"; using("###.###############", Rad);" radians), then --"
print
print "using( Trig"####.###############", functionssin( andRad)); their" inverses.= sine"
print using( "####.###############", cos( Rad)); " = cosine"
print using( "####.##############", tan( Rad)); " = tangent"
print
print " Trig. for angle 45 in radians and degrees. Now the inverses --"
print "For the 'sine' above, the 'arcsine' is --";
print
print using("####.####", "(asn 45( radians",sin ( Rad))) * 57.29577951) ; "45 degrees"
print " ( or," ; using("####.###############",asn ( sin ( Rad)));" radians ) "
 
print "For Sin",the sin('cosine' value)above, the sin('arccosine' degrees2radians(is value))--";
print using(" Cos####.####", cos(acs value), ( cos( degrees2radians( valueRad))) * 57.29577951) ; " degrees"
print " Tan", tan ( value)or," ; tanusing("####.###############",acs degrees2radians( valuecos ( Rad)));" radians ) "
print "For the 'tangent' above, the 'arctangent' is --";
 
print using("####.####", (atn ( tan ( Rad))) * 57.29577951) ; " degrees"
print
print " ( or," ; using("####.###############",atn ( tan ( Rad)));" radians ) "
print " Inverse trig. for result =0.5"
end
 
'----------- Output -------------
value =0.5
'When the angle = 45.000 degrees,
 
' (or 0.785398163397448 radians), then --
print " asn", asn( value); " radians", radians2degrees( asn( value)); " degrees"
'
print " acs", acs( value); " radians", radians2degrees( acs( value)); " degrees"
' 0.707106781186547 = sine
print " atn", atn( value); " radians", radians2degrees( atn( value)); " degrees"
' 0.707106781186548 = cosine
 
' 1.00000000000000 = tangent
end
'
 
' Now the inverses --
 
'For the 'sine' above, the 'arcsine' is -- 45.0000 degrees
function radians2degrees( r)
' ( or, 0.785398163397448 radians )
radians2degrees =r *360 /2 /pi
'For the 'cosine' above, the 'arccosine' is -- 45.0000 degrees
end function
' ( or, 0.785398163397448 radians )
 
'For the 'tangent' above, the 'arctangent' is -- 45.0000 degrees
function degrees2radians( degrees)
' ( or, 0.785398163397448 radians )
degrees2radians =degrees /360 *2 *pi
end function</lang>
 
=={{header|Logo}}==