Cos Calculator

Cos (Cosine) Calculator

Calculate the cosine value of any angle in degrees or radians instantly.

Degrees (°) Radians (rad)
Result: cos(θ)

What is the Cosine Function?

The cosine function (abbreviated as "cos") is a fundamental trigonometric ratio used in mathematics and physics. In a right-angled triangle, the cosine of an angle (θ) is defined as the length of the adjacent side divided by the length of the hypotenuse.

The Formula:
cos(θ) = Adjacent / Hypotenuse

How to Use the Cos Calculator

Using this tool is straightforward. Follow these steps to find the cosine of any value:

  1. Input the Angle: Type the numeric value of the angle you wish to calculate.
  2. Choose the Unit: Select whether the input is in Degrees or Radians. Note: Most standard mathematics uses degrees for geometry, while calculus often uses radians.
  3. Click Calculate: The tool will perform the trigonometric calculation using the Math.cos function.

Common Cosine Values Table

Angle (Degrees) Angle (Radians) Cos(θ) Result
0 1
30° π/6 √3 / 2 (≈0.866)
45° π/4 √2 / 2 (≈0.707)
60° π/3 0.5
90° π/2 0

Practical Example

If you have a right triangle with a 60-degree angle and a hypotenuse of 10 units, and you want to find the length of the adjacent side, you would calculate cos(60°) which equals 0.5. Multiplying 0.5 by the hypotenuse (10) gives you 5 units for the adjacent side length.

function calculateCosine() { var angleInput = document.getElementById("angleInput").value; var unitType = document.getElementById("unitType").value; var resultContainer = document.getElementById("cosResultContainer"); var outputValue = document.getElementById("cosValueOutput"); var secondaryResults = document.getElementById("secondaryResults"); if (angleInput === "") { alert("Please enter a numeric value for the angle."); return; } var angle = parseFloat(angleInput); if (isNaN(angle)) { alert("Please enter a valid number."); return; } var originalAngle = angle; var radians; if (unitType === "degrees") { radians = angle * (Math.PI / 180); } else { radians = angle; } var cosValue = Math.cos(radians); // Cleaning up floating point issues for common angles like 90 deg if (unitType === "degrees" && Math.abs(angle % 180) === 90) { cosValue = 0; } else if (unitType === "degrees" && Math.abs(angle % 360) === 0) { cosValue = 1; } else if (unitType === "degrees" && Math.abs(angle % 360) === 180) { cosValue = -1; } var roundedCos = parseFloat(cosValue.toFixed(10)); outputValue.innerHTML = roundedCos; var secantValue = (cosValue === 0) ? "Undefined" : (1 / cosValue).toFixed(6); var sinValue = Math.sin(radians).toFixed(6); secondaryResults.innerHTML = "Related Functions:" + "Secant (sec): " + secantValue + "" + "Sine (sin): " + sinValue + "" + "Input in " + (unitType === "degrees" ? "Radians: " + (angle * (Math.PI / 180)).toFixed(6) : "Degrees: " + (angle * (180 / Math.PI)).toFixed(2) + "°"); resultContainer.style.display = "block"; }

Leave a Comment