Rate This Document
Findability
Accuracy
Completeness
Readability

sin

Compute the sine of a real number.

Interface Definition

C interface:

float sinf(float x);

double sin(double x);

float complex csinf(float complex x);

double complex csin(double complex x);

Fortran interface:

RES = SINF(X);

RES = SIN(X);

RES = CSINF(X);

RES = CSIN(X);

Parameters

Parameter

Type

Description

Input/Output

x

  • For sinf, x is of single-precision floating-point type.
  • For sin, x is of double-precision floating-point type.
  • For csinf, x is of single-precision floating-point complex number type.
  • For csin, x is of double-precision floating-point complex number type.

Floating-point value of a radian angle

Input

Return Value

  • The sine y of radiant angle x is returned. y ∈ [-1, +1]
  • If the input is +0, the return value is +0.
  • If the input is -0, the return value is -0.
  • If the input is ±∞, the return value is NaN.
  • If the input is NaN, the return value is NaN.

Dependencies

C: "km.h"

Fortran: "km.f03"

Examples

C interface:
    double pi = acos(-1); 
    // typical usage 
    double a = pi/6, b = 1.0, c = -3*pi/4, d = pi/3; 
    // special handling 
    double e = INFINITY, f = -INFINITY, g = NAN; 
    double complex k = 0 + 0 * I;
    // print result 
    printf("sin(pi/6) = %.15f\n", sin(a)); 
    printf("sin(1.0) = %.15f\n", sin(b)); 
    printf("sin(-3*pi/4) = %.15f\n", sin(c)); 
    printf("sin(pi/3) = %.15f\n", sin(d)); 
    printf("sin(INFINITY) = %.15f\n", sin(e)); 
    printf("sin(-INFINITY) = %.15f\n", sin(f)); 
    printf("sin(NAN) = %.15f\n", sin(g)); 
    printf("csin(0+0*I) = %.15f + %.15f * I\n", creal(csin(k)), cimag(csin(k)));
    /* 
     *  sin(pi/6) = 0.500000000000000 
     *  sin(1.0) = 0.841470984807897 
     *  sin(-3*pi/4) = -0.707106781186548 
     *  sin(pi/3) = 0.866025403784438 
     *  sin(INFINITY) = nan 
     *  sin(-INFINITY) = nan 
     *  sin(NAN) = nan 
     *  csin(0+0*I) = 0 + 0 * I
     * 
     * */

Fortran interface:

    REAL(8) :: X = 1.0 
    PRINT*,  SIN(X) 
    ! 
    ! OUTPUT 
    !     0.841470984807897 
    !