Enter three known values to find the fourth. Leave the unknown field empty or type "x".
:=:
Ratio Simplifier
Enter two numbers to reduce them to their simplest form.
:
Understanding Ratios and Proportions
A ratio is a mathematical comparison between two numbers that indicates how many times the first number contains the second. For instance, if a bowl of fruit contains eight oranges and six lemons, the ratio of oranges to lemons is 8:6. In mathematics, we often want to simplify these relationships or find missing values when we know the relationship must remain constant.
How to Solve a Proportion
A proportion is an equation that states that two ratios are equal. The formula for solving a proportion is A/B = C/D. To find a missing value, you can use cross-multiplication:
If A is unknown: A = (B * C) / D
If B is unknown: B = (A * D) / C
If C is unknown: C = (A * D) / B
If D is unknown: D = (B * C) / A
Example: Recipe Scaling
A recipe requires 2 cups of flour for 3 people. How much flour (x) is needed for 9 people?
Ratio: 2 : 3 = x : 9
Calculation: (2 * 9) / 3 = 6 cups.
Simplifying Ratios
To simplify a ratio, you must find the Greatest Common Divisor (GCD) of both numbers and divide each part of the ratio by that number. For example, the ratio 12:18 can be simplified. The GCD of 12 and 18 is 6. Dividing both by 6 gives us a simplified ratio of 2:3.
Common Applications
Aspect Ratios: Standard television screens have an aspect ratio of 16:9.
Chemistry: Calculating the molar ratio of reactants in a chemical equation.
Map Scales: Determining actual distance based on a map scale of 1:10,000.
Photography: Maintaining proportions when resizing images to prevent distortion.
function solveProportion() {
var a = document.getElementById("propA").value.toLowerCase();
var b = document.getElementById("propB").value.toLowerCase();
var c = document.getElementById("propC").value.toLowerCase();
var d = document.getElementById("propD").value.toLowerCase();
var resultDiv = document.getElementById("propResult");
var valA = parseFloat(a);
var valB = parseFloat(b);
var valC = parseFloat(c);
var valD = parseFloat(d);
var countEmpty = 0;
if (isNaN(valA)) countEmpty++;
if (isNaN(valB)) countEmpty++;
if (isNaN(valC)) countEmpty++;
if (isNaN(valD)) countEmpty++;
if (countEmpty !== 1) {
resultDiv.style.display = "block";
resultDiv.innerHTML = "Error: Please provide exactly three numbers to solve for the fourth.";
return;
}
var solvedValue = 0;
var label = "";
if (isNaN(valA)) {
solvedValue = (valB * valC) / valD;
label = "A";
} else if (isNaN(valB)) {
solvedValue = (valA * valD) / valC;
label = "B";
} else if (isNaN(valC)) {
solvedValue = (valA * valD) / valB;
label = "C";
} else if (isNaN(valD)) {
solvedValue = (valB * valC) / valA;
label = "D";
}
if (!isFinite(solvedValue)) {
resultDiv.style.display = "block";
resultDiv.innerHTML = "Error: Calculation resulted in an invalid number (possible division by zero).";
} else {
resultDiv.style.display = "block";
resultDiv.innerHTML = "The missing value (" + label + ") is: " + solvedValue.toLocaleString(undefined, {maximumFractionDigits: 4}) + "";
}
}
function simplifyRatio() {
var a = parseInt(document.getElementById("simpA").value);
var b = parseInt(document.getElementById("simpB").value);
var resultDiv = document.getElementById("simpResult");
if (isNaN(a) || isNaN(b) || a <= 0 || b <= 0) {
resultDiv.style.display = "block";
resultDiv.innerHTML = "Error: Please enter two positive whole numbers.";
return;
}
var getGCD = function(x, y) {
while (y) {
var t = y;
y = x % y;
x = t;
}
return x;
};
var divisor = getGCD(a, b);
var simpleA = a / divisor;
var simpleB = b / divisor;
resultDiv.style.display = "block";
resultDiv.innerHTML = "Simplified Ratio: " + simpleA + " : " + simpleB + " (Divided by GCD: " + divisor + ")";
}