Math Atan Function - C++ Programming Tutorial
C++ Course / Math Functions / Math Atan Function

Math Atan Function

BLUF: Mastering Math Atan Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Math Atan Function

C++ is renowned for its efficiency. Learn how Math Atan Function enables low-level control and high-performance computing in the tutorial below.

C++ Math atan

The function calculates the arctangent of a value provided in radians.

Syntax

Suppose a number is 'x'. Syntax would be:

Example

float atan(float x);
double atan(double x);
long double atan(long double x);
double atan(integral x);

Note: If the value passed is an integer type, then it is cast to double.

Parameter

x : The value for which the arctangent needs to be determined.

Return value

It returns the value in the range[-∏/2, ∏/2].

Example 1

Let's examine a basic scenario where the value of x equals zero.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
    float degree=0;
    float x=degree*3.14/180;
    std::cout << "Value of tangent is :" <<tan(x)<< std::endl;
    cout<<"Inverse of tangent is :"<<atan(x);
    return 0;
}

Output:

Output

Value of tangent is :0
Inverse of tangent is :0

In this instance, the atan method computes the arctangent of a value if x is set to zero.

Example 2

Let's consider a basic scenario where the value of x is less than zero.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
    float degree= -67;
    float x=degree*3.14/180;
    std::cout << "Value of tangent is : " <<tan(x)<< std::endl;
    cout<<"Inverse of tangent is : "<<atan(x);
    return 0;
}

Output:

Output

Value of tangent is : -2.35197
Inverse of tangent is : -0.863063

In this illustration, the atan function computes the arctangent of a number if the x value is negative.

Example 3

Let's observe a basic scenario where the value of x is greater than zero.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
    float degree=30;
    float x=degree*3.14/180;
    std::cout << "Value of tangent is : " <<tan(x)<< std::endl;
    cout<<"Inverse of tangent is : "<<atan(x);
    return 0;
}

Output:

Output

Value of tangent is : 0.576996
Inverse of tangent is : 0.48214

In this instance, the atan function computes the arctangent of a number given that the value of x is positive.

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience