Trigonometric functions: Difference between revisions

Content added Content deleted
Line 967: Line 967:
=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==
<lang lb>' [RC] Trigonometric functions.
<lang lb>' [RC] Trigonometric functions.
' Liberty Basic works in radians. All six functions are available.
global pi
pi = 4 *atn( 1)
' Optional information. You 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.

value =45
2 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
print " Trig. functions and their inverses."
print using( "####.###############", sin( Rad)); " = sine"
print using( "####.###############", cos( Rad)); " = cosine"
print using( "####.##############", tan( Rad)); " = tangent"
print
print
print " Trig. for angle 45 in radians and degrees."
print " Now the inverses --"
print "For the 'sine' above, the 'arcsine' is --";
print
print , " 45 radians", "45 degrees"
print using("####.####", (asn ( sin ( Rad))) * 57.29577951) ; " degrees"
print " ( or," ; using("####.###############",asn ( sin ( Rad)));" radians ) "

print " Sin", sin( value), sin( degrees2radians( value))
print "For the 'cosine' above, the 'arccosine' is --";
print " Cos", cos( value), cos( degrees2radians( value))
print using("####.####", (acs ( cos ( Rad))) * 57.29577951) ; " degrees"
print " Tan", tan( value), tan( degrees2radians( value))
print " ( or," ; using("####.###############",acs ( cos ( 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}}==
=={{header|Logo}}==