Second-Order Homogeneous Linear ODE Solver
Results:
Enter coefficients and click "Solve ODE" to see the solution.
Results:
'; if (isNaN(a) || isNaN(b) || isNaN(c)) { resultDiv.innerHTML = outputHtml + 'Please enter valid numbers for all coefficients.'; return; } if (a === 0) { resultDiv.innerHTML = outputHtml + 'Coefficient \'a\' cannot be zero for a second-order differential equation. This would be a first-order equation.'; return; } // Characteristic Equation var charEq = "; if (a === 1) charEq += 'r²'; else if (a === -1) charEq += '-r²'; else charEq += a + 'r²'; if (b > 0) charEq += ' + ' + (b === 1 ? 'r' : b + 'r'); else if (b 0) charEq += ' + ' + c; else if (c < 0) charEq += ' – ' + Math.abs(c); charEq += ' = 0'; outputHtml += 'Characteristic Equation: ' + charEq + "; // Discriminant var discriminant = b * b – 4 * a * c; outputHtml += 'Discriminant (Δ): ' + discriminant + "; var solutionType = "; var generalSolution = "; if (discriminant > 0) { // Distinct Real Roots var r1 = (-b + Math.sqrt(discriminant)) / (2 * a); var r2 = (-b – Math.sqrt(discriminant)) / (2 * a); solutionType = 'Distinct Real Roots'; outputHtml += 'Roots: r₁ = ' + r1.toFixed(4) + ', r₂ = ' + r2.toFixed(4) + "; var term1 = 'C₁'; if (r1 !== 0) { if (r1 === 1) term1 += 'eˣ'; else if (r1 === -1) term1 += 'e⁻ˣ'; else term1 += 'e^(' + r1.toFixed(4) + 'x)'; } var term2 = 'C₂'; if (r2 !== 0) { if (r2 === 1) term2 += 'eˣ'; else if (r2 === -1) term2 += 'e⁻ˣ'; else term2 += 'e^(' + r2.toFixed(4) + 'x)'; } generalSolution = 'y(x) = ' + term1 + ' + ' + term2; } else if (discriminant === 0) { // Repeated Real Roots var r = -b / (2 * a); solutionType = 'Repeated Real Roots'; outputHtml += 'Root: r = ' + r.toFixed(4) + ' (multiplicity 2)'; var expTerm = "; if (r === 0) expTerm = "; // e^0x = 1 else if (r === 1) expTerm = 'eˣ'; else if (r === -1) expTerm = 'e⁻ˣ'; else expTerm = 'e^(' + r.toFixed(4) + 'x)'; generalSolution = 'y(x) = C₁' + expTerm + ' + C₂x' + expTerm; } else { // Complex Conjugate Roots var alpha = -b / (2 * a); var beta = Math.sqrt(Math.abs(discriminant)) / (2 * a); solutionType = 'Complex Conjugate Roots'; outputHtml += 'Roots: r₁ = ' + alpha.toFixed(4) + ' + ' + beta.toFixed(4) + 'i, r₂ = ' + alpha.toFixed(4) + ' – ' + beta.toFixed(4) + 'i'; var expAlphaTerm = "; if (alpha === 0) expAlphaTerm = "; // e^0x = 1 else if (alpha === 1) expAlphaTerm = 'eˣ'; else if (alpha === -1) expAlphaTerm = 'e⁻ˣ'; else expAlphaTerm = 'e^(' + alpha.toFixed(4) + 'x)'; var cosTerm = 'cos(' + (beta === 1 ? 'x' : beta.toFixed(4) + 'x') + ')'; var sinTerm = 'sin(' + (beta === 1 ? 'x' : beta.toFixed(4) + 'x') + ')'; generalSolution = 'y(x) = ' + (expAlphaTerm ? expAlphaTerm + '(' : ") + 'C₁' + cosTerm + ' + C₂' + sinTerm + (expAlphaTerm ? ')' : "); } outputHtml += 'Solution Type: ' + solutionType + "; outputHtml += 'General Solution: ' + generalSolution + "; resultDiv.innerHTML = outputHtml; }Understanding Second-Order Homogeneous Linear Differential Equations
Differential equations are fundamental tools in mathematics, physics, engineering, and many other scientific fields. They describe how a quantity changes with respect to one or more independent variables. Among the various types, the second-order homogeneous linear differential equation with constant coefficients is particularly common and solvable using a straightforward algebraic method.
What is a Second-Order Homogeneous Linear ODE?
A differential equation is classified as:
- Second-Order: Because the highest derivative present in the equation is the second derivative (y").
- Homogeneous: Because all terms in the equation involve the dependent variable y or its derivatives, and there is no independent term (i.e., it equals zero).
- Linear: Because y and its derivatives appear only to the first power and are not multiplied together.
- Constant Coefficients: Because the coefficients multiplying y", y', and y are constant numbers, not functions of the independent variable (e.g., x).
The general form of such an equation is:
a y" + b y' + c y = 0
Where 'a', 'b', and 'c' are constant coefficients, and 'a' cannot be zero (otherwise, it would be a first-order equation).
The Characteristic Equation
To solve this type of differential equation, we assume a solution of the form y(x) = e^(rx), where 'r' is a constant. Taking the first and second derivatives:
- y' = r e^(rx)
- y" = r² e^(rx)
Substituting these into the original differential equation gives:
a (r² e^(rx)) + b (r e^(rx)) + c (e^(rx)) = 0
Since e^(rx) is never zero, we can divide it out, leading to the characteristic equation (also known as the auxiliary equation):
a r² + b r + c = 0
This is a standard quadratic equation, and its roots 'r' determine the form of the general solution to the differential equation.
Solving the Characteristic Equation: The Discriminant
The roots of the quadratic equation a r² + b r + c = 0 can be found using the quadratic formula:
r = [-b ± sqrt(b² – 4ac)] / (2a)
The term b² - 4ac is called the discriminant (Δ). Its value dictates the nature of the roots and, consequently, the form of the general solution:
Case 1: Distinct Real Roots (Δ > 0)
If the discriminant is positive, there are two distinct real roots, r₁ and r₂. The general solution is a linear combination of two exponential functions:
y(x) = C₁e^(r₁x) + C₂e^(r₂x)
Where C₁ and C₂ are arbitrary constants determined by initial or boundary conditions.
Example: For y" + 3y' + 2y = 0 (a=1, b=3, c=2)
- Characteristic Equation: r² + 3r + 2 = 0
- Discriminant: 3² – 4(1)(2) = 9 – 8 = 1 (Δ > 0)
- Roots: r = [-3 ± sqrt(1)] / 2 = (-3 ± 1) / 2. So, r₁ = -1, r₂ = -2.
- General Solution: y(x) = C₁e^(-x) + C₂e^(-2x)
Case 2: Repeated Real Roots (Δ = 0)
If the discriminant is zero, there is one real root 'r' with multiplicity two (r₁ = r₂ = r = -b / 2a). In this case, the general solution is:
y(x) = C₁e^(rx) + C₂xe^(rx)
The 'x' term in the second part ensures linear independence of the solutions.
Example: For y" + 2y' + y = 0 (a=1, b=2, c=1)
- Characteristic Equation: r² + 2r + 1 = 0
- Discriminant: 2² – 4(1)(1) = 4 – 4 = 0 (Δ = 0)
- Root: r = -2 / 2 = -1. So, r₁ = r₂ = -1.
- General Solution: y(x) = C₁e^(-x) + C₂xe^(-x)
Case 3: Complex Conjugate Roots (Δ < 0)
If the discriminant is negative, there are two complex conjugate roots. These can be written as r₁ = α + iβ and r₂ = α – iβ, where α = -b / 2a and β = sqrt(|Δ|) / 2a. The general solution involves trigonometric functions:
y(x) = e^(αx) (C₁cos(βx) + C₂sin(βx))
Example: For y" + 2y' + 5y = 0 (a=1, b=2, c=5)
- Characteristic Equation: r² + 2r + 5 = 0
- Discriminant: 2² – 4(1)(5) = 4 – 20 = -16 (Δ < 0)
- Roots: r = [-2 ± sqrt(-16)] / 2 = (-2 ± 4i) / 2. So, r₁ = -1 + 2i, r₂ = -1 – 2i.
- Here, α = -1 and β = 2.
- General Solution: y(x) = e^(-x) (C₁cos(2x) + C₂sin(2x))
This calculator helps you quickly determine the characteristic equation, its roots, and the general solution for second-order homogeneous linear differential equations with constant coefficients by simply inputting the 'a', 'b', and 'c' coefficients.