tan() : Tangent Function
On this page
Summary
Calculate the tangent of an angle (in radians).
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
Output:
<p>tan(0) = 0.000</p>
<p>tan(π/4) = 1.000</p>
Convert Degrees
Output:
<p>tan(45°) = 1.000</p>
Calculate Slope
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