Differential Equations
Units and Topics
Unit 3. Second Order Linear Equations
3.5 Variation of Parameters
The method of undetermined coefficients works for a short list of forcings and for constant coefficients. The method of this topic finds a particular solution for any continuous forcing, and it also works for coefficients that depend on t, when a fundamental set of the homogeneous equation is known. This topic covers the idea of the method, its two formulas, three examples, and a comparison with the method of Topic 3.4.
You need Topics 3.1 and 3.4 for this topic. The topic uses the product rule, the Wronskian, and the integrals of exponential functions, of powers, and of the tangent.
1. The Idea of the Method
The equation is written in the standard form, with the coefficient 1 in front of y″.
y″ + p(t) y′ + q(t) y = g(t)Let y₁ and y₂ be a fundamental set of the homogeneous equation. The general solution of the homogeneous equation is c₁y₁ + c₂y₂ with constants c₁ and c₂. The method replaces the constants by unknown functions u₁(t) and u₂(t) and tries
yp = u₁y₁ + u₂y₂The constants are also called parameters, and the method lets them vary. This explains the name variation of parameters. The same idea appears in Topic 2.2: the solution of a first order linear equation is 1/μ times a function of t, where C/μ is the homogeneous solution.
The trial function has two unknown functions, and the differential equation gives one condition. A second condition can be chosen freely, and the method chooses the condition that removes the second derivatives of u₁ and u₂.
2. The Two Equations for u₁′ and u₂′
yp′ = u₁′y₁ + u₂′y₂ + u₁y₁′ + u₂y₂′the product ruleu₁′y₁ + u₂′y₂ = 0the chosen conditionyp′ = u₁y₁′ + u₂y₂′the derivative with the chosen conditionyp″ = u₁′y₁′ + u₂′y₂′ + u₁y₁″ + u₂y₂″the product rule one more timeSubstituting yp, yp′, and yp″ in the left side of the equation and collecting the terms with u₁ and the terms with u₂ gives
yp″ + pyp′ + qyp = u₁(y₁″ + py₁′ + qy₁) + u₂(y₂″ + py₂′ + qy₂) + u₁′y₁′ + u₂′y₂′collect the termsyp″ + pyp′ + qyp = u₁′y₁′ + u₂′y₂′y₁ and y₂ are solutions of the homogeneous equation, so both parentheses are 0u₁′y₁′ + u₂′y₂′ = g(t)the equation is satisfied when this holdsThe functions u₁′ and u₂′ satisfy two algebraic equations.
u₁′y₁ + u₂′y₂ = 0the chosen conditionu₁′y₁′ + u₂′y₂′ = g(t)the condition from the differential equationu₁′(y₁y₂′ − y₁′y₂) = −y₂g(t)multiply the first equation by y₂′ and the second by y₂, then subtractu₁′ = −y₂g(t)/Wthe parenthesis is the Wronskian Wu₂′ = y₁g(t)/Wthe same steps with y₁′ and y₁ remove u₁′Variation of parameters. For the equation y″ + p(t)y′ + q(t)y = g(t) with the fundamental set y₁, y₂ and the Wronskian W = y₁y₂′ − y₁′y₂, a particular solution is yp = u₁y₁ + u₂y₂, where u₁′ = −y₂g/W and u₂′ = y₁g/W.
The Wronskian of a fundamental set is not 0, so the divisions are allowed. The method ends with two integrations.
3. A First Example
Find a particular solution of y″ − y = 3e2t. The method of Topic 3.4 also solves this equation, so the result can be compared.
y₁ = et and y₂ = e−tthe fundamental set of y″ − y = 0W = −2the Wronskian, from Topic 3.1u₁′ = −e−t(3e2t)/−2u₁′ = −y₂g/Wu₁′ = 3/2 etsimplifyu₁ = 3/2 etintegrateu₂′ = et(3e2t)/−2u₂′ = y₁g/Wu₂′ = −3/2 e3tsimplifyu₂ = −1/2 e3tintegrateyp = 3/2 etet − 1/2 e3te−typ = u₁y₁ + u₂y₂yp = e2tbecause 3/2 − 1/2 = 1The method of undetermined coefficients gives the same function: the trial function Ae2t leads to 4A − A = 3, so A = 1.
The constants of integration
The integrations for u₁ and u₂ are done without constants. A constant k₁ in u₁ and a constant k₂ in u₂ would add k₁y₁ + k₂y₂ to yp. This is a solution of the homogeneous equation, and the general solution yp + c₁y₁ + c₂y₂ already contains it.
4. A Forcing That Is Not in the Table
Find a particular solution of
y″ + y = 1/cos tfor t between −π/2 and π/2, where cos t is positive. The forcing is not a polynomial, an exponential function, a sine, or a cosine, and its derivatives do not stay inside a small family of functions. The method of Topic 3.4 does not work.
y₁ = cos t and y₂ = sin tthe fundamental set of y″ + y = 0W = 1the Wronskian, from Topic 3.1u₁′ = −(sin t)/cos tu₁′ = −y₂g/Wu₁ = ln(cos t)integrate. The derivative of ln(cos t) is −(sin t)/cos tu₂′ = (cos t)/cos tu₂′ = y₁g/Wu₂ = tintegrate, because u₂′ = 1yp = cos t ln(cos t) + t sin typ = u₁y₁ + u₂y₂The general solution is y = cos t ln(cos t) + t sin t + c₁ cos t + c₂ sin t. No trial function of Topic 3.4 would produce the term with the logarithm.
5. Coefficients That Depend on t
Find a particular solution of t²y″ − 2y = 3t² for t greater than 0. The homogeneous equation t²y″ − 2y = 0 has the solutions y₁ = t² and y₂ = 1/t. Substituting each function shows this.
t²(2) − 2t² = 0y₁ = t² has the second derivative 2t²(2/t³) − 2/t = 0y₂ = 1/t has the second derivative 2/t³The formulas need the standard form, so the equation is divided by t² first.
y″ − 2/t² y = 3the standard form, so g(t) = 3W = t²(−1/t²) − 2t(1/t)W = y₁y₂′ − y₁′y₂W = −3because −1 − 2 = −3u₁′ = −1/t(3)/−3u₁′ = −y₂g/Wu₁′ = 1/tsimplifyu₁ = ln tintegrateu₂′ = t²(3)/−3u₂′ = y₁g/Wu₂′ = −t²simplifyu₂ = −t³/3integrateyp = t² ln t − t²/3yp = u₁y₁ + u₂y₂The term −t²/3 is a constant multiple of y₁, so it is a solution of the homogeneous equation and can be left out. A simpler particular solution is yp = t² ln t.
yp′ = 2t ln t + tthe product ruleyp″ = 2 ln t + 3the product rule one more timet²yp″ − 2yp = 2t² ln t + 3t² − 2t² ln tsubstitute in the equationt²yp″ − 2yp = 3t²the equation is satisfiedWith the forcing 3t² read from the equation before the division, the result would be wrong by the factor t².
6. A Comparison of the Two Methods
| Undetermined coefficients | Variation of parameters | |
|---|---|---|
| Coefficients | Constant | Constant, or functions of t |
| Forcing | Polynomials, exponential functions, sines, cosines, and their products | Any continuous function |
| What is needed | The roots of the characteristic equation | A fundamental set y₁, y₂ |
| Work | Algebra | Two integrals |
When both methods work, the method of undetermined coefficients is usually shorter. The integrals of variation of parameters cannot always be written with familiar functions. The method still gives the solution as an integral, which can be calculated with numbers.
7. An Example from Physics: A Force of Any Form on an Oscillator
A block on a spring is at rest at x = 0. From the time t = 0 on, a force F(t) acts on the block. With ω² = k/m and f(t) = F(t)/m, the second law of Newton gives
x″ + ω²x = f(t)The fundamental set is cos ωt, sin ωt, and its Wronskian is ω. The integrals are written with the variable s and run from 0 to t, so that u₁ and u₂ are 0 at t = 0.
u₁ = −1/ω ∫ f(s) sin ωs dsfrom u₁′ = −y₂f/Wu₂ = 1/ω ∫ f(s) cos ωs dsfrom u₂′ = y₁f/Wx = 1/ω ∫ f(s) [sin ωt cos ωs − cos ωt sin ωs] dsx = u₁ cos ωt + u₂ sin ωt, with the factors of t moved inside the integralsx = 1/ω ∫ f(s) sin ω(t − s) dsthe formula for the sine of a differenceThe response of an oscillator. The solution of x″ + ω²x = f(t) with x(0) = 0 and x′(0) = 0 is x(t) = 1/ω ∫ f(s) sin ω(t − s) ds, with the integral from s = 0 to s = t.
The formula adds the effects of the force at all earlier times s. The force at the time s contributes with the factor sin ω(t − s), which depends on the time t − s that has passed since then.
A constant force that starts at t = 0
For ω = 2 per second and the constant f = 2 m/s², the formula gives
x = 1/2 ∫ 2 sin 2(t − s) dsthe formula with ω = 2 and f = 2x = 1/2 [cos 2(t − s)]an antiderivative of 2 sin 2(t − s) with respect to s is cos 2(t − s)x = 1/2(1 − cos 2t)the bracket is 1 at s = t and cos 2t at s = 0The block oscillates between 0 and 1 m about the position 0.5 m. The check gives x″ + 4x = 2 cos 2t + 2 − 2 cos 2t, which is 2.
Try it: a force that acts for a limited time
The force per mass f is 1 from t = 0 to t = T, and 0 after that. The green band marks this interval. The blue curve is the position x(t) from the formula of Part 7, for a block that starts at rest. The sliders set ω and T.
Common Mistakes
- Reading g(t) from an equation that is not in the standard form. The coefficient of y″ must be 1.
- Exchanging the two formulas. The formula for u₁′ contains y₂ and a minus sign, and the formula for u₂′ contains y₁.
- Calculating the Wronskian in the wrong order. W = y₁y₂′ − y₁′y₂, and exchanging y₁ and y₂ changes its sign.
- Forgetting to multiply u₁ and u₂ by y₁ and y₂ at the end. The particular solution is u₁y₁ + u₂y₂.
- Using this method when a trial function of Topic 3.4 would be shorter.
Summary
| Idea | Statement |
|---|---|
| Standard form | y″ + p(t)y′ + q(t)y = g(t) |
| Trial function | yp = u₁y₁ + u₂y₂ |
| Chosen condition | u₁′y₁ + u₂′y₂ = 0 |
| Formulas | u₁′ = −y₂g/W and u₂′ = y₁g/W |
| Wronskian | W = y₁y₂′ − y₁′y₂ |
| Constants of integration | Not needed in u₁ and u₂ |
| y″ + y = 1/cos t | yp = cos t ln(cos t) + t sin t |
| Oscillator that starts at rest | x = 1/ω ∫ f(s) sin ω(t − s) ds, from s = 0 to s = t |
Practice
Work each problem on paper first. Then open the answer to check your work.
1. Use variation of parameters to find a particular solution of y″ − y = 4et.
y₁ = et, y₂ = e−t, and W = −2the fundamental set and its Wronskianu₁′ = −e−t(4et)/−2u₁′ = −y₂g/Wu₁ = 2tbecause u₁′ = 2u₂′ = et(4et)/−2u₂′ = y₁g/Wu₂ = −e2tbecause u₂′ = −2e2typ = 2tet − e2te−typ = u₁y₁ + u₂y₂yp = 2tet − etsimplify
The term −et is a solution of the homogeneous equation and can be left out. A particular solution is 2tet, as in practice problem 4 of Topic 3.4.
2. Find a particular solution of y″ + y = tan t for t between −π/2 and π/2. Use the integral ∫ (1/cos t) dt = ln((1 + sin t)/cos t).
y₁ = cos t, y₂ = sin t, and W = 1the fundamental set and its Wronskianu₁′ = −sin t tan tu₁′ = −y₂g/Wu₁′ = cos t − 1/cos tbecause sin² t = 1 − cos² tu₁ = sin t − ln((1 + sin t)/cos t)integrateu₂′ = cos t tan tu₂′ = y₁g/Wu₂ = −cos tbecause u₂′ = sin typ = sin t cos t − cos t ln((1 + sin t)/cos t) − cos t sin typ = u₁y₁ + u₂y₂yp = −cos t ln((1 + sin t)/cos t)the first and the last term cancel
3. The equation y″ − 2y′ + y = et/t, for t greater than 0, has the fundamental set et, tet with the Wronskian e2t. Find a particular solution.
u₁′ = −tet(et/t)/e2tu₁′ = −y₂g/Wu₁ = −tbecause u₁′ = −1u₂′ = et(et/t)/e2tu₂′ = y₁g/Wu₂ = ln tbecause u₂′ = 1/typ = −tet + tet ln typ = u₁y₁ + u₂y₂
The term −tet is a solution of the homogeneous equation and can be left out. A particular solution is tet ln t.
4. The equation t²y″ − 2y = 6t³, for t greater than 0, has the homogeneous solutions t² and 1/t with the Wronskian −3. Find a particular solution.
y″ − 2/t² y = 6tthe standard form, so g(t) = 6tu₁′ = −1/t(6t)/−3u₁′ = −y₂g/Wu₁ = 2tbecause u₁′ = 2u₂′ = t²(6t)/−3u₂′ = y₁g/Wu₂ = −t⁴/2because u₂′ = −2t³yp = 2t³ − t³/2yp = u₁y₁ + u₂y₂yp = 3/2 t³simplify
Check: t²(9t) − 2(3/2)t³ = 9t³ − 3t³ = 6t³.
5. Explain why the constants of integration in u₁ and u₂ can be set to 0.
A constant k₁ added to u₁ and a constant k₂ added to u₂ change yp by k₁y₁ + k₂y₂.
This function is a solution of the homogeneous equation. The general solution yp + c₁y₁ + c₂y₂ already contains each function of this form, so the constants k₁ and k₂ add nothing new.
6. A block satisfies x″ + 4x = f(t) and starts at rest at x = 0. The force per mass is f(t) = t. Use the formula of Part 7 and the integral ∫ s sin 2(t − s) ds = t/2 − (1/4) sin 2t, from s = 0 to s = t, to find x(t).
x = 1/2 ∫ s sin 2(t − s) dsthe formula with ω = 2 and f(s) = sx = 1/2(t/2 − 1/4 sin 2t)the given integralx = t/4 − 1/8 sin 2tmultiply out
Check: x″ = (1/2) sin 2t, so x″ + 4x = (1/2) sin 2t + t − (1/2) sin 2t = t.
Python Practice
Step 1. The two formulas with numbers
The code below calculates u₁′ and u₂′ for the example of Part 3 at the time t = 1. The fundamental set is et, e−t, the Wronskian is −2, and the forcing is 3e2t.
Python
The values are 4.077 and −30.128. They agree with 3/2 et and −3/2 e3t at t = 1. Now use the forcing 4et of practice problem 1. The values should be 2 and −14.778, which is −2e².
Python
Step 2. Check the solution with the logarithm
The code below checks the particular solution y = cos t ln(cos t) + t sin t of the equation y″ + y = 1/cos t of Part 4, for times between −1 and 1. It estimates the second derivative with np.gradient.
Python
The largest difference is very small. Now check the particular solution of practice problem 2, y = −cos t ln((1 + sin t)/cos t), in the equation y″ + y = tan t. The tangent is typed as np.tan. Two lines need a change.
Python
Step 3. Coefficients that depend on t
The code below checks the particular solution y = t² ln t of the equation t²y″ − 2y = 3t² of Part 5, for times between 1 and 3. The derivatives are typed by hand.
Python
The largest difference is 0 up to rounding. Now check the particular solution y = 3/2 t³ of the equation t²y″ − 2y = 6t³ of practice problem 4. Its second derivative is 9t. Three lines need a change.
Python
Step 4. The integral formula with numbers
The formula of Part 7 gives the position as an integral. The instruction np.trapezoid calculates an integral from a list of values. It receives the values of the function and the list of the points. The code below calculates x(3) for ω = 2 and the constant f = 2, and compares the result with the formula 1/2(1 − cos 2t) of Part 7.
Python
Both values are 0.0199. The expression 2 + 0 * s makes a list in which each value is 2. Now use the force per mass f(s) = s of practice problem 6. The position is then t/4 − 1/8 sin 2t. Two lines need a change. Both values should be close to 0.7849.
Python
Step 5. A force with no simple antiderivative
The integral formula also works when the integral cannot be written with familiar functions. The code below uses the force per mass f(s) = e−s², a short push near s = 0, with ω = 2. It calculates the position at t = 5.
Python
The position is about 0.1371. Now calculate the position at t = 5 for an oscillator with ω = 1 and the same force. The result should be about −0.7822.
Python
Quiz
This quiz has 5 questions on this topic. A question asks you either to choose one answer or to type numbers. The page grades your answers and explains each one. A number can be typed as a whole number, a decimal, a fraction such as 1/3, or a calculation such as sqrt(18)/2 or arccos(1/2). The page shows the value of a calculation next to the box. Angles in a calculation are in degrees. The Calculator button under each question opens a calculator. Your answers are saved in your browser, so they are still on the page when you come back to it.
Choose how your answers are checked
1. Which formulas does variation of parameters use for y″ + p(t)y′ + q(t)y = g(t)?
The formula for u₁′ contains the other solution y₂ and a minus sign. The formula for u₂′ contains y₁. Both are divided by the Wronskian W = y₁y₂′ − y₁′y₂.
2. For which equation is variation of parameters needed, because the method of undetermined coefficients does not work?
The derivatives of 1/t are −1/t², 2/t³, and so on. They do not stay inside a small family of functions, so no trial function of Topic 3.4 works. The other three forcings are a polynomial, an exponential function, and a cosine.
3. For y″ − y = 6, with y₁ = et, y₂ = e−t, and W = −2, find the value of u₁′ at t = 0.
u₁′ = −y₂g/Wthe formulau₁′ = −e−t(6)/−2substitute y₂, g, and Wu₁′ = 3e−tsimplifyu₁′(0) = 3substitute t = 0
4. The equation t²y″ − 2y = 3t² is solved by variation of parameters. Which function is g(t) in the formulas?
The formulas need the standard form, with the coefficient 1 in front of y″. Dividing the equation by t² gives y″ − (2/t²)y = 3, so g(t) = 3.
5. A block satisfies x″ + 4x = 2 and starts at rest at x = 0. Its position is x = (1/2)(1 − cos 2t). Find the largest value of x.
x = 1/2(1 − cos 2t)the positioncos 2t = −1the position is largest when the cosine is smallestx = 1/2(1 + 1)substitutex = 1the largest value