VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-program-to-find-the-tangent-of-given-radian-value/

⇱ JavaScript Program to Find the Tangent of given Radian Value - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Program to Find the Tangent of given Radian Value

Last Updated : 5 Aug, 2025

Given a radian value, our task is to find a tangent using JavaScript. Tangent (tan) is a trigonometric function which is the ratio of the length of the side opposite to an angle to the length of the adjacent side in a right triangle.

Example:

Input: 45 degrees 

Output: 1

Below are the approaches to find the tangent of a given radian value using JavaScript:

Using Math.tan() Function

Create a function that takes a radian parameter. Inside the function, use the Math.tan() function provided by JavaScript's Math object to calculate the tangent of the given radian value. Return the calculated tangent value.

Example: The example below shows finding the tangent of a given radian value Using Math.tan() Function.


Output
Tangent of 60 radians is: 0.320040389379563

Time complexity: O(1).

Space complexity: O(1).

Using Trigonometric Formula

Create a function that takes a radian parameter. Inside the function, use the Math.sin() function to calculate the sine of the given radian value and use the Math.cos() function to calculate the cosine of the radian value. Divide the sine value by the cosine value to obtain the tangent of the given radian value. Return the calculated tangent value.

Example: The example below shows finding the tangent of a given radian value Using Math.tan() Function.


Output
Tangent of 45 radians is: 1.6197751905438615

Time complexity: O(1).

Space complexity: O(1).

Comment