What is numpy.arctan2() in Numpy?

Learn via video courses
Topics Covered

Trigonometry is one of the various branches of mathematics that deals with the study of the relationship between the sides and angles of a right-angled triangle. It is one of the most popular and sought-after fields in science.

In this article, we will learn about the arctan2() function in NumPy, which helps us to find the inverse of the tangent between two radians. Finding the inverse of the tangent between two radians helps us to choose a quadrant correctly.

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Syntax

The syntax of arctan2() function is:

Parameters

The parameters that go in with arctan2() function are:

  • arr1: This mandatory parameter takes in y-coordinates.
  • arr2: This mandatory parameter takes in x-coordinates.
  • out: This optional parameter represents the location where the output will be stored.
  • where: This optional parameter is none by default. If it is true, a universal value will be computed at that place in the output array.
Sharpen Your Fundamentals with Free Learning

Return Type

When we use the arctan2() function, element-wise arc tangent coordinates are returned, which are in the interval of [π/2,π/2][-π/2, π/2]

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Examples

  • Basic Example using direct values

    To get hands-on with arctan2(), let's take a simple example in which we will take 2 arrays containing the x and y coordinates, respectively. After that, we will use the arctan2() function to generate the inverse of its tangent function.

    Output

  • Getting Output as Degree

    Many times, we need our trigonometric values, like the inverse of the tangent, to be in degrees rather than radians. There is a very straightforward method to convert radians into degrees using a loop.

    Output

    When we calculate the inverse of the tangent using arctan2(), we get a number that is not in degrees. Using the for loop and some calculations, we converted radians into degrees.

Difference Between arctan() and arctan2()

Arctan2 is an upgraded version of the basic arctan() function in NumPy. Here are the differences between arctan() and arctan2() in NumPy.

NumPy arctan()NumPy arctan2()
This is a 2-quadrant inverse function, which returns two quadrant valuesThis is a 4-quadrant inverse function, which returns four quadrant values
The range of arctan is from -90 to 90 degrees.The range of arctan is from -180 to 180 degrees.
This function can accept a single array as input.This function only accepts two arrays as input.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Conclusion

  • In this article, we covered what arctan2() is; a function that returns the inverse of a tangent.
  • We understood the syntax, different parameters that arctan2() takes, and the value that is returned.
  • To further solidify our understanding, we went through different examples in which we used arctan2(); used arctan2() to get direct output and also as degrees.
  • To conclude, we read the major differences between arctan() and arctan2() functions in NumPy; including the number of quadrants they return and their ranges.