Mathematics
f(z)    Complex Numbers and Functions     Tech Note
Complex Trig Functions

This page shows how to compute several complex trigonometric functions, including cosine, sine, tangent, secant, cosecant, and cotangent.

 CCos:  Complex cosine

CCos function

// z = cos(a)
FUNCTION CCos (CONST a:  TComplex):  TComplex;
  VAR
    aTemp:  TComplex;
BEGIN  // Abramowitz formula 4.3.56 on p. 74
  aTemp := CConvert(a, cfRectangular);
  RESULT := CSet ( COS(aTemp.x)*COSH(aTemp.y),
                  -SIN(aTemp.x)*SINH(aTemp.y))
END {CCos};

Examples

Complex cosine:  CCos = Cos(z)
 
                              COS(z)                          COS(z)
          z                rectangular                        polar
     ------------  ----------------------------   --------------------------------
 1    0.0 +  0.0i   1.000000000 +  0.000000000i   1.000000000 * CIS(  0.000000000)
 2    0.5 +  0.5i   0.989584883 -  0.249826398i   1.020632877 * CIS( -0.247288622)
 3   -0.5 +  0.5i   0.989584883 +  0.249826398i   1.020632877 * CIS(  0.247288622)
 4   -0.5 -  0.5i   0.989584883 -  0.249826398i   1.020632877 * CIS( -0.247288622)
 5    0.5 -  0.5i   0.989584883 +  0.249826398i   1.020632877 * CIS(  0.247288622)
 6    1.0 +  0.0i   0.540302306 +  0.000000000i   0.540302306 * CIS(  0.000000000)
 7    1.0 +  1.0i   0.833730025 -  0.988897706i   1.293454455 * CIS( -0.870327425)
 8    0.0 +  1.0i   1.543080635 +  0.000000000i   1.543080635 * CIS(  0.000000000)
 9   -1.0 +  1.0i   0.833730025 +  0.988897706i   1.293454455 * CIS(  0.870327425)
10   -1.0 +  0.0i   0.540302306 +  0.000000000i   0.540302306 * CIS(  0.000000000)
11   -1.0 -  1.0i   0.833730025 -  0.988897706i   1.293454455 * CIS( -0.870327425)
12    0.0 -  1.0i   1.543080635 +  0.000000000i   1.543080635 * CIS(  0.000000000)
13    1.0 -  1.0i   0.833730025 +  0.988897706i   1.293454455 * CIS(  0.870327425)
14    5.0 +  0.0i   0.283662185 +  0.000000000i   0.283662185 * CIS(  0.000000000)
15    5.0 +  3.0i   2.855815004 +  9.606383448i  10.021890156 * CIS(  1.281834004)
16    0.0 +  3.0i  10.067661996 +  0.000000000i  10.067661996 * CIS(  0.000000000)
17   -5.0 +  3.0i   2.855815004 -  9.606383448i  10.021890156 * CIS( -1.281834004)
18   -5.0 +  0.0i   0.283662185 +  0.000000000i   0.283662185 * CIS(  0.000000000)
19   -5.0 -  3.0i   2.855815004 +  9.606383448i  10.021890156 * CIS(  1.281834004)
20    0.0 -  3.0i  10.067661996 +  0.000000000i  10.067661996 * CIS(  0.000000000)
21   -5.0 -  3.0i   2.855815004 +  9.606383448i  10.021890156 * CIS(  1.281834004)

 

CSin:  Complex sine

CSin function

// z = sin(a)
FUNCTION CSin (CONST a:  TComplex):  TComplex;
  VAR
    aTemp:  TComplex;
BEGIN  // Abramowitz formula 4.3.55 on p. 74
  aTemp := CConvert(a, cfRectangular);
  RESULT := CSet(SIN(aTemp.x)*COSH(aTemp.y),
                 COS(aTemp.x)*SINH(aTemp.y))
END {CSin};

The table below, in addition to showing the complex sine function, also shows the results of the computation, cos2(z) + sin2(z), which is from the mathematical identity cos2(z) + sin2(z) = 1.

Examples

Complex sine:  CSin = Sin(z)
 
                              SIN(z)                COS^2(z) + SIN^2(z) = 1
          z                rectangular                    rectangular
     ------------  ----------------------------   ---------------------------
 1    0.0 +  0.0i   0.000000000 +  0.000000000i   1.000000000 +  0.000000000i
 2    0.5 +  0.5i   0.540612686 +  0.457304153i   1.000000000 +  0.000000000i
 3   -0.5 +  0.5i  -0.540612686 +  0.457304153i   1.000000000 +  0.000000000i
 4   -0.5 -  0.5i  -0.540612686 -  0.457304153i   1.000000000 +  0.000000000i
 5    0.5 -  0.5i   0.540612686 -  0.457304153i   1.000000000 +  0.000000000i
 6    1.0 +  0.0i   0.841470985 +  0.000000000i   1.000000000 +  0.000000000i
 7    1.0 +  1.0i   1.298457581 +  0.634963915i   1.000000000 +  0.000000000i
 8    0.0 +  1.0i   0.000000000 +  1.175201194i   1.000000000 +  0.000000000i
 9   -1.0 +  1.0i  -1.298457581 +  0.634963915i   1.000000000 +  0.000000000i
10   -1.0 +  0.0i  -0.841470985 +  0.000000000i   1.000000000 +  0.000000000i
11   -1.0 -  1.0i  -1.298457581 -  0.634963915i   1.000000000 +  0.000000000i
12    0.0 -  1.0i   0.000000000 -  1.175201194i   1.000000000 +  0.000000000i
13    1.0 -  1.0i   1.298457581 -  0.634963915i   1.000000000 +  0.000000000i
14    5.0 +  0.0i  -0.958924275 +  0.000000000i   1.000000000 +  0.000000000i
15    5.0 +  3.0i  -9.654125477 +  2.841692296i   1.000000000 +  0.000000000i
16    0.0 +  3.0i   0.000000000 + 10.017874927i   1.000000000 +  0.000000000i
17   -5.0 +  3.0i   9.654125477 +  2.841692296i   1.000000000 +  0.000000000i
18   -5.0 +  0.0i   0.958924275 +  0.000000000i   1.000000000 +  0.000000000i
19   -5.0 -  3.0i   9.654125477 -  2.841692296i   1.000000000 +  0.000000000i
20    0.0 -  3.0i   0.000000000 - 10.017874927i   1.000000000 +  0.000000000i
21   -5.0 -  3.0i   9.654125477 -  2.841692296i   1.000000000 +  0.000000000i

 

CTan:  Complex tangent

CTan function

// z   = tan(a)
FUNCTION CTan (CONST a:  TComplex):  TComplex;
  VAR
    aTemp:  TComplex;
    rTemp:  TReal;
BEGIN  // Abramowitz formula 4.3.57 on p. 74
  aTemp := CConvert(a, cfRectangular);
  rTemp := COS(2.0*aTemp.x) + COSH(2.0*aTemp.y);
 
  TRY
    RESULT := CSet(SIN(2.0*aTemp.x) /rTemp,
                   SINH(2.0*aTemp.y)/rTemp)
  EXCEPT
    ON EZeroDivide DO         // x/0
       RESULT := CSet(Infinity, Infinity);
    ON EComplexInvalidOp DO   // 0/0
       RESULT := CSet(Infinity, Infinity)
  END
END {CTan};

The table below show the computation of tan(z) directly and via calculation as sin(z)/cos(z).

Examples

Complex tangent:  CTan = Tan(z) = Sin(z)/Cos(z)
 
                              TAN(z)                    SIN(z) / COS(z)
          z                rectangular                   rectangular
     ------------  ----------------------------   ---------------------------
 1    0.0 +  0.0i   0.000000000 +  0.000000000i   0.000000000 +  0.000000000i
 2    0.5 +  0.5i   0.403896455 +  0.564083141i   0.403896455 +  0.564083141i
 3   -0.5 +  0.5i  -0.403896455 +  0.564083141i  -0.403896455 +  0.564083141i
 4   -0.5 -  0.5i  -0.403896455 -  0.564083141i  -0.403896455 -  0.564083141i
 5    0.5 -  0.5i   0.403896455 -  0.564083141i   0.403896455 -  0.564083141i
 6    1.0 +  0.0i   1.557407725 +  0.000000000i   1.557407725 +  0.000000000i
 7    1.0 +  1.0i   0.271752585 +  1.083923327i   0.271752585 +  1.083923327i
 8    0.0 +  1.0i   0.000000000 +  0.761594156i   0.000000000 +  0.761594156i
 9   -1.0 +  1.0i  -0.271752585 +  1.083923327i  -0.271752585 +  1.083923327i
10   -1.0 +  0.0i  -1.557407725 +  0.000000000i  -1.557407725 +  0.000000000i
11   -1.0 -  1.0i  -0.271752585 -  1.083923327i  -0.271752585 -  1.083923327i
12    0.0 -  1.0i   0.000000000 -  0.761594156i   0.000000000 -  0.761594156i
13    1.0 -  1.0i   0.271752585 -  1.083923327i   0.271752585 -  1.083923327i
14    5.0 +  0.0i  -3.380515006 +  0.000000000i  -3.380515006 +  0.000000000i
15    5.0 +  3.0i  -0.002708236 +  1.004164711i  -0.002708236 +  1.004164711i
16    0.0 +  3.0i   0.000000000 +  0.995054754i   0.000000000 +  0.995054754i
17   -5.0 +  3.0i   0.002708236 +  1.004164711i   0.002708236 +  1.004164711i
18   -5.0 +  0.0i   3.380515006 +  0.000000000i   3.380515006 +  0.000000000i
19   -5.0 -  3.0i   0.002708236 -  1.004164711i   0.002708236 -  1.004164711i
20    0.0 -  3.0i   0.000000000 -  0.995054754i   0.000000000 -  0.995054754i
21   -5.0 -  3.0i   0.002708236 -  1.004164711i   0.002708236 -  1.004164711i

 

CSec:  Complex secant

CSec function

// z   = sec(a)
FUNCTION CSec (CONST a:  TComplex):  TComplex;
  VAR
    temp:  TComplex;
BEGIN  {Abramowitz formula 4.3.5 on p. 72}
  temp := CCos(a);
  TRY
    RESULT := CDiv(ComplexOne, temp)
  EXCEPT
    ON EComplexZeroDivide DO  // x/0
       RESULT := CSet(Infinity, Infinity);
    ON EComplexInvalidOp DO   // 0/0
       RESULT := CSet(Infinity, Infinity)
  END
END {CSec};

The table below, in addition to showing the complex secant function, also shows the results of the mathematical identity sec2(z) - tan2(z) = 1.  [This identity is just another version of the more-recognized identity, cos2(z) + sin2(z) = 1.  Dividing all the terms in this identity by cos2(z), and rearranging the terms, results in the identity used below.]

Examples

Complex secant:  CSec = Sec(z)

                              SEC(z)                SEC^2(z) - TAN^2(z) = 1
          z                rectangular                    rectangular
     ------------  ----------------------------   ---------------------------
 1    0.0 +  0.0i   1.000000000 +  0.000000000i   1.000000000 +  0.000000000i
 2    0.5 +  0.5i   0.949978868 +  0.239827631i   1.000000000 +  0.000000000i
 3   -0.5 +  0.5i   0.949978868 -  0.239827631i   1.000000000 +  0.000000000i
 4   -0.5 -  0.5i   0.949978868 +  0.239827631i   1.000000000 +  0.000000000i
 5    0.5 -  0.5i   0.949978868 -  0.239827631i   1.000000000 +  0.000000000i
 6    1.0 +  0.0i   1.850815718 +  0.000000000i   1.000000000 +  0.000000000i
 7    1.0 +  1.0i   0.498337031 +  0.591083842i   1.000000000 +  0.000000000i
 8    0.0 +  1.0i   0.648054274 +  0.000000000i   1.000000000 +  0.000000000i
 9   -1.0 +  1.0i   0.498337031 -  0.591083842i   1.000000000 +  0.000000000i
10   -1.0 +  0.0i   1.850815718 +  0.000000000i   1.000000000 +  0.000000000i
11   -1.0 -  1.0i   0.498337031 +  0.591083842i   1.000000000 +  0.000000000i
12    0.0 -  1.0i   0.648054274 +  0.000000000i   1.000000000 +  0.000000000i
13    1.0 -  1.0i   0.498337031 -  0.591083842i   1.000000000 +  0.000000000i
14    5.0 +  0.0i   3.525320086 +  0.000000000i   1.000000000 +  0.000000000i
15    5.0 +  3.0i   0.028433531 -  0.095644641i   1.000000000 +  0.000000000i
16    0.0 +  3.0i   0.099327927 +  0.000000000i   1.000000000 +  0.000000000i
17   -5.0 +  3.0i   0.028433531 +  0.095644641i   1.000000000 +  0.000000000i
18   -5.0 +  0.0i   3.525320086 +  0.000000000i   1.000000000 +  0.000000000i
19   -5.0 -  3.0i   0.028433531 -  0.095644641i   1.000000000 +  0.000000000i
20    0.0 -  3.0i   0.099327927 +  0.000000000i   1.000000000 +  0.000000000i
21   -5.0 -  3.0i   0.028433531 -  0.095644641i   1.000000000 +  0.000000000i

 

CCsc:  Complex cosecant

CCsc function

// z   = csc(a)
FUNCTION CCsc (CONST a:  TComplex):  TComplex;
  VAR
    temp:  TComplex;
BEGIN  // Abramowitz formula 4.3.4 on p. 72
  temp := CSin(a);
  TRY
    RESULT := CDiv(ComplexOne, temp)
  EXCEPT
    ON EComplexZeroDivide DO   // x/0
       RESULT := CSet(Infinity, Infinity);
    ON EComplexInvalidOp DO    // 0/0
       RESULT := CSet(Infinity, Infinity)
  END
END {CCsc};

The table below, in addition to showing the complex cosecant function, also shows the results of the mathematical identity csc2(z) - cot2(z) = 1.  [This identity is just another version of the more-recognized identity, cos2(z) + sin2(z) = 1.  Dividing all the terms in this identity by sin2(z), and rearranging the terms, results in the identity used below.]

Examples

Complex cosecant:  CCsc = Csc(z)
 
                              CSC(z)                CSC^2(z) - COT^2(z) = 1
          z                rectangular                    rectangular
     ------------  ----------------------------   ---------------------------
 1    0.0 +  0.0i           INF +          INFi
 2    0.5 +  0.5i   1.078229695 -  0.912074264i   1.000000000 +  0.000000000i
 3   -0.5 +  0.5i  -1.078229695 -  0.912074264i   1.000000000 +  0.000000000i
 4   -0.5 -  0.5i  -1.078229695 +  0.912074264i   1.000000000 +  0.000000000i
 5    0.5 -  0.5i   1.078229695 +  0.912074264i   1.000000000 +  0.000000000i
 6    1.0 +  0.0i   1.188395106 +  0.000000000i   1.000000000 +  0.000000000i
 7    1.0 +  1.0i   0.621518017 -  0.303931002i   1.000000000 +  0.000000000i
 8    0.0 +  1.0i   0.000000000 -  0.850918128i   1.000000000 +  0.000000000i
 9   -1.0 +  1.0i  -0.621518017 -  0.303931002i   1.000000000 +  0.000000000i
10   -1.0 +  0.0i  -1.188395106 +  0.000000000i   1.000000000 +  0.000000000i
11   -1.0 -  1.0i  -0.621518017 +  0.303931002i   1.000000000 +  0.000000000i
12    0.0 -  1.0i   0.000000000 +  0.850918128i   1.000000000 +  0.000000000i
13    1.0 -  1.0i   0.621518017 +  0.303931002i   1.000000000 +  0.000000000i
14    5.0 +  0.0i  -1.042835213 +  0.000000000i   1.000000000 +  0.000000000i
15    5.0 +  3.0i  -0.095323635 -  0.028058516i   1.000000000 +  0.000000000i
16    0.0 +  3.0i   0.000000000 -  0.099821570i   1.000000000 +  0.000000000i
17   -5.0 +  3.0i   0.095323635 -  0.028058516i   1.000000000 +  0.000000000i
18   -5.0 +  0.0i   1.042835213 +  0.000000000i   1.000000000 +  0.000000000i
19   -5.0 -  3.0i   0.095323635 +  0.028058516i   1.000000000 +  0.000000000i
20    0.0 -  3.0i   0.000000000 +  0.099821570i   1.000000000 +  0.000000000i
21   -5.0 -  3.0i   0.095323635 +  0.028058516i   1.000000000 +  0.000000000i

 

CCot:  Complex cotangent

CCot function

// z   = cot(a)
FUNCTION CCot (CONST a:  TComplex):  TComplex;
  VAR
    aTemp:  TComplex;
    Temp:  TReal;
BEGIN  // Abramowitz formula 4.3.58 on p. 74
  aTemp := CConvert (a,cfRectangular);
  Temp := COSH(2.0*aTemp.y) - COS(2.0*aTemp.x);
  TRY
    RESULT := CSet( SIN(2.0*aTemp.x)/temp,
                   -SINH(2.0*aTemp.y)/temp)
  EXCEPT
    ON EZeroDivide DO   // x/0
       RESULT := CSet(Infinity, Infinity);
    ON EInvalidOp DO    // 0/0
       RESULT := CSet(Infinity, Infinity)
  END
END {CCot};

The table below shows the computation of cot(z) directly and via calculation as cos(z)/sin(z).

Examples

Complex cotangent:  CCot = Cot(z) = Cos(z)/Sin(z)
 
                              COT(z)                    COS(z) / SIN(z)
          z                rectangular                    rectangular
     ------------  ----------------------------   ---------------------------
 1    0.0 +  0.0i           INF +          INFi           INF +          INFi
 2    0.5 +  0.5i   0.839139579 -  1.171945145i   0.839139579 -  1.171945145i
 3   -0.5 +  0.5i  -0.839139579 -  1.171945145i  -0.839139579 -  1.171945145i
 4   -0.5 -  0.5i  -0.839139579 +  1.171945145i  -0.839139579 +  1.171945145i
 5    0.5 -  0.5i   0.839139579 +  1.171945145i   0.839139579 +  1.171945145i
 6    1.0 +  0.0i   0.642092616 +  0.000000000i   0.642092616 +  0.000000000i
 7    1.0 +  1.0i   0.217621562 -  0.868014143i   0.217621562 -  0.868014143i
 8    0.0 +  1.0i   0.000000000 -  1.313035285i   0.000000000 -  1.313035285i
 9   -1.0 +  1.0i  -0.217621562 -  0.868014143i  -0.217621562 -  0.868014143i
10   -1.0 +  0.0i  -0.642092616 +  0.000000000i  -0.642092616 +  0.000000000i
11   -1.0 -  1.0i  -0.217621562 +  0.868014143i  -0.217621562 +  0.868014143i
12    0.0 -  1.0i   0.000000000 +  1.313035285i   0.000000000 +  1.313035285i
13    1.0 -  1.0i   0.217621562 +  0.868014143i   0.217621562 +  0.868014143i
14    5.0 +  0.0i  -0.295812916 +  0.000000000i  -0.295812916 +  0.000000000i
15    5.0 +  3.0i  -0.002685798 -  0.995845319i  -0.002685798 -  0.995845319i
16    0.0 +  3.0i   0.000000000 -  1.004969823i   0.000000000 -  1.004969823i
17   -5.0 +  3.0i   0.002685798 -  0.995845319i   0.002685798 -  0.995845319i
18   -5.0 +  0.0i   0.295812916 +  0.000000000i   0.295812916 +  0.000000000i
19   -5.0 -  3.0i   0.002685798 +  0.995845319i   0.002685798 +  0.995845319i
20    0.0 -  3.0i   0.000000000 +  1.004969823i   0.000000000 +  1.004969823i
21   -5.0 -  3.0i   0.002685798 +  0.995845319i   0.002685798 +  0.995845319i

 


Download ComplexMathLibrary


Updated 18 Feb 2002


since 24 June 2001