C Programming/tgmath.h

tgmath.h is a Standard C header that defines many type-generic macros that can be used for a variety of mathematical operations. This header also includes  and. For all of the functions in the  and   headers that do not have an f (float) or l (long double) suffix, and whose corresponding type is double (with the exception of  ), there is a corresponding macro.

Type-generic macro
A type generic macro is something which allows calling a function whose type is determined by the type of argument in the macro. This means, for example, x is declared as an int data type but $$tan$$ has been called this way:

then this expression will have a type.

Also, if any one of the parameters or arguments of a type-generic macro is complex, it will call a complex function, otherwise a real function will be called. The type of function that is called, ultimately depends upon the final converted type of parameter. .

Dependency Graph
The flowchart below shows the Dependency graph for tgmath.h.

Functions from
The functions listed below handle real arguments and return real output only. If complex arguments are passed to these functions, NaN or other special numbers are returned.

Functions from
The functions defined below handle complex parameters, but do not return complex output.

Usage example
The code below illustrates usage of, function defined in  , which computes the inverse of tangent of a number defined in the domain of tangent.

Notable differences
The similar functions defined here have notable difference when it comes to return value of "tricky" numbers. For example, using sqrt to compute square root of -25 returns -NaN(Not a Number), whereas, csqrt returns 0.000000. Such differences may be noticed in other functions also.

Rationale
This header file is mainly included while calculating mathematical functions.As it includes both math.h and complex.h, the problem arising due to inconsistent input is solved. Including any of the header files, individually, involves inconsistent outputs for some inputs.