amath  1.6.2
Simple command line calculator
ccsc.c File Reference
#include "prim.h"
#include "math.h"
#include "complex.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

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 47 of file ccsc.c.

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

Referenced by ComplexNumber::Cosecant().

48 {
49  complex w;
50  double a, b;
51  double d;
52 
53  a = creal(z);
54  b = cimag(z);
55  d = cosh(2.0 * b) - cos(2.0 * a);
56 
57  if (d == 0.0) {
58  w = cpack(HUGE, HUGE); // TODO: INF, INF
59  } else {
60  w = cpack((2.0 * sin(a) * cosh(b) / d), (-2.0 * cos(a) * sinh(b) / d));
61  }
62 
63  return w;
64 }
#define HUGE
Definition: prim.h:40
double sinh(double x)
Hyperbolic sine function.
Definition: sinh.c:81
double cos(double x)
Trigonometric cosine function.
Definition: cos.c:87
double sin(double x)
Trigonometric sine function.
Definition: sin.c:87
double cosh(double x)
Hyperbolic cosine function.
Definition: cosh.c:84
complex cpack(double x, double y)
Pack two real numbers into a complex number.
Definition: prim.c:71
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:47

Here is the call graph for this function:

Here is the caller graph for this function: