Lua atan()

abereFejiro9953409650's avatar
Published Oct 14, 2023
Contribute to Docs

The atan() function in Lua’s math library evaluates the arctangent (inverse tangent) of a given number. The arctangent is the angle in radians (the answer returned) whose tangent is equal to the given value.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.
    • Beginner Friendly.
      4 hours

Syntax

math.atan(x)
  • x: The number representing the tangent.

Example

In this example, math.atan() calculates the arctangent of 1.

local x = 1
local answer = math.atan(x)
local output = string.format("The arctangent of %.2f is approximately %.4f", x, answer)
print(output)

This will result in the following output below.

The arctangent of 1.00 is approximately 0.7854

All contributors

Contribute to Docs

Learn Lua on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.
    • Beginner Friendly.
      4 hours