How to use Math.tan() Function In Javascript
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.
// Define the function
function findTangent(radian) {
return Math.tan(radian);
}
const radianValue = 60;
console.log("Tangent of", radianValue,
"radians is:",
findTangent(radianValue));
Output
Tangent of 60 radians is: 0.320040389379563
Time complexity: O(1).
Space complexity: O(1).
JavaScript Program to Find the Tangent of given Radian Value
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:
Table of Content
- Using Math.tan() Function
- Using Trigonometric Formula
Contact Us