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

Go to the source code of this file.

Functions

complex ctan (complex z)
 Tangent of a complex number. More...
 

Function Documentation

◆ ctan()

complex ctan ( complex  z)

Tangent of a complex number.

Calculated as in Open Office:
https://wiki.openoffice.org/wiki/Documentation/How_Tos/Calc:_IMTAN_function

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

Definition at line 55 of file ctan.c.

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

Referenced by ComplexNumber::Tangent().

56 {
57  complex w;
58  double a, b;
59  double d;
60 
61  a = creal(z);
62  b = cimag(z);
63  d = cos(2.0 * a) + cosh(2.0 * b);
64 
65  if (d == 0.0)
66  {
67  w = cpack((double)INFP, (double)INFP);
68  }
69  else
70  {
71  w = cpack((sin(2.0 * a) / d), (sinh(2.0 * b) / d));
72  }
73 
74  return w;
75 }
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: