Trigonometric functions: Difference between revisions

Content added Content deleted
(→‎{{header|Kotlin}}: made the Kotlin example not use Java)
No edit summary
Line 5,118: Line 5,118:
0.785398163397448 45
0.785398163397448 45
</pre>
</pre>

=={{header|SparForte}}==
As a structured script.
<syntaxhighlight lang="ada">#!/usr/local/bin/spar
pragma annotate( summary, "trig" )
@( description, "If your language has a library or built-in " )
@( description, "functions for trigonometry, show examples of: ")
@( description, "sine, cosine, tangent, inverses (of the above) " )
@( description, "using the same angle in radians and degrees." )
@( description, "" )
@( description, "For the non-inverse functions, each radian/" )
@( description, "degree pair should use arguments that evaluate to " )
@( description, "the same angle (that is, it's not necessary to " )
@( description, "use the same angle for all three regular " )
@( description, "functions as long as the two sine calls use the " )
@( description, "same angle). For the inverse functions, use " )
@( description, "the same number and convert its answer to radians " )
@( description, "and degrees." )
@( category, "tutorials" )
@( author, "Ken O. Burtch" )
@( see_also, "http://rosettacode.org/wiki/Trigonometric_functions" );
pragma license( unrestricted );

pragma software_model( nonstandard );
pragma restriction( no_external_commands );

procedure trig is
degrees_cycle : constant float := 360.0;
radians_cycle : constant float := 2.0 * float( numerics.pi );
angle_degrees : constant float := 45.0;
angle_radians : constant float := float( numerics.pi ) / 4.0;
begin
put( "Sin " )
@( numerics.sin( angle_degrees, degrees_cycle ) )
@( numerics.sin( angle_radians, radians_cycle ) );
new_line;

put( "Cos " )
@( numerics.cos( angle_degrees, degrees_cycle ) )
@( numerics.cos( angle_radians, radians_cycle ) );
new_line;

put( "Tan " )
@( numerics.tan( angle_degrees, degrees_cycle ) )
@( numerics.tan( angle_radians, radians_cycle ) );
new_line;

put( "Cot " )
@( numerics.cot( angle_degrees, degrees_cycle ) )
@( numerics.cot( angle_radians, radians_cycle ) );
new_line;

put( "Arcsin" )
@( numerics.arcsin( numerics.sin( angle_degrees, degrees_cycle ), degrees_cycle ) )
@( numerics.arcsin( numerics.sin( angle_radians, radians_cycle ), radians_cycle ) );
new_line;

put( "Arccos" )
@( numerics.arccos( numerics.cos( angle_degrees, degrees_cycle ), degrees_cycle ) )
@( numerics.arccos( numerics.cos( angle_radians, radians_cycle ), radians_cycle ) );
new_line;

put( "Arctan" )
@( numerics.arctan( numerics.tan( angle_degrees, degrees_cycle ), 1, degrees_cycle ) )
@( numerics.arctan( numerics.tan( angle_radians, radians_cycle ), 1, radians_cycle ) );
new_line;

put( "Arccot" )
@( numerics.arccot( numerics.cot( angle_degrees, degrees_cycle ), 1, degrees_cycle ) )
@( numerics.arccot( numerics.cot( angle_radians, radians_cycle ), 1, radians_cycle ) );
new_line;

command_line.set_exit_status( 0 );
end trig;</syntaxhighlight>
{{out}}
<pre>
$ spar trig
Sin 7.07106781186547E-01 7.07106781186547E-01
Cos 7.07106781186547E-01 7.07106781186548E-01
Tan 1.00000000000000E+00 9.99999999999998E-01
Cot 1.00000000000000E+00 1.00000000000000E+00
Arcsin 4.50000000000000E+01 7.85398163397448E-01
Arccos 4.50000000000000E+01 7.85398163397448E-01
Arctan 45 7.85398163397448E-01
Arccot 45 7.85398163397449E-01</pre>


=={{header|SQL PL}}==
=={{header|SQL PL}}==