PS-Trainer C - Entwicklung
Mathematik: Trigonometrie
Homepage von PS-Trainer - C-Entwicklung - Mathematik - an PS-Trainer
PS-Trainer PS-Trainer

Math and related Trigonometry
sin Calculate the sine and hyperbolic sine.
cos Calculate the cosine.
tan Calculate the tangent or hyperbolic tangent.
asin Calculate the arcsine.
acos Calculate the arccosine.
atan, atan2

Calculate the arctangent of x (atan) or of y/x (atan2).



sin, sinh
Calculate sines and hyperbolic sines.
double sin( double x );
double sinh( double x );


Routine Required Header Compatibility
sin  <math.h> ANSI, Win 95, Win NT
sinh  <math.h>
ANSI, Win 95, Win NT

Subject: Floating-Point Support Routines
Keywords: See also acos, asin, atan, cos, tan
Return Value
sin returns the sine of x. If x is greater than or equal to 263, or less than or equal to –263, a loss of significance in the result occurs, in which case the function generates a _TLOSS error and returns an indefinite (same as a quiet NaN).
sinh returns the hyperbolic sine of x. If the result is too large, sinh sets errno to ERANGE and returns ±HUGE_VAL. You can modify error handling with _matherr.

Parameter
x Angle in radians

Example
/* SINCOS.C: This program displays the sine, hyperbolic
* sine, cosine, and hyperbolic cosine of pi / 2.
*/

#include <math.h>
#include <stdio.h>

void main( void )
{
double pi = 3.1415926535;
double x, y;

x = pi / 2;
y = sin( x );
printf( "sin( %f ) = %f\n", x, y );
y = sinh( x );
printf( "sinh( %f ) = %f\n",x, y );
y = cos( x );
printf( "cos( %f ) = %f\n", x, y );
y = cosh( x );
printf( "cosh( %f ) = %f\n",x, y );
}


Output
sin( 1.570796 ) = 1.000000
sinh( 1.570796 ) = 2.301299
cos( 1.570796 ) = 0.000000
cosh( 1.570796 ) = 2.509178


cos, cosh
 

 


tan, tanh
Calculate the tangent (tan) or hyperbolic tangent (tanh).
double tan( double x );
double tanh( double x );


Routine Required Header Compatibility
tan <math.h> ANSI, Win 95, Win NT
tanh  <math.h> ANSI, Win 95, Win NT

Subject: Floating-Point Support Routines, Long Double Routines
See also acos, asin, atan, cos, sin
Return Value
tan returns the tangent of x. If x is greater than or equal to 263, or less than or equal to –263, a loss of significance in the result occurs, in which case the function generates a _TLOSS error and returns an indefinite (same as a quiet NaN). You can modify error handling with _matherr.
tanh returns the hyperbolic tangent of x. There is no error return.

Parameter
x Angle in radians

Example
/* TAN.C: This program displays the tangent of pi / 4
* and the hyperbolic tangent of the result.
*/

#include <math.h>
#include <stdio.h>

void main( void )
{
double pi = 3.1415926535;
double x, y;

x = tan( pi / 4 );
y = tanh( x );
printf( "tan( %f ) = %f\n", x, y );
printf( "tanh( %f ) = %f\n", y, x );
}

Output
tan( 1.000000 ) = 0.761594
tanh( 0.761594 ) = 1.000000


atan, atan2
Calculates the arctangent of x (atan) or the arctangent of y/x (atan2).
double atan( double x );
double atan2( double y, double x );


Routine Required Header Compatibility
atan <math.h> ANSI, Win 95, Win NT
atan2  <math.h> ANSI, Win 95, Win NT

Remarks
The atan function calculates the arctangent of x.
atan2 calculates the arctangent of y/x. atan2 is well defined for every point other than the origin, even if x equals 0 and y does not equal 0.

Subject: Floating-Point Support Routines
See also acos, asin, cos, _matherr, sin, tan
Return Value
atan returns the arctangent of x.
atan2 returns the arctangent of y/x. If x is 0, atan returns 0. If both parameters of atan2 are 0, the function returns 0. You can modify error handling by using the _matherr routine. atan returns a value in the range –p/2 to p/2 radians; atan2 returns a value in the range –p to p radians, using the signs of both parameters to determine the quadrant of the return value.

Parameters
x, y Any numbers
Example
/* ATAN.C: This program calculates
* the arctangent of 1 and -1.
*/

#include <math.h>
#include <stdio.h>
#include <errno.h>

void main( void )
{
double x1, x2, y;

printf( "Enter a real number: " );
scanf( "%lf", &x1 );
y = atan( x1 );
printf( "Arctangent of %f: %f\n", x1, y );
printf( "Enter a second real number: " );
scanf( "%lf", &x2 );
y = atan2( x1, x2 );
printf( "Arctangent of %f / %f: %f\n", x1, x2, y );
}


Output
Enter a real number: -862.42
Arctangent of -862.420000: -1.569637
Enter a second real number: 78.5149
Arctangent of -862.420000 / 78.514900: -1.480006


asin
Calculates the arcsine.
double asin( double x );

Routine Required Header Compatibility
asin <math.h> ANSI, Win 95, Win NT

Floating-Point Support Routines
See also acos, atan, cos, _matherr, sin, tan
Return Value
The asin function returns the arcsine of x in the range –p/2 to p/2 radians. If x is less than –1 or greater than 1, asin returns an indefinite (same as a quiet NaN). You can modify error handling with the _matherr routine.

Parameter
x Value whose arcsine is to be calculated
Example
/* ASINCOS.C: This program prompts for a value in the range
* -1 to 1. Input values outside this range will produce
* _DOMAIN error messages.If a valid value is entered, the
* program prints the arcsine and the arccosine of that value.
*/

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

void main( void )
{
double x, y;

printf( "Enter a real number between -1 and 1: " );
scanf( "%lf", &x );
y = asin( x );
printf( "Arcsine of %f = %f\n", x, y );
y = acos( x );
printf( "Arccosine of %f = %f\n", x, y );
}


Output
Enter a real number between -1 and 1: .32696
Arcsine of 0.326960 = 0.333085
Arccosine of 0.326960 = 1.237711


acos
Calculates the arccosine.
double acos( double x );

Routine Required Header Compatibility
acos <math.h> <errno.h> ANSI, Win 95, Win NT

Floating-Point Support Routines
See also asin, atan, cos, _matherr, sin, tan
Return Value
The acos function returns the arccosine of x in the range 0 to p radians. If x is less than –1 or greater than 1, acos returns an indefinite (same as a quiet NaN). You can modify error handling with the _matherr routine.

Parameter
x Value between –1 and 1 whose arccosine is to be calculated
Example
/* ASINCOS.C: This program prompts for a value in the range
* -1 to 1. Input values outside this range will produce
* _DOMAIN error messages.If a valid value is entered, the
* program prints the arcsine and the arccosine of that value.
*/

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

void main( void )
{
double x, y;

printf( "Enter a real number between -1 and 1: " );
scanf( "%lf", &x );
y = asin( x );
printf( "Arcsine of %f = %f\n", x, y );
y = acos( x );
printf( "Arccosine of %f = %f\n", x, y );
}


Output
Enter a real number between -1 and 1: .32696
Arcsine of 0.326960 = 0.333085
Arccosine of 0.326960 = 1.237711


tan, tanh
Calculate the tangent (tan) or hyperbolic tangent (tanh).
double tan( double x );
double tanh( double x );


Routine Required Header Compatibility
Routine Required Header Compatibility
tan <math.h> ANSI, Win 95, Win NT
tanh  <math.h> ANSI, Win 95, Win NT


Floating-Point Support Routines, Long Double Routines
See Also acos, asin, atan, cos, sin
Return Value
tan returns the tangent of x. If x is greater than or equal to 263, or less than or equal to –263, a loss of significance in the result occurs, in which case the function generates a _TLOSS error and returns an indefinite (same as a quiet NaN). You can modify error handling with _matherr.
tanh returns the hyperbolic tangent of x. There is no error return.

Parameter
x Angle in radians

Example
/* TAN.C: This program displays the tangent of pi / 4
* and the hyperbolic tangent of the result.
*/

#include <math.h>
#include <stdio.h>

void main( void )
{
double pi = 3.1415926535;
double x, y;

x = tan( pi / 4 );
y = tanh( x );
printf( "tan( %f ) = %f\n", x, y );
printf( "tanh( %f ) = %f\n", y, x );
}


Output
tan( 1.000000 ) = 0.761594
tanh( 0.761594 ) = 1.000000


Homepage von PS-Trainer - C-Entwicklung - Mathematik - an PS-Trainer

Aktuelle Daten dieser Seite Letzte Änderung:
  Geocities

 

 

 

Hosted by www.Geocities.ws

1