Enter an angle in degrees or radians to calculate its sine, cosine, tangent, cosecant, secant, and cotangent.
Degrees
Radians
Trigonometric Values
Sine (sin):—
Cosine (cos):—
Tangent (tan):—
Cosecant (csc):—
Secant (sec):—
Cotangent (cot):—
Understanding Trigonometric Functions
Trigonometry is a branch of mathematics that studies relationships between the sides and angles of triangles. The six basic trigonometric functions (sine, cosine, tangent, cosecant, secant, and cotangent) are fundamental to understanding these relationships, particularly in right-angled triangles and the unit circle. They are essential tools in fields like physics, engineering, navigation, computer graphics, and more.
The Six Trigonometric Functions
Consider a right-angled triangle with one angle θ (theta), an opposite side (O), an adjacent side (A), and a hypotenuse (H). The basic trigonometric functions are defined as ratios of these sides:
Sine (sin θ): The ratio of the length of the opposite side to the length of the hypotenuse. sin(θ) = O / H
Cosine (cos θ): The ratio of the length of the adjacent side to the length of the hypotenuse. cos(θ) = A / H
Tangent (tan θ): The ratio of the length of the opposite side to the length of the adjacent side. tan(θ) = O / A
The other three trigonometric functions are the reciprocals of these basic three:
Cosecant (csc θ): The reciprocal of sine. csc(θ) = 1 / sin(θ) = H / O
Secant (sec θ): The reciprocal of cosine. sec(θ) = 1 / cos(θ) = H / A
Cotangent (cot θ): The reciprocal of tangent. cot(θ) = 1 / tan(θ) = A / O
Using the Unit Circle
Trigonometric functions can also be understood using the unit circle (a circle with a radius of 1 centered at the origin). For any angle θ measured from the positive x-axis, a point (x, y) on the unit circle corresponds to:
cos(θ) = x
sin(θ) = y
tan(θ) = y / x
The reciprocal functions follow directly from these definitions.
Degrees vs. Radians
Angles can be measured in two primary units: degrees and radians.
Degrees: A full circle is 360 degrees (°). 90° is a right angle, 180° is a straight angle.
Radians: A full circle is 2π radians. A straight angle is π radians, and a right angle is π/2 radians. Radians are often preferred in calculus and higher mathematics because they simplify many formulas.
Conversion between the two is straightforward:
To convert degrees to radians: radians = degrees × (π / 180)
To convert radians to degrees: degrees = radians × (180 / π)
Calculator Usage and Examples
This calculator allows you to input an angle in either degrees or radians and will compute the values for all six trigonometric functions. This is useful for:
Solving trigonometric equations.
Working with periodic functions like waves.
Performing calculations in geometry and physics problems involving angles.
Example 1: Calculate the trig functions for 45 degrees.
Example 2: Calculate the trig functions for π/2 radians (which is 90 degrees).
Input Angle Value: 1.57079632679 (or Math.PI / 2 if using a calculator that supports it)
Select Angle Unit: Radians
Expected Results: sin(π/2) = 1, cos(π/2) ≈ 0 (very close to zero due to floating-point precision), tan(π/2) is undefined, csc(π/2) = 1, sec(π/2) is undefined, cot(π/2) ≈ 0.
Note: When a function is undefined (e.g., tangent of 90 degrees or π/2 radians, secant of 90 degrees), the calculator will display "Undefined" or a very large number approaching infinity due to floating-point limitations.
function calculateTrig() {
var angleInput = document.getElementById("angleValue");
var unitSelect = document.getElementById("angleUnit");
var errorMessageDiv = document.getElementById("errorMessage");
var resultsContainer = document.getElementById("resultsContainer");
var angleValue = parseFloat(angleInput.value);
var unit = unitSelect.value;
errorMessageDiv.style.display = 'none';
resultsContainer.style.display = 'none';
document.getElementById("sineResult").textContent = "–";
document.getElementById("cosineResult").textContent = "–";
document.getElementById("tangentResult").textContent = "–";
document.getElementById("cosecantResult").textContent = "–";
document.getElementById("secantResult").textContent = "–";
document.getElementById("cotangentResult").textContent = "–";
if (isNaN(angleValue)) {
errorMessageDiv.textContent = "Please enter a valid number for the angle.";
errorMessageDiv.style.display = 'block';
return;
}
var angleInRadians;
if (unit === "degrees") {
angleInRadians = angleValue * (Math.PI / 180);
} else {
angleInRadians = angleValue;
}
// Small tolerance for checking near-zero values that lead to undefined reciprocals
var tolerance = 1e-10;
var sinVal = Math.sin(angleInRadians);
var cosVal = Math.cos(angleInRadians);
var tanVal = Math.tan(angleInRadians);
var cscVal, secVal, cotVal;
// Handle potential division by zero or near-zero for reciprocals
if (Math.abs(sinVal) < tolerance) {
cscVal = "Undefined";
} else {
cscVal = 1 / sinVal;
}
if (Math.abs(cosVal) < tolerance) {
secVal = "Undefined";
} else {
secVal = 1 / cosVal;
}
if (Math.abs(tanVal) < tolerance) {
// Tangent is zero, so cotangent is undefined.
cotVal = "Undefined";
} else if (tanVal === Infinity || tanVal === -Infinity || isNaN(tanVal)) {
// Tangent is undefined (e.g., at pi/2, 3pi/2), so cotangent is zero.
cotVal = 0;
}
else {
cotVal = 1 / tanVal;
}
// Format results to a reasonable number of decimal places
var formatResult = function(value) {
if (typeof value === "number") {
// Check if the value is very close to an integer
if (Math.abs(value – Math.round(value)) < tolerance) {
return Math.round(value).toString();
}
// Check if the value is very close to zero
if (Math.abs(value) < tolerance) {
return "0";
}
return value.toFixed(6); // Display up to 6 decimal places
}
return value; // Return "Undefined" as is
};
document.getElementById("sineResult").textContent = formatResult(sinVal);
document.getElementById("cosineResult").textContent = formatResult(cosVal);
document.getElementById("tangentResult").textContent = formatResult(tanVal);
document.getElementById("cosecantResult").textContent = formatResult(cscVal);
document.getElementById("secantResult").textContent = formatResult(secVal);
document.getElementById("cotangentResult").textContent = formatResult(cotVal);
resultsContainer.style.display = 'block';
}