Trigonometry is the branch of mathematics dealing with the relationships between the sides and angles of triangles. Whether you are a student solving a geometry problem or an engineer designing a bridge, understanding how to calculate sine, cosine, and tangent is essential.
The Fundamental Ratios: SOH CAH TOA
In a right-angled triangle, we define the three primary ratios based on an angle (θ):
When you calculate trig values, the unit of measurement is critical. Most calculators defaults to degrees, but in advanced calculus and physics, radians are preferred. 180 degrees is equal to π (approximately 3.14159) radians.
To convert Degrees to Radians: Multiply by π/180.
To convert Radians to Degrees: Multiply by 180/π.
Example Calculation
Suppose you have a ladder leaning against a wall at a 60-degree angle. If the ladder is 10 feet long (the hypotenuse), how high up the wall does it reach (the opposite side)?
Using the Sine function: sin(60°) = Height / 10. Since sin(60°) is roughly 0.866, the height is 0.866 * 10 = 8.66 feet.
Inverse Trigonometry
If you know the lengths of the sides but not the angle, you use inverse functions (Arcsine, Arccosine, or Arctangent). For example, if the opposite side is 5 and the hypotenuse is 10, the ratio is 0.5. Calculating arcsin(0.5) will give you 30°.
function runTrigCalculation() {
var val = parseFloat(document.getElementById('trig_angle_val').value);
var unit = document.getElementById('trig_angle_unit').value;
var func = document.getElementById('trig_func_type').value;
var display = document.getElementById('ratio_result_display');
if (isNaN(val)) {
display.innerHTML = 'Please enter a valid number';
return;
}
var rad = val;
if (unit === 'deg') {
rad = val * (Math.PI / 180);
}
var result;
try {
if (func === 'sin') result = Math.sin(rad);
else if (func === 'cos') result = Math.cos(rad);
else if (func === 'tan') {
if (Math.abs(Math.cos(rad)) < 1e-10) {
result = "Undefined (Asymptote)";
} else {
result = Math.tan(rad);
}
}
else if (func === 'sec') result = 1 / Math.cos(rad);
else if (func === 'csc') result = 1 / Math.sin(rad);
else if (func === 'cot') result = 1 / Math.tan(rad);
if (typeof result === 'number') {
display.innerHTML = 'Result: ' + result.toFixed(6) + '';
} else {
display.innerHTML = '' + result + '';
}
} catch (e) {
display.innerHTML = 'Calculation Error';
}
}
function runInverseCalculation() {
var val = parseFloat(document.getElementById('trig_ratio_val').value);
var unit = document.getElementById('trig_inv_unit').value;
var func = document.getElementById('trig_inv_func_type').value;
var display = document.getElementById('angle_result_display');
if (isNaN(val)) {
display.innerHTML = 'Please enter a valid number';
return;
}
// Domain checks for asin and acos
if ((func === 'asin' || func === 'acos') && (val 1)) {
display.innerHTML = 'Input must be between -1 and 1';
return;
}
var radResult;
if (func === 'asin') radResult = Math.asin(val);
else if (func === 'acos') radResult = Math.acos(val);
else if (func === 'atan') radResult = Math.atan(val);
var finalResult = radResult;
var unitLabel = " rad";
if (unit === 'deg') {
finalResult = radResult * (180 / Math.PI);
unitLabel = "°";
}
display.innerHTML = 'Angle: ' + finalResult.toFixed(4) + unitLabel + '';
}