MATH 2410 — Differential Equations
Lecture Notes. This is NOT meant to be a substitute for coming to lecture or consulting the textbook directly, but rather a helpful resource to review for exams/ review what was discussed in lecture.
Growth and Decay Models
Recall from Section 1.3 the basic growth/decay model
\[ \frac{dx}{dt} = kx, \qquad x(t_0) = x_0, \]where \(k\) is a constant of proportionality. This differential equation is both separable and linear.
We are told \(\dfrac{dx}{dt} = -kx\). Separating variables,
\[ \frac{dx}{x} = -k\,dt \;\Longrightarrow\; \int \frac{dx}{x} = \ln|x| = -kt+C \;\Longrightarrow\; x(t) = Ce^{-kt}. \]Since \(x(0) = 1\) g, \(C=1\), so \(x(t) = e^{-kt}\). Using the half-life,
\[ x(3.3) = \frac{1}{2}x(0) = \frac{1}{2} \;\Longrightarrow\; e^{-3.3k} = \frac{1}{2} \;\Longrightarrow\; k = -\frac{1}{3.3}\ln\!\left(\frac{1}{2}\right). \]We want the time at which \(x(t) = 0.1\) (i.e. \(90\%\) has decayed):
\[ 0.1 = e^{-kt} \;\Longrightarrow\; t = -\frac{\ln(0.1)}{k} \approx 10.96. \]Thus
\[ \boxed{t \approx 11 \text{ hours}.} \]Newton's Law of Cooling
Solving by separation of variables,
\[ \frac{dT}{T-T_m} = k\,dt \;\Longrightarrow\; \int \frac{dT}{T-T_m} = \int k\,dt \;\Longrightarrow\; \ln|T-T_m| = kt+C \;\Longrightarrow\; T(t) = T_m + Ce^{kt}. \]Let \(T_m\) be the (constant) oven temperature and \(T(t)\) the thermometer reading at time \(t\) (in minutes). Then
\[ T(0) = T_m + Ce^{k(0)} = T_m+C = 70 \;\Longrightarrow\; C = 70-T_m, \]so \(T(t) = T_m + (70-T_m)e^{kt}\). Using the two given readings,
\[ \begin{aligned} T(1) &= T_m + (70-T_m)e^{k} = 110 \;\Longrightarrow\; e^{k} = \frac{110-T_m}{70-T_m}, \\ T(2) &= T_m + (70-T_m)e^{2k} = 145 \;\Longrightarrow\; e^{2k} = \frac{145-T_m}{70-T_m}. \end{aligned} \]Since \(e^{2k} = (e^k)^2\),
\[ \frac{145-T_m}{70-T_m} = \left(\frac{110-T_m}{70-T_m}\right)^2 \;\Longrightarrow\; (145-T_m)(70-T_m) = (110-T_m)^2. \]Expanding both sides,
\[ 10150 - 215T_m + T_m^2 = 12100 - 220T_m + T_m^2 \;\Longrightarrow\; 5T_m = 1950. \]Thus
\[ \boxed{T_m = 390^\circ\text{F}.} \]Nonlinear Population Models
Suppose we track a rate of growth that depends on both the amount present and another factor that is itself dependent on the amount present: \(\dfrac{dP}{dt} = P\cdot f(P)\), a nonlinear model.
Suppose an environment has a carrying capacity for a population, so that
\[ \frac{dP}{dt} = P\cdot f(P), \qquad f(K) = 0, \quad f(0) = r, \]where \(K\) is the carrying capacity. If \(f(P)\) is linear, we obtain
\[ \frac{dP}{dt} = P\left(r - \frac{r}{K}P\right), \]called the logistic equation.
Solving the logistic equation. Separating variables,
\[ \frac{dP}{P(a-bP)} = dt. \]Using partial fractions, \(\dfrac{1}{P(a-bP)} = \dfrac{1/a}{P} + \dfrac{b/a}{a-bP}\), so
\[ \frac{1}{a}\int \frac{dP}{P} + \frac{b}{a}\int \frac{dP}{a-bP} = \int dt \;\Longrightarrow\; \frac{1}{a}\ln\!\left(\frac{P}{a-bP}\right) = t+C. \]Solving for \(P\),
\[ \frac{P}{a-bP} = ce^{at} \;\Longrightarrow\; P = \frac{ace^{at}}{1-bce^{at}}. \]If \(P(0) = P_0\) with \(P_0 \ne a/b\), then \(c = P_0/(a-bP_0)\), and the solution can be written as
\[ \boxed{P(t) = \frac{aP_0}{bP_0+(a-bP_0)e^{-at}}.} \]The model is \(\dfrac{dx}{dt} = kx(1000-x)\), \(x(0)=1\), matching the logistic equation with \(a=1000k\), \(b=k\). Then
\[ x(t) = \frac{1000k}{k+999ke^{-1000kt}} = \frac{1000}{1+999e^{-1000kt}}. \]Using \(x(4)=50\):
\[ 50 = \frac{1000}{1+999e^{-4000k}} \;\Longrightarrow\; e^{-4000k} = \frac{19}{999} \;\Longrightarrow\; k = -\frac{1}{4000}\ln\!\left(\frac{19}{999}\right). \]Then
\[ \boxed{x(6) \approx 276 \text{ students}.} \]Adjusting Population Models
Recall the logistic model can be written in terms of the carrying capacity \(K\) and intrinsic growth rate \(r\) by setting \(a=r\), \(b=r/K\):
\[ \frac{dP}{dt} = P\left(r-\frac{r}{K}P\right). \]How can we make the model more realistic? Suppose a constant number \(h\) of the population is removed (harvested) per unit time. Then
\[ \frac{dP}{dt} = P\left(r-\frac{r}{K}P\right) - h, \qquad h>0, \]which is still separable and autonomous.
Systems of First-Order Differential Equations
Let \(x_1(t)\) and \(x_2(t)\) denote the amount of salt (in lb) in Tanks A and B, respectively. Since each tank maintains a constant volume of \(50\) gal, the concentration in Tank A is \(x_1/50\) and in Tank B is \(x_2/50\). Then
\[ \begin{aligned} \frac{dx_1}{dt} &= \underbrace{(3)(0)}_{\text{fresh water in}} + \underbrace{(1)\frac{x_2}{50}}_{\text{from Tank B}} - \underbrace{(4)\frac{x_1}{50}}_{\text{out to Tank B}} = -\frac{2}{25}x_1 + \frac{1}{50}x_2, \\[4pt] \frac{dx_2}{dt} &= \underbrace{(4)\frac{x_1}{50}}_{\text{from Tank A}} - \underbrace{(3)\frac{x_2}{50}}_{\text{leaves system}} - \underbrace{(1)\frac{x_2}{50}}_{\text{to Tank A}} = \frac{2}{25}x_1 - \frac{2}{25}x_2, \end{aligned} \]with initial conditions \(x_1(0)=25\), \(x_2(0)=0\).
Homogeneous Linear Equations and Superposition
Throughout, we assume the coefficients \(a_i(x)\) are continuous and \(a_n(x)\) is nonzero on the interval under consideration.
To see why, suppose \(y_1\) and \(y_2\) are solutions. Then for any constant \(c_1\),
\[ a_n(x)\frac{d^n}{dx^n}(c_1y_1) + \cdots + a_1(x)\frac{d}{dx}(c_1y_1) + a_0(x)(c_1y_1) = c_1\Big(a_n(x)y_1^{(n)} + \cdots + a_1(x)y_1' + a_0(x)y_1\Big) = c_1(0) = 0, \]so \(c_1y_1\) is also a solution. Likewise,
\[ a_n(x)\frac{d^n}{dx^n}(y_1+y_2) + \cdots + a_1(x)\frac{d}{dx}(y_1+y_2) + a_0(x)(y_1+y_2) = 0 + 0 = 0, \]so \(y_1+y_2\) is also a solution. Together, these two facts give the superposition principle stated above.
For \(y_1=x^2\): \(y_1'=2x\), \(y_1''=2\), \(y_1'''=0\), so
\[ x^3(0) - 2x(2x) + 4(x^2) = -4x^2+4x^2 = 0. \checkmark \]For \(y_2=x^2\ln x\): \(y_2' = 2x\ln x + x\), \(y_2'' = 2\ln x+3\), \(y_2''' = 2/x\), so
\[ x^3\left(\frac{2}{x}\right) - 2x(2x\ln x+x) + 4(x^2\ln x) = 2x^2 - 4x^2\ln x - 2x^2 + 4x^2\ln x = 0. \checkmark \]By the superposition principle,
\[ \boxed{y = c_1x^2+c_2x^2\ln(x)} \]is also a solution, for any constants \(c_1,c_2\).
Linear Independence and the Wronskian
Fundamental Sets and General Solutions
Now consider the nonhomogeneous case.
Reduction of Order
Given a homogeneous linear differential equation, how do we locate more than one solution? Consider a second-order linear homogeneous DE
\[ y'' + P(x)y' + Q(x)y = 0, \]with \(P(x),Q(x)\) continuous on the interval we consider, and suppose we already know one solution \(y_1(x)\). We want to locate a second, linearly independent solution \(y_2(x)\).
Since \(y_1,y_2\) must be linearly independent, the ratio \(u(x) = y_2(x)/y_1(x)\) is nonconstant. Write \(y_2(x) = u(x)y_1(x)\), so
\[ y_2' = u'y_1+uy_1', \qquad y_2'' = u''y_1+2u'y_1'+uy_1''. \]Substituting into the differential equation,
\[ \begin{aligned} y_2''+Py_2'+Qy_2 &= u''y_1+2u'y_1'+uy_1'' + P(u'y_1+uy_1') + Quy_1 \\ &= u''y_1 + 2u'y_1' + Pu'y_1 + u\underbrace{(y_1''+Py_1'+Qy_1)}_{0} \\ &= y_1u'' + (2y_1'+Py_1)u'. \end{aligned} \]We need this to equal zero, so letting \(w=u'\),
\[ y_1w' + (2y_1'+Py_1)w = 0, \]which is a first-order linear DE in \(w\). Its integrating factor is
\[ \mu(x) = e^{\int \frac{2y_1'+Py_1}{y_1}dx} = e^{\int \left(\frac{2y_1'}{y_1}+P\right)dx} = e^{2\ln|y_1|}e^{\int P\,dx} = y_1^2\,e^{\int P\,dx}. \]Since \(\dfrac{d}{dx}(\mu(x)w)=0\), we get \(\mu(x)w=c\), so
\[ w = \frac{c}{y_1^2\,e^{\int P\,dx}} = c\cdot\frac{e^{-\int P\,dx}}{y_1^2}. \]Choosing \(c=1\) and integrating,
\[ u = \int \frac{e^{-\int P\,dx}}{y_1^2}\,dx. \]- Write the DE in standard form \(y''+P(x)y'+Q(x)y=0\) and identify the known solution \(y_1(x)\).
- Set \(y_2 = u(x)y_1(x)\) and substitute into the DE.
- The \(u\) terms will cancel, leaving a first-order linear DE in \(w=u'\).
- Solve for \(w\) using an integrating factor, then integrate to find \(u\).
- Form \(y_2 = u(x)y_1(x)\), and write the general solution \(y=c_1y_1+c_2y_2\).
Let \(y_2=u(x)e^x\). Then
\[ y_2' = e^x(u+u'), \qquad y_2'' = e^x(u''+2u'+u). \]Substituting,
\[ y_2''-y_2 = e^x(u''+2u'+u) - ue^x = e^x(u''+2u'). \]We want \(u''+2u'=0\), so with \(w=u'\): \(w'+2w=0\). The integrating factor is \(\mu(x)=e^{2x}\), so
\[ \frac{d}{dx}\big(e^{2x}w\big)=0 \;\Longrightarrow\; e^{2x}w=c_2 \;\Longrightarrow\; w = c_2e^{-2x}. \]Integrating, \(u = -\tfrac12c_2e^{-2x}+c_1\). Choosing \(c_2=-2\), \(c_1=0\) gives \(u=e^{-2x}\), so \(y_2 = e^{-2x}e^x = e^{-x}\). Thus
\[ \boxed{y = c_1e^x+c_2e^{-x}.} \]Standard form: \(y''-\dfrac3xy'+\dfrac{4}{x^2}y=0\). Let \(y_2=u(x)x^2\). Then
\[ y_2' = u'x^2+2xu, \qquad y_2'' = u''x^2+4xu'+2u. \]Substituting,
\[ y_2''-\frac3xy_2'+\frac{4}{x^2}y_2 = (u''x^2+4xu'+2u) - \frac3x(u'x^2+2xu)+\frac{4}{x^2}(ux^2) = u''x^2+xu'. \]We want \(u''x^2+xu'=0\), so with \(w=u'\): \(x^2w'+xw=0\), i.e. \(w'+\dfrac1xw=0\). The integrating factor is \(\mu(x)=e^{\int (1/x)dx}=x\), so
\[ \frac{d}{dx}(xw)=0 \;\Longrightarrow\; xw=c_1 \;\Longrightarrow\; w=\frac{c_1}{x}. \]Integrating, \(u = c_1\ln(x)+c_2\). Choosing \(c_1=1\), \(c_2=0\) gives \(u=\ln(x)\), so \(y_2=x^2\ln(x)\). Checking,
\[ W(y_1,y_2) = \begin{vmatrix}x^2 & x^2\ln(x)\\ 2x & 2x\ln(x)+x \end{vmatrix} = x^3+2x^3\ln(x)-2x^3\ln(x) = x^3 \ne 0 \]on \((0,\infty)\), so
\[ \boxed{y = c_1x^2+c_2x^2\ln(x).} \]Let \(y_2=u\). Then \(y_2'=u'\), \(y_2''=u''\), and substituting,
\[ (1-x^2)u''+2xu'=0 \;\Longrightarrow\; u''+\frac{2x}{1-x^2}u'=0. \]With \(w=u'\): \(w'+\dfrac{2x}{1-x^2}w=0\). The integrating factor is
\[ \mu(x) = e^{\int \frac{2x}{1-x^2}dx} = e^{-\ln(1-x^2)} = \frac{1}{1-x^2}. \]Then \(\dfrac{d}{dx}\left(\dfrac{w}{1-x^2}\right)=0\), so \(\dfrac{w}{1-x^2}=c_1\), i.e. \(w=c_1(1-x^2)\). Integrating,
\[ u = c_1\left(x-\frac{x^3}{3}\right)+c_2. \]Choosing \(c_1=1\), \(c_2=0\) gives \(y_2 = x-\dfrac{x^3}{3}\). Checking,
\[ W(y_1,y_2) = \begin{vmatrix}1 & x-\frac{x^3}{3}\\ 0 & 1-x^2 \end{vmatrix} = 1-x^2 \ne 0 \]away from \(x=\pm1\), so
\[ \boxed{y = c_1+c_2\left(x-\frac{x^3}{3}\right).} \]Let \(y_2=u(x)\sin x\). Then
\[ y_2' = u'\sin x+u\cos x, \qquad y_2'' = u''\sin x+2u'\cos x-u\sin x. \]Substituting,
\[ \begin{aligned} y_2''+2\tan x\,y_2'-y_2 &= (u''\sin x+2u'\cos x-u\sin x) + 2\tan x(u'\sin x+u\cos x) - u\sin x \\ &= u''\sin x + 2u'\left(\cos x+\tan x\sin x\right) + u\left(-2\sin x+2\tan x\cos x\right). \end{aligned} \]Since \(\cos x+\tan x\sin x = \dfrac{\cos^2x+\sin^2x}{\cos x} = \sec x\) and \(-2\sin x+2\tan x\cos x = -2\sin x+2\sin x = 0\), this simplifies to
\[ u''\sin x + 2\sec x\,u' = 0. \]With \(w=u'\): \(\sin x\,w'+2\sec x\,w=0\), so
\[ \frac{w'}{w} = -\frac{2\sec x}{\sin x} = -\frac{2}{\sin x\cos x} = -4\csc(2x). \]Integrating, \(\ln|w| = -2\ln|\tan x|+c_1\), so \(w = c_1\cot^2x\). Then
\[ u = c_1\int \cot^2x\,dx = c_1\int(\csc^2x-1)\,dx = c_1(-\cot x - x)+c_2. \]Choosing \(c_1=-1\), \(c_2=0\) gives \(u = \cot x + x\), so
\[ y_2 = (\cot x+x)\sin x = \cos x + x\sin x. \]Checking,
\[ W(\sin x,\, \cos x+x\sin x) = \sin x(x\cos x) - (\cos x+x\sin x)\cos x = x\sin x\cos x - \cos^2x - x\sin x\cos x = -\cos^2x \ne 0 \]away from \(x=\pi/2+k\pi\), so
\[ \boxed{y = c_1\sin x + c_2(\cos x+x\sin x).} \]The Auxiliary Equation
We now specialize to homogeneous linear differential equations whose coefficients are all constants. We will focus on the second-order case,
\[ ay'' + by' + cy = 0, \qquad a\ne 0, \]though the same idea extends to any order.
Since \(y=e^{mx}\) reproduces itself (up to a constant multiple) under differentiation, it is a natural guess for a solution. Substituting \(y=e^{mx}\), \(y'=me^{mx}\), \(y''=m^2e^{mx}\) into the DE,
\[ am^2e^{mx}+bme^{mx}+ce^{mx} = e^{mx}\big(am^2+bm+c\big) = 0. \]Since \(e^{mx}\ne 0\) for any \(x\), this holds exactly when
\[ am^2+bm+c=0. \]Since the auxiliary equation is a quadratic in \(m\), the quadratic formula
\[ m = \frac{-b\pm\sqrt{b^2-4ac}}{2a} \]gives one of three possible outcomes, depending on the sign of the discriminant \(b^2-4ac\): two distinct real roots, one repeated real root, or a pair of complex conjugate roots. Each case produces a different form for the general solution.
Case 1: Distinct Real Roots
If \(b^2-4ac>0\), the auxiliary equation has two distinct real roots \(m_1\ne m_2\), giving two solutions \(y_1=e^{m_1x}\) and \(y_2=e^{m_2x}\). Since \(y_2/y_1 = e^{(m_2-m_1)x}\) is nonconstant, \(y_1\) and \(y_2\) are linearly independent, so the general solution is
\[ y = c_1e^{m_1x}+c_2e^{m_2x}. \]The auxiliary equation is \(m^2-5m+6=0\), which factors as \((m-2)(m-3)=0\), giving roots \(m=2\) and \(m=3\). Thus
\[ \boxed{y = c_1e^{2x}+c_2e^{3x}.} \]Case 2: Repeated Real Root
If \(b^2-4ac=0\), the auxiliary equation has a single repeated root \(m=-b/(2a)\), giving only one solution \(y_1=e^{mx}\) directly. To find a second, linearly independent solution, we apply reduction of order (Section 4.2) with \(y_1=e^{mx}\): since \(y_1\) solves the DE with \(P(x) = b/a\) constant,
\[ y_2 = y_1\int \frac{e^{-\int (b/a)\,dx}}{y_1^2}\,dx = e^{mx}\int \frac{e^{-(b/a)x}}{e^{2mx}}\,dx. \]Since \(m=-b/(2a)\), we have \(e^{2mx}=e^{-(b/a)x}\), so the integrand is simply \(1\), giving \(y_2 = e^{mx}\int 1\,dx = xe^{mx}\). Thus the general solution is
\[ y = c_1e^{mx}+c_2xe^{mx}. \]The auxiliary equation is \(m^2-6m+9=0\), i.e. \((m-3)^2=0\), giving the repeated root \(m=3\). Thus
\[ \boxed{y = c_1e^{3x}+c_2xe^{3x}.} \]Case 3: Complex Conjugate Roots
If \(b^2-4ac<0\), the auxiliary equation has a complex conjugate pair of roots \(m = \alpha\pm i\beta\), where \(\alpha = -b/(2a)\) and \(\beta = \sqrt{4ac-b^2}/(2a)\). Formally, this gives solutions \(e^{(\alpha+i\beta)x}\) and \(e^{(\alpha-i\beta)x}\). Using Euler's formula \(e^{i\theta} = \cos\theta+i\sin\theta\),
\[ e^{(\alpha\pm i\beta)x} = e^{\alpha x}\big(\cos(\beta x)\pm i\sin(\beta x)\big). \]Taking suitable linear combinations of these two (complex) solutions produces two real-valued, linearly independent solutions, \(e^{\alpha x}\cos(\beta x)\) and \(e^{\alpha x}\sin(\beta x)\), so the general solution is
\[ y = e^{\alpha x}\big(c_1\cos(\beta x)+c_2\sin(\beta x)\big). \]The auxiliary equation is \(m^2+4m+13=0\), so
\[ m = \frac{-4\pm\sqrt{16-52}}{2} = \frac{-4\pm\sqrt{-36}}{2} = -2\pm 3i. \]Here \(\alpha=-2\) and \(\beta=3\), so
\[ \boxed{y = e^{-2x}\big(c_1\cos(3x)+c_2\sin(3x)\big).} \]- Write the auxiliary equation \(am^2+bm+c=0\).
- Find its roots using factoring or the quadratic formula.
- Distinct real roots \(m_1,m_2\): \(y=c_1e^{m_1x}+c_2e^{m_2x}\).
- Repeated real root \(m\): \(y=c_1e^{mx}+c_2xe^{mx}\).
- Complex roots \(\alpha\pm i\beta\): \(y=e^{\alpha x}\big(c_1\cos(\beta x)+c_2\sin(\beta x)\big)\).
Undetermined Coefficients
The method of undetermined coefficients is a way to guess the correct form of \(y_p\) directly, and it applies whenever:
- the coefficients \(a_i\) are constants, and
- \(g(x)\) is a polynomial, an exponential, \(\sin(\beta x)\), \(\cos(\beta x)\), or a sum or product of these.
| \(g(x)\) | Guess for \(y_p\) |
|---|---|
| \(k\) (constant) | \(A\) |
| \(mx+b\) | \(Ax+B\) |
| \(ax^2+bx+c\) | \(Ax^2+Bx+C\) |
| \(\sin(\beta x)\) or \(\cos(\beta x)\) | \(A\sin(\beta x)+B\cos(\beta x)\) |
| \(e^{mx}\) | \(Ae^{mx}\) |
Homogeneous part. Guess \(y_c=e^{mx}\):
\[ m^2+5m-6 = (m+6)(m-1) = 0 \;\Longrightarrow\; m=-6,\ m=1. \]So \(y_c = c_1e^{-6x}+c_2e^{x}\).
Particular solution. Guess \(y_p=Ax^2+Bx+C\), so \(y_p'=2Ax+B\) and \(y_p''=2A\). Substituting,
\[ y_p''+5y_p'-6y_p = 2A+5(2Ax+B)-6(Ax^2+Bx+C) = -6Ax^2+(10A-6B)x+(2A+5B-6C). \]Matching coefficients with \(-6x^2-2x+1\):
\[ -6A=-6 \Rightarrow A=1, \qquad 10A-6B=-2 \Rightarrow B=2, \qquad 2A+5B-6C=1 \Rightarrow C=\tfrac{11}{6}. \]So \(y_p = x^2+2x+\tfrac{11}{6}\). Thus
\[ \boxed{y = c_1e^{-6x}+c_2e^{x}+x^2+2x+\frac{11}{6}.} \]Homogeneous part. Guess \(y_c=e^{mx}\):
\[ m^2-5m+4 = (m-1)(m-4)=0 \;\Longrightarrow\; m=1,\ m=4. \]So \(y_c=c_1e^{x}+c_2e^{4x}\).
Particular solution. Guess \(y_p=A\cos(2x)+B\sin(2x)\), so \(y_p'=-2A\sin(2x)+2B\cos(2x)\) and \(y_p''=-4A\cos(2x)-4B\sin(2x)\). Substituting,
\[ \begin{aligned} y_p''-5y_p'+4y_p &= -4A\cos(2x)-4B\sin(2x) -10B\cos(2x)+10A\sin(2x) \\ &\qquad +4A\cos(2x)+4B\sin(2x) \\ &= 10A\sin(2x) - 10B\cos(2x). \end{aligned} \]Matching with \(\sin(2x)\): \(10A=1 \Rightarrow A=\tfrac{1}{10}\), and \(-10B=0 \Rightarrow B=0\). So \(y_p=\tfrac{1}{10}\cos(2x)\). Thus
\[ \boxed{y = c_1e^{x}+c_2e^{4x}+\frac{1}{10}\cos(2x).} \]Homogeneous part. Guess \(y_c=e^{mx}\): \(m^2+1=0 \Rightarrow m=\pm i\), so \(y_c = c_1\cos x+c_2\sin x\).
Particular solution. Since \(g(x)=10x+e^{6x}\) is a sum, find a particular solution for each piece. For \(10x\), guess \(y_{p_1}=Ax+B\): then \(y_{p_1}''+y_{p_1}=Ax+B=10x \Rightarrow A=10\), \(B=0\). For \(e^{6x}\), guess \(y_{p_2}=Ae^{6x}\): then \(y_{p_2}''=36Ae^{6x}\), so
\[ y_{p_2}''+y_{p_2} = 37Ae^{6x} = e^{6x} \;\Longrightarrow\; A=\frac{1}{37}. \]So \(y_p = 10x+\dfrac{1}{37}e^{6x}\), and
\[ y = c_1\cos x+c_2\sin x+10x+\frac{1}{37}e^{6x}. \]Apply initial conditions.
\[ y(0) = c_1+\frac{1}{37} = 1 \;\Longrightarrow\; c_1 = \frac{36}{37}. \]Since \(y' = -c_1\sin x+c_2\cos x+10+\tfrac{6}{37}e^{6x}\),
\[ y'(0) = c_2+10+\frac{6}{37} = 0 \;\Longrightarrow\; c_2 = -\frac{376}{37}. \]Thus
\[ \boxed{y = \frac{36}{37}\cos x - \frac{376}{37}\sin x + 10x + \frac{1}{37}e^{6x}.} \]Homogeneous part. The auxiliary equation is \(m^2+4m+4=(m+2)^2=0\), a repeated root \(m=-2\), so (by Section 4.3) \(y_c = c_1e^{-2x}+c_2xe^{-2x}\).
Particular solution. Guess \(y_p=Ax^2+Bx+C\), so \(y_p'=2Ax+B\) and \(y_p''=2A\). Substituting,
\[ y_p''+4y_p'+4y_p = 4Ax^2+(8A+4B)x+(2A+4B+4C) = 4-x^2. \]Matching coefficients:
\[ 4A=-1 \Rightarrow A=-\tfrac14, \qquad 8A+4B=0 \Rightarrow B=\tfrac12, \qquad 2A+4B+4C=4 \Rightarrow C=\tfrac58. \]So \(y_p = -\tfrac14x^2+\tfrac12x+\tfrac58\). Thus
\[ \boxed{y = c_1e^{-2x}+c_2xe^{-2x} - \frac14x^2+\frac12x+\frac58.} \]Homogeneous part. \(m^2-9=0 \Rightarrow m=\pm3\), so \(y_c = c_1e^{3x}+c_2e^{-3x}\).
Particular solution. Since \(g(x)=x\sin(x)\) is a product of a polynomial and \(\sin(x)\), guess \(y_p = (Ax+B)\sin(x)+(Cx+D)\cos(x)\). Carrying out the differentiation twice,
\[ y_p'' = \big(-Ax-B-2C\big)\sin(x) + \big(2A-Cx-D\big)\cos(x). \]So
\[ y_p''-9y_p = \big(-10Ax-10B-2C\big)\sin(x) + \big(2A-10Cx-10D\big)\cos(x). \]Matching with \(x\sin(x) + 0\cdot\cos(x)\):
\[ -10A=1 \Rightarrow A=-\tfrac{1}{10}, \qquad -10C=0 \Rightarrow C=0, \] \[ -10B-2C=0 \Rightarrow B=0, \qquad 2A-10D=0 \Rightarrow D=\tfrac{A}{5}=-\tfrac{1}{50}. \]So \(y_p = -\tfrac{1}{10}x\sin(x)-\tfrac{1}{50}\cos(x)\). Thus
\[ \boxed{y = c_1e^{3x}+c_2e^{-3x} - \frac{1}{10}x\sin(x) - \frac{1}{50}\cos(x).} \]Variation of Parameters
Undetermined coefficients only works when \(g(x)\) has one of a few special forms. Variation of parameters is a more general method that works for any nonhomogeneous linear DE, once a fundamental set of solutions to the homogeneous equation is known.
Given \(y''+P(x)y'+Q(x)y=f(x)\) with homogeneous general solution \(y_c=c_1y_1+c_2y_2\), look for a particular solution of the form \(y_p = u_1(x)y_1(x)+u_2(x)y_2(x)\).
- Find \(y_c = c_1y_1+c_2y_2\), the general solution to the homogeneous equation.
- Compute the Wronskian \(W=W(y_1,y_2)\), along with \[ W_1 = \begin{vmatrix}0 & y_2\\ f(x) & y_2'\end{vmatrix}, \qquad W_2 = \begin{vmatrix}y_1 & 0\\ y_1' & f(x)\end{vmatrix}. \]
- Find \(u_1' = W_1/W\) and \(u_2'=W_2/W\).
- Integrate to find \(u_1\) and \(u_2\).
- The general solution is \(y = y_c+y_p = c_1y_1+c_2y_2+u_1y_1+u_2y_2\).
Undetermined coefficients does not apply here, since \(\tan(x)\) is not a polynomial, exponential, sine, or cosine. We use variation of parameters instead.
Homogeneous part. \(y_c=c_1\sin x+c_2\cos x\), so \(y_1=\sin x\), \(y_2=\cos x\), and \(f(x)=\tan x\).
Wronskians.
\[ W(y_1,y_2) = \begin{vmatrix}\sin x & \cos x\\ \cos x & -\sin x \end{vmatrix} = -\sin^2x-\cos^2x = -1, \] \[ W_1 = \begin{vmatrix}0 & \cos x\\ \tan x & -\sin x\end{vmatrix} = -\cos x\tan x = -\sin x, \qquad W_2 = \begin{vmatrix}\sin x & 0\\ \cos x & \tan x\end{vmatrix} = \sin x\tan x. \]Solve for \(u_1',u_2'\).
\[ u_1' = \frac{W_1}{W} = \frac{-\sin x}{-1} = \sin x, \qquad u_2' = \frac{W_2}{W} = \frac{\sin x\tan x}{-1} = -\sin x\tan x. \]Integrate.
\[ u_1 = \int \sin x\,dx = -\cos x. \]For \(u_2\), write \(-\sin x\tan x = -\dfrac{\sin^2x}{\cos x} = -\dfrac{1-\cos^2x}{\cos x} = -\sec x+\cos x\), so
\[ u_2 = \int(-\sec x+\cos x)\,dx = -\ln|\sec x+\tan x|+\sin x. \]Assemble. \(y_p = u_1y_1+u_2y_2 = -\cos x\sin x + \big(-\ln|\sec x+\tan x|+\sin x\big)\cos x\), so
\[ \boxed{y = c_1\sin x+c_2\cos x - \sin x\cos x + \big(\sin x-\ln|\sec x+\tan x|\big)\cos x.} \]