amath  1.8.5
Simple command line calculator
ccsc.c File Reference
#include "prim.h"
Include dependency graph for ccsc.c:

Go to the source code of this file.

Functions

complex ccsc (complex z)
 Cosecant of a complex number. More...
 

Function Documentation

◆ ccsc()

complex ccsc ( complex  z)

Cosecant of a complex number.

Calculated as in Open Office:

a+bi
            2.0 * sin(a) * cosh(b)
real  = ------------------------------
         cosh(2.0 * b) - cos(2.0 * a)
           -2.0 * cos(a) * sinh(b)
imag  = ------------------------------
         cosh(2.0 * b) - cos(2.0 * a)

https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_IMCSC_function

Definition at line 48 of file ccsc.c.

References cimag(), cos(), cosh(), cpack(), creal(), sin(), and sinh().

Referenced by ComplexNumber::Cosecant().

49 {
50  complex w;
51  double a, b;
52  double d;
53 
54  a = creal(z);
55  b = cimag(z);
56  d = cosh(2.0 * b) - cos(2.0 * a);
57 
58  if (d == 0.0)
59  {
60  w = cpack((double)INFP, (double)INFP);
61  }
62  else
63  {
64  w = cpack((2.0 * sin(a) * cosh(b) / d), (-2.0 * cos(a) * sinh(b) / d));
65  }
66 
67  return w;
68 }
double sin(double x)
Sine function.
Definition: sin.c:86
double cosh(double x)
Hyperbolic cosine function.
Definition: cosh.c:83
Definition: mathi.h:48
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:68
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
double cos(double x)
Cosine function.
Definition: cos.c:87
#define INFP
Definition: mathr.h:51
double sinh(double x)
Hyperbolic sine function.
Definition: sinh.c:77
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
Here is the call graph for this function:
Here is the caller graph for this function: