What is arc tangent?
The arctangent is the inverse of the tangent function. It returns the angle whose tangent is the given number.
catan() is an inbuilt function in <complex.h> header file which returns the complex inverse tangent (or arc tangent) of any constant, which divides the imaginary axis on the basis of the inverse tangent in the closed interval [-i, +i] (where i stands for iota), used for evaluation of a complex object say z is on imaginary axis whereas to determine a complex object which is real or integer, then internally invokes pre-defined methods as:
| S.No. |
Method |
Return Type |
|
1. |
atan() function takes a complex z of datatype double which determine arc tangent for real complex numbers | Returns complex arc tangent lies in a range along real axis [-PI/2, +PI/2] for an argument of type double. |
|
2. |
atanf() function takes a complex z of datatype float double which determine arc tangent for real complex numbers. | Returns complex arc tangent lies in a range along real axis [-PI/2, +PI/2] for an argument of type float. |
|
3. |
atanl() function takes a complex z of datatype long double which determine arc tangent for real complex numbers | Returns complex arc tangent lies in a range along real axis [-PI/2, +PI/2] for an argument of type long double. |
|
4. |
catan() function takes a complex z of datatype double which also allows imaginary part of complex numbers | Returns complex arc tangent lies in a range along imaginary axis [-i, +i] for a complex object of type double |
|
5. |
catanf() Â function takes a complex z of datatype float double which also allows imaginary part of complex numbers | Returns complex arc tangent lies in a range along imaginary axis [-i, +i] for a complex object of type float |
|
6. |
catanl() Â function takes a complex z of datatype long double which also allows imaginary part of complex numbers | Returns complex arc tangent lies in a range along imaginary axis [-i, +i] for a complex object of type long double |
Syntax:
atan(double arg); atanf(float arg); atanl(long double arg); where arg is a floating-point value catan(double complex z); catanf(float complex z); catanl( long double complex z); where z is a Type – generic macro
Parameter: These functions accept one mandatory parameter z which specifies the inverse tangent. The parameter can be of double, float, or long double datatype.
Return Value: This function returns complex arc tangent/arc tangent according to the type of the argument passed.
Below are the programs illustrate the above method:
Program 1: This program will illustrate the functions atan(), atanf(), and atanl() computes the principal value of the arc tangent of floating – point argument. If a range error occurs due to underflow, the correct result after rounding off is returned.Â
C++
// C++ program to illustrate the use// of functions atan(), atanf(),// and atanl()#include<bits/stdc++.h>using namespace std;Â
//Drive codeint main(){Â Â Â Â // For function atan()Â Â Â Â cout << "atan(1) = " << atan(1) << ", ";Â Â Â Â cout << "4*atan(1) = " << 4 * atan(1) << "\n";Â
    cout << "atan(-0.0) = " << atan(-0.0) << ", ";    cout << "atan(+0.0) = " << atan(0) << "\n";Â
    // For special values INFINITY    cout << "atan(INFINITY) = " << atan(INFINITY) << ", ";    cout << "2*atan(INFINITY) = " << 2 * atan(INFINITY) << "\n\n";Â
    // For function atanf()    cout << "atanf(1.1) = " << atanf(1.1) << ", ";    cout << "4*atanf(1.5) = " << 4 * atanf(1.5) << "\n";Â
    cout << "atanf(-0.3) = " << atanf(-0.3) << ", ";    cout << "atanf(+0.3) = " << atanf(0.3) << "\n";Â
    // For special values INFINITY    cout << "atanf(INFINITY) = " << atanf(INFINITY) << ", ";    cout << "2*atanf(INFINITY) = " << 2 * atanf(INFINITY) << "\n\n";Â
    // For function atanl()    cout << "atanl(1.1) = " << atanl(1.1) << ", ";    cout << "4*atanl(1.7) = " << 4 * atanl(1.7) << "\n";Â
    cout << "atanl(-1.3) = " << atanl(-1.3) << ", ";    cout << "atanl(+0.3) = " << atanl(0.3) << "\n";Â
    // For special values INFINITY    cout << "atanl(INFINITY) = " << atanl(INFINITY) << ", ";    cout << "2*atanl(INFINITY) = " << 2 * atanl(INFINITY) << "\n\n";Â
    return 0;} |
C
// C program to illustrate the use// of functions atan(), atanf(),// and atanl()#include <math.h>#include <stdio.h>Â
// Driver Codeint main(){    // For function atan()    printf("atan(1) = %lf, ",           atan(1));    printf(" 4*atan(1)=%lf\n",           4 * atan(1));Â
    printf("atan(-0.0) = %+lf, ",           atan(-0.0));    printf("atan(+0.0) = %+lf\n",           atan(0));Â
    // For special values INFINITY    printf("atan(Inf) = %lf, ",           atan(INFINITY));    printf("2*atan(Inf) = %lf\n\n",           2 * atan(INFINITY));Â
    // For function atanf()    printf("atanf(1.1) = %f, ",           atanf(1.1));    printf("4*atanf(1.5)=%f\n",           4 * atanf(1.5));Â
    printf("atanf(-0.3) = %+f, ",           atanf(-0.3));    printf("atanf(+0.3) = %+f\n",           atanf(0.3));Â
    // For special values INFINITY    printf("atanf(Inf) = %f, ",           atanf(INFINITY));    printf("2*atanf(Inf) = %f\n\n",           2 * atanf(INFINITY));Â
    // For function atanl()    printf("atanl(1.1) = %Lf, ",           atanl(1.1));    printf("4*atanl(1.7)=%Lf\n",           4 * atanl(1.7));Â
    printf("atanl(-1.3) = %+Lf, ",           atanl(-1.3));    printf("atanl(+0.3) = %+Lf\n",           atanl(0.3));Â
    // For special values INFINITY    printf("atanl(Inf) = %Lf, ",           atanl(INFINITY));    printf("2*atanl(Inf) = %Lf\n\n",           2 * atanl(INFINITY));Â
    return 0;} |
atan(1) = 0.785398, 4*atan(1)=3.141593 atan(-0.0) = -0.000000, atan(+0.0) = +0.000000 atan(Inf) = 1.570796, 2*atan(Inf) = 3.141593 atanf(1.1) = 0.832981, 4*atanf(1.5)=3.931175 atanf(-0.3) = -0.291457, atanf(+0.3) = +0.291457 atanf(Inf) = 1.570796, 2*atanf(Inf) = 3.141593 atanl(1.1) = 0.832981, 4*atanl(1.7)=4.156289 atanl(-1.3) = -0.915101, atanl(+0.3) = +0.291457 atanl(Inf) = 1.570796, 2*atanl(Inf) = 3.141593
Program 2: This program will illustrate the functions catan(), catanf(), and catanl() computes the principal value of the arc tangent of complex number as argument.Â
C
// C program to illustrate the use// of functions catan(), catanf(),// and catanl()#include <complex.h>#include <float.h>#include <stdio.h>Â
// Driver Codeint main(){    // Given Complex Number    double complex z1 = catan(2 * I);Â
    // Function catan()    printf("catan(+0 + 2i) = %lf + %lfi\n",           creal(z1), cimag(z1));Â
    // Complex(0, + INFINITY)    double complex z2 = 2                        * catan(2 * I * DBL_MAX);    printf("2*catan(+0 + i*Inf) = %lf%+lfi\n",           creal(z2), cimag(z2));Â
    printf("\n");Â
    // Function catanf()    float complex z3 = catanf(2 * I);    printf("catanf(+0 + 2i) = %f + %fi\n",           crealf(z3), cimagf(z3));Â
    // Complex(0, + INFINITY)    float complex z4 = 2                       * catanf(2 * I * DBL_MAX);    printf("2*catanf(+0 + i*Inf) = %f + %fi\n",           crealf(z4), cimagf(z4));Â
    printf("\n");Â
    // Function catanl()    long double complex z5 = catanl(2 * I);    printf("catan(+0+2i) = %Lf%+Lfi\n",           creall(z5), cimagl(z5));Â
    // Complex(0, + INFINITY)    long double complex z6 = 2                             * catanl(2 * I * DBL_MAX);    printf("2*catanl(+0 + i*Inf) = %Lf + %Lfi\n",           creall(z6), cimagl(z6));} |
catan(+0 + 2i) = 1.570796 + 0.549306i 2*catan(+0 + i*Inf) = 3.141593+0.000000i catanf(+0 + 2i) = 1.570796 + 0.549306i 2*catanf(+0 + i*Inf) = 3.141593 + 0.000000i catan(+0+2i) = 1.570796+0.549306i 2*catanl(+0 + i*Inf) = 3.141593 + 0.000000i
Program 3: This program will illustrate the functions catanh(), catanhf(), and catanhl() computes the complex arc hyperbolic tangent of z along the real axis and in the interval [-i*PI/2, +i*PI/2] along the imaginary axis.Â
C
// C program to illustrate the use// of functions catanh(), catanhf(),// and catanhl()#include <complex.h>#include <stdio.h>Â
// Driver Codeint main(){    // Function catanh()    double complex z1 = catanh(2);    printf("catanh(+2+0i) = %lf%+lfi\n",           creal(z1), cimag(z1));Â
    // for any z, atanh(z) = atan(iz)/i    // I denotes Imaginary    // part of the complex number    double complex z2 = catanh(1 + 2 * I);    printf("catanh(1+2i) = %lf%+lfi\n\n",           creal(z2), cimag(z2));Â
    // Function catanhf()    float complex z3 = catanhf(2);    printf("catanhf(+2+0i) = %f%+fi\n",           crealf(z3), cimagf(z3));Â
    // for any z, atanh(z) = atan(iz)/i    float complex z4 = catanhf(1 + 2 * I);    printf("catanhf(1+2i) = %f%+fi\n\n",           crealf(z4), cimagf(z4));Â
    // Function catanh()    long double complex z5 = catanhl(2);    printf("catanhl(+2+0i) = %Lf%+Lfi\n",           creall(z5), cimagl(z5));Â
    // for any z, atanh(z) = atan(iz)/i    long double complex z6 = catanhl(1 + 2 * I);    printf("catanhl(1+2i) = %Lf%+Lfi\n\n",           creall(z6), cimagl(z6));} |
catanh(+2+0i) = 0.549306+1.570796i catanh(1+2i) = 0.173287+1.178097i catanhf(+2+0i) = 0.549306+1.570796i catanhf(1+2i) = 0.173287+1.178097i catanhl(+2+0i) = 0.549306+1.570796i catanhl(1+2i) = 0.173287+1.178097i
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

