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.

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