Skip to main content Link Search Menu Expand Document Toggle dark mode Copy Code (external link)

tan() : Tangent Function

Calculate the tangent of an angle (in radians).


On this page

Signature

tan(angleInRadians)

Parameters

Parameter Type Required Description
angleInRadians Number Yes The angle in radians

Returns

Type: Double

The tangent of the angle.


Examples

Basic Tangent

<p>tan(0) = {{format(tan(0), '0.000')}}</p>
<p>tan(Ï€/4) = {{format(tan(pi() / 4), '0.000')}}</p>

Output:

<p>tan(0) = 0.000</p>
<p>tan(Ï€/4) = 1.000</p>

Convert Degrees

<p>tan(45°) = {{format(tan(radians(45)), '0.000')}}</p>

Output:

<p>tan(45°) = 1.000</p>

Calculate Slope

<p>Slope: {{format(tan(model.angle), '0.00')}}</p>

Data:

doc.Params["model"] = new {
    angle = Math.PI / 6  // 30 degrees
};

Output:

<p>Slope: 0.58</p>

Notes

  • Input must be in radians (not degrees)
  • Undefined at Ï€/2, 3Ï€/2, etc. (where cosine = 0)
  • For degrees, use: tan(radians(degrees))
  • tan(x) = sin(x) / cos(x)
  • Common values:
    • tan(0) = 0
    • tan(Ï€/4) = 1
    • tan(Ï€/6) ≈ 0.577

See Also