Calculator with Sin Tan Cos

Trigonometric Function Calculator

Enter an angle value and select its unit (degrees or radians) to calculate its Sine, Cosine, and Tangent.

Degrees Radians

Results:

Sine (sin):

Cosine (cos):

Tangent (tan):

.trig-calculator-container { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 8px; padding: 20px; max-width: 500px; margin: 20px auto; box-shadow: 0 4px 8px rgba(0,0,0,0.1); } .trig-calculator-container h2 { color: #333; text-align: center; margin-bottom: 20px; } .trig-calculator-container p { color: #555; line-height: 1.6; } .trig-input-group { margin-bottom: 15px; } .trig-input-group label { display: block; margin-bottom: 5px; font-weight: bold; color: #444; } .trig-input-group input[type="number"], .trig-input-group select { width: calc(100% – 22px); padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; } .trig-calculator-container button { background-color: #007bff; color: white; padding: 12px 20px; border: none; border-radius: 4px; cursor: pointer; font-size: 18px; width: 100%; transition: background-color 0.3s ease; } .trig-calculator-container button:hover { background-color: #0056b3; } .trig-results { margin-top: 25px; padding-top: 15px; border-top: 1px solid #eee; } .trig-results h3 { color: #333; margin-bottom: 10px; } .trig-results p { font-size: 1.1em; margin-bottom: 8px; } .trig-results span { font-weight: bold; color: #007bff; } function calculateTrigFunctions() { var angleInput = document.getElementById('angleInput').value; var angleUnit = document.getElementById('angleUnit').value; var errorMessage = document.getElementById('errorMessage'); errorMessage.textContent = "; // Clear previous errors if (angleInput === " || isNaN(angleInput)) { errorMessage.textContent = 'Please enter a valid number for the angle.'; document.getElementById('sinResult').textContent = "; document.getElementById('cosResult').textContent = "; document.getElementById('tanResult').textContent = "; return; } var angle = parseFloat(angleInput); var angleInRadians; if (angleUnit === 'degrees') { angleInRadians = angle * (Math.PI / 180); } else { // radians angleInRadians = angle; } var sinVal = Math.sin(angleInRadians); var cosVal = Math.cos(angleInRadians); var tanVal; // Check for tangent at odd multiples of PI/2 (90, 270 degrees) // Use a small epsilon for floating point comparison var isTangentUndefined = false; var remainder = Math.abs(angleInRadians % Math.PI); // Angle modulo PI var halfPi = Math.PI / 2; // Check if angle is close to PI/2 or 3*PI/2 (or 5*PI/2 etc.) // This means angleInRadians is (2n+1)*PI/2 if (Math.abs(remainder – halfPi) < 1e-9) { // Check if it's close to PI/2 isTangentUndefined = true; } if (isTangentUndefined) { tanVal = 'Undefined'; } else { tanVal = Math.tan(angleInRadians); } document.getElementById('sinResult').textContent = sinVal.toFixed(6); document.getElementById('cosResult').textContent = cosVal.toFixed(6); document.getElementById('tanResult').textContent = (typeof tanVal === 'number') ? tanVal.toFixed(6) : tanVal; } // Run calculation on page load with default values window.onload = calculateTrigFunctions;

Understanding Sine, Cosine, and Tangent

Trigonometric functions are fundamental in mathematics, especially in geometry and physics, for relating angles of a triangle to the lengths of its sides. The three primary functions are Sine (sin), Cosine (cos), and Tangent (tan).

What They Represent:

  • Sine (sin): In a right-angled triangle, the sine of an angle is the ratio of the length of the side opposite the angle to the length of the hypotenuse.
  • Cosine (cos): The cosine of an angle is the ratio of the length of the adjacent side to the length of the hypotenuse.
  • Tangent (tan): The tangent of an angle is the ratio of the length of the opposite side to the length of the adjacent side. It can also be expressed as sin(angle) / cos(angle).

Degrees vs. Radians:

Angles can be measured in two common units: degrees and radians.

  • Degrees: A full circle is 360 degrees. This is the more commonly understood unit for everyday use.
  • Radians: A full circle is 2π radians. Radians are often preferred in higher mathematics and physics because they simplify many formulas, especially those involving calculus. One radian is the angle subtended at the center of a circle by an arc that is equal in length to the radius of the circle.

The conversion between them is: 180 degrees = π radians.

How to Use This Calculator:

  1. Enter Angle Value: Input the numerical value of the angle you wish to calculate. For example, enter '30' for 30 degrees or '0.5' for 0.5 radians.
  2. Select Angle Unit: Choose whether your input angle is in 'Degrees' or 'Radians' from the dropdown menu.
  3. Click 'Calculate': The calculator will instantly display the Sine, Cosine, and Tangent values for your specified angle.

Practical Applications:

Trigonometric functions are crucial in various fields:

  • Engineering: Used in structural analysis, electrical engineering (AC circuits), and mechanical design.
  • Physics: Essential for describing wave motion, oscillations, projectile motion, and analyzing forces.
  • Computer Graphics: Used for rotations, transformations, and rendering 3D objects.
  • Navigation: Historically used in celestial navigation and modern GPS systems.
  • Architecture: For calculating angles and dimensions in building designs.

Examples:

  • Angle: 0 degrees (0 radians)
    • sin(0) = 0
    • cos(0) = 1
    • tan(0) = 0
  • Angle: 30 degrees (π/6 radians ≈ 0.523599 radians)
    • sin(30°) = 0.5
    • cos(30°) ≈ 0.866025
    • tan(30°) ≈ 0.577350
  • Angle: 45 degrees (π/4 radians ≈ 0.785398 radians)
    • sin(45°) ≈ 0.707107
    • cos(45°) ≈ 0.707107
    • tan(45°) = 1
  • Angle: 90 degrees (π/2 radians ≈ 1.570796 radians)
    • sin(90°) = 1
    • cos(90°) = 0
    • tan(90°) = Undefined (as division by zero)

Leave a Reply

Your email address will not be published. Required fields are marked *