Trig Function Calculator

Trigonometric Function Calculator

Degrees (°) Radians (rad)

Results

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 side lengths and angles of triangles. This calculator allows you to find the values of the six primary trigonometric functions for any given angle, whether measured in degrees or radians.

The Primary Functions

  • Sine (sin): The ratio of the length of the side that is opposite that angle to the length of the hypotenuse.
  • Cosine (cos): The ratio of the length of the adjacent side to the length of the hypotenuse.
  • Tangent (tan): The ratio of the opposite side to the adjacent side (or sin/cos).

The Reciprocal Functions

  • Cosecant (csc): The reciprocal of sine (1/sin).
  • Secant (sec): The reciprocal of cosine (1/cos).
  • Cotangent (cot): The reciprocal of tangent (1/tan).

Degrees vs. Radians

Most calculators default to degrees, where a full circle is 360°. In advanced mathematics and physics, radians are preferred, where a full circle is 2π (approx 6.283) radians. To convert manually:

Radians = Degrees × (π / 180)

Common Angle Examples

Angle (°) Sin Cos Tan
0 1 0
30° 0.5 0.8660 0.5774
45° 0.7071 0.7071 1
60° 0.8660 0.5 1.7321
90° 1 0 Undefined
function calculateTrigonometry() { var val = document.getElementById('angleInput').value; var unit = document.getElementById('angleUnit').value; if (val === "" || isNaN(val)) { alert("Please enter a valid numeric angle."); return; } var angle = parseFloat(val); var rad; if (unit === "degrees") { rad = angle * (Math.PI / 180); } else { rad = angle; } var s = Math.sin(rad); var c = Math.cos(rad); var t = Math.tan(rad); // Precise display helper function formatRes(n) { if (Math.abs(n) 1e14) return "Undefined"; return Number(n.toFixed(6)).toString(); } // Helper for Undefined / Infinity cases function handleUndefined(funcVal) { if (!isFinite(funcVal) || Math.abs(funcVal) > 1e15) { return "Undefined"; } return formatRes(funcVal); } // Tangent check for odd multiples of 90 degrees var tanDisplay; if (unit === "degrees" && (angle – 90) % 180 === 0) { tanDisplay = "Undefined"; } else { tanDisplay = handleUndefined(t); } // Reciprocals var csc = 1 / s; var sec = 1 / c; var cot = 1 / t; // Output values document.getElementById('sinRes').innerText = formatRes(s); document.getElementById('cosRes').innerText = formatRes(c); document.getElementById('tanRes').innerText = tanDisplay; // Check for sine zero (csc undefined) document.getElementById('cscRes').innerText = (Math.abs(s) < 1e-14) ? "Undefined" : formatRes(csc); // Check for cosine zero (sec undefined) document.getElementById('secRes').innerText = (Math.abs(c) < 1e-14) ? "Undefined" : formatRes(sec); // Check for tan zero or tan undefined (cot cases) if (Math.abs(t) < 1e-14) { document.getElementById('cotRes').innerText = "Undefined"; } else if (tanDisplay === "Undefined") { document.getElementById('cotRes').innerText = "0"; } else { document.getElementById('cotRes').innerText = formatRes(cot); } document.getElementById('trigResults').style.display = 'block'; }

Leave a Comment