A linear equation is an algebraic equation in which each term is either a constant or the product of a constant and a single variable. Solving these equations is a fundamental skill in mathematics, physics, and engineering.
1. Single Variable Equations
The standard form is ax + b = c. To find x, we follow these steps:
Subtract the constant b from both sides: ax = c – b
Divide both sides by the coefficient a: x = (c – b) / a
A system of equations consists of two or more equations with the same set of variables. We typically solve these using Cramer's Rule or the Elimination Method. For a 2×2 system:
a₁x + b₁y = c₁
a₂x + b₂y = c₂
Our calculator uses Cramer's Rule, which calculates the Determinant (D):
D = (a₁ * b₂) – (a₂ * b₁)
Dx = (c₁ * b₂) – (c₂ * b₁)
Dy = (a₁ * c₂) – (a₂ * c₁)
x = Dx / D, y = Dy / D
Practical Applications
Linear equations are used everywhere:
Economics: Finding the equilibrium point where supply equals demand.
Physics: Calculating velocity, time, and distance in uniform motion.
Chemistry: Balancing chemical equations and concentration mixtures.
Finance: Calculating simple interest and break-even points for businesses.
function solveSingleEquation() {
var a = parseFloat(document.getElementById('single_a').value);
var b = parseFloat(document.getElementById('single_b').value);
var c = parseFloat(document.getElementById('single_c').value);
var resultDiv = document.getElementById('single_result');
if (isNaN(a) || isNaN(b) || isNaN(c)) {
resultDiv.innerHTML = "Please enter valid numbers for a, b, and c.";
resultDiv.style.color = "#c0392b";
return;
}
if (a === 0) {
if (b === c) {
resultDiv.innerHTML = "Infinite solutions (Identity)";
} else {
resultDiv.innerHTML = "No solution (Contradiction)";
}
resultDiv.style.color = "#c0392b";
} else {
var x = (c – b) / a;
resultDiv.innerHTML = "Result: x = " + Number(x.toFixed(4));
resultDiv.style.color = "#27ae60";
}
}
function solveSystem() {
var a1 = parseFloat(document.getElementById('sys_a1').value);
var b1 = parseFloat(document.getElementById('sys_b1').value);
var c1 = parseFloat(document.getElementById('sys_c1').value);
var a2 = parseFloat(document.getElementById('sys_a2').value);
var b2 = parseFloat(document.getElementById('sys_b2').value);
var c2 = parseFloat(document.getElementById('sys_c2').value);
var resultDiv = document.getElementById('system_result');
if (isNaN(a1) || isNaN(b1) || isNaN(c1) || isNaN(a2) || isNaN(b2) || isNaN(c2)) {
resultDiv.innerHTML = "Please fill all fields with valid numbers.";
resultDiv.style.color = "#c0392b";
return;
}
// Cramer's Rule
var determinant = (a1 * b2) – (a2 * b1);
if (determinant === 0) {
var dx = (c1 * b2) – (c2 * b1);
var dy = (a1 * c2) – (a2 * c1);
if (dx === 0 && dy === 0) {
resultDiv.innerHTML = "The lines are coincident (Infinite solutions).";
} else {
resultDiv.innerHTML = "The lines are parallel (No solution).";
}
resultDiv.style.color = "#c0392b";
} else {
var x = ((c1 * b2) – (c2 * b1)) / determinant;
var y = ((a1 * c2) – (a2 * c1)) / determinant;
resultDiv.innerHTML = "Solution: x = " + Number(x.toFixed(4)) + ", y = " + Number(y.toFixed(4));
resultDiv.style.color = "#27ae60";
}
}