Class 12 Maths, Worked in Full Past papersGet updates
Chapter 9 · Differential Equations

Example 14: Linear: dydx−y=cos⁡x\frac{dy}{dx} - y = \cos x

ExamplesLinear differential equations · Section 9.4.3
The question

Find the general solution of the differential equation dydx−y=cos⁡x\dfrac{dy}{dx} - y = \cos x⁠.

Exam answer

The equation is of the form dydx+Py=Q\frac{dy}{dx} + Py = Q⁠, where P=−1P = -1 and Q=cos⁡xQ = \cos x⁠.

I.F.=e∫−1 dx=e−x\text{I.F.} = e^{\int -1\,dx} = e^{-x}

So the solution is given by

ye−x=∫e−xcos⁡x dx+C…(i)ye^{-x} = \int e^{-x}\cos x\,dx + C\quad\ldots(\text{i})

Let I=∫e−xcos⁡x dxI = \int e^{-x}\cos x\,dx⁠. Integrating by parts with cos⁡x\cos x as the first function,

I=cos⁡x (−e−x)−∫(−sin⁡x)(−e−x) dx=−e−xcos⁡x−∫e−xsin⁡x dx\begin{aligned} I &= \cos x\,(-e^{-x}) \\ &\quad - \int(-\sin x)(-e^{-x})\,dx \\ &= -e^{-x}\cos x - \int e^{-x}\sin x\,dx \end{aligned}

Again by parts, with sin⁡x\sin x as the first function,

I=−e−xcos⁡x−[sin⁡x (−e−x)−∫cos⁡x (−e−x) dx]=−e−xcos⁡x+e−xsin⁡x−I\begin{aligned} I &= -e^{-x}\cos x - \bigg[\sin x\,(-e^{-x}) \\ &\qquad - \int\cos x\,(-e^{-x})\,dx\bigg] \\ &= -e^{-x}\cos x + e^{-x}\sin x - I \end{aligned} 2I=(sin⁡x−cos⁡x)e−xI=(sin⁡x−cos⁡x)e−x2\begin{aligned} 2I &= (\sin x - \cos x)e^{-x} \\ I &= \frac{(\sin x - \cos x)e^{-x}}{2} \end{aligned}

Putting the value of II in (i),

ye−x=sin⁡x−cos⁡x2 e−x+Cye^{-x} = \frac{\sin x - \cos x}{2}\,e^{-x} + C

∴\therefore y=sin⁡x−cos⁡x2+Cexy = \dfrac{\sin x - \cos x}{2} + Ce^x is the general solution.

Want the reason behind every step, the basics and the checks?

The one idea this problem is built on

The equation is linear: yy and dydx\frac{dy}{dx} appear only to the first power, with coefficients that depend on xx only. Multiplying it by the integrating factor e∫P dx=e−xe^{\int P\,dx} = e^{-x} makes the left side the derivative of one product, ddx(ye−x)\frac{d}{dx}\left(ye^{-x}\right)⁠. Then one integration solves it; the only real work is the integral ∫e−xcos⁡x dx\int e^{-x}\cos x\,dx⁠, which needs integration by parts twice.

Given, to find, and the plan
Given
dydx−y=cos⁡x\frac{dy}{dx} - y = \cos x⁠, for all real xx⁠.
To find
The general solution (one arbitrary constant).
Plan
(1) Match dydx+Py=Q\frac{dy}{dx} + Py = Q⁠: find PP and QQ⁠. (2) Find I.F. =e∫P dx= e^{\int P\,dx}⁠. (3) Multiply and see the product rule. (4) Integrate: y⋅I.F.=∫Q⋅I.F. dx+Cy\cdot\text{I.F.} = \int Q\cdot\text{I.F.}\,dx + C⁠. (5) Find ∫e−xcos⁡x dx\int e^{-x}\cos x\,dx by parts twice. (6) Solve for yy⁠. (7) Check by substitution.

Basics you need

1First order linear equations

dydx+Py=Q\frac{dy}{dx} + Py = Q⁠, where PP and QQ are constants or functions of xx only, is linear. Its solution is y (I.F.)=∫(Q×I.F.) dx+Cy\,(\text{I.F.}) = \int(Q\times\text{I.F.})\,dx + C⁠, where I.F.=e∫P dx\text{I.F.} = e^{\int P\,dx} (Section 9.4.3). Lesson: linear equations, the integrating factor

2Why the integrating factor works

If g′=Pgg' = Pg⁠, then g y′+Pg y=g y′+g′ y=(yg)′g\,y' + Pg\,y = g\,y' + g'\,y = (yg)'⁠, by the product rule. g=e∫P dxg = e^{\int P\,dx} has g′=Pgg' = Pg⁠. Basics: (y · g)′ = g(y′ + Py)

3Integration by parts

∫f g dx=f∫g dx−∫(f′∫g dx)dx\int f\,g\,dx = f\int g\,dx - \int\left(f'\int g\,dx\right)dx⁠, with ff the first function (Section 7.6). Basics: every method ends with an integral

4Exponentials

ddxe−x=−e−x\frac{d}{dx}e^{-x} = -e^{-x}⁠, so ∫e−x dx=−e−x\int e^{-x}\,dx = -e^{-x}⁠; and e−x⋅ex=1e^{-x}\cdot e^x = 1⁠. Basics: the function whose rate is k times itself

Solution

  1. Recognise the linear form: P=−1P = -1⁠, Q=cos⁡xQ = \cos x

    dydx+(−1) y=cos⁡x.\frac{dy}{dx} + (-1)\,y = \cos x.
    Compare with dydx+Py=Q\frac{dy}{dx} + Py = Q⁠. Here yy and dydx\frac{dy}{dx} appear to the first power only, the coefficient of yy is the constant −1-1⁠, and the right side cos⁡x\cos x depends on xx only. So the equation is linear with P=−1P = -1⁠, Q=cos⁡xQ = \cos x⁠. (It is not separable: cos⁡x+y\cos x + y does not split as a product of a function of xx and a function of yy⁠.)
    Section 9.4.3: first order linear equation, step (i). Lesson: linear equations
  2. The integrating factor

    I.F.=e∫P dx=e∫−1 dx=e−x.\text{I.F.} = e^{\int P\,dx} = e^{\int -1\,dx} = e^{-x}.
    Any one antiderivative of PP will do: a constant added to −x-x would only multiply the I.F. by a nonzero constant, which cancels later. So no constant of integration is written here; the solution's one constant comes in Step 4.
    Section 9.4.3, step (ii). Basics: (y · g)′ = g(y′ + Py)
  3. Multiply by the I.F.: the left side is one derivative

    e−xdydx−e−xy=e−xcos⁡xddx(ye−x)=e−xcos⁡x.\begin{aligned} e^{-x}\frac{dy}{dx} - e^{-x}y &= e^{-x}\cos x \\ \frac{d}{dx}\left(ye^{-x}\right) &= e^{-x}\cos x. \end{aligned}
    By the product rule, ddx(ye−x)=e−xdydx+y⋅(−e−x)\frac{d}{dx}\left(ye^{-x}\right) = e^{-x}\frac{dy}{dx} + y\cdot(-e^{-x})⁠, which is exactly the left side. This is the whole point of the integrating factor.
    Product rule (Chapter 5, Section 5.3); Section 9.4.3. Basics: (y · g)′ = g(y′ + Py)
  4. Integrate both sides, with one constant

    ye−x=∫e−xcos⁡x dx+C.…(1)ye^{-x} = \int e^{-x}\cos x\,dx + C.\quad\ldots(1)
    A function whose derivative is e−xcos⁡xe^{-x}\cos x is an antiderivative of it, plus an arbitrary constant. This CC is the one arbitrary constant of the general solution, so when we find the integral in Step 5 we add no further constant.
    Section 9.4.3, step (iii): y (I.F.)=∫(Q×I.F.) dx+Cy\,(\text{I.F.}) = \int(Q\times\text{I.F.})\,dx + C⁠. Basics: one constant for order 1
  5. Find I=∫e−xcos⁡x dxI = \int e^{-x}\cos x\,dx⁠: by parts twice

    Take cos⁡x\cos x as the first function and e−xe^{-x} as the second, so ∫e−x dx=−e−x\int e^{-x}\,dx = -e^{-x}⁠:

    I=cos⁡x (−e−x)−∫(−sin⁡x)(−e−x) dx=−e−xcos⁡x−∫e−xsin⁡x dx.\begin{aligned} I &= \cos x\,(-e^{-x}) \\ &\quad - \int(-\sin x)(-e^{-x})\,dx \\ &= -e^{-x}\cos x - \int e^{-x}\sin x\,dx. \end{aligned}

    Again by parts, now with sin⁡x\sin x first:

    ∫e−xsin⁡x dx=sin⁡x (−e−x)−∫cos⁡x (−e−x) dx=−e−xsin⁡x+I.\begin{aligned} &\int e^{-x}\sin x\,dx \\ &= \sin x\,(-e^{-x}) \\ &\quad - \int\cos x\,(-e^{-x})\,dx \\ &= -e^{-x}\sin x + I. \end{aligned}

    So

    I=−e−xcos⁡x+e−xsin⁡x−I2I=(sin⁡x−cos⁡x)e−xI=(sin⁡x−cos⁡x)e−x2.\begin{aligned} I &= -e^{-x}\cos x + e^{-x}\sin x - I \\ 2I &= (\sin x - \cos x)e^{-x} \\ I &= \frac{(\sin x - \cos x)e^{-x}}{2}. \end{aligned}
    Each integration by parts turns cosine into sine or back, and the exponential stays an exponential. After two rounds the original integral II reappears with a minus sign, so we can solve for II like an ordinary unknown. The first function must be the trigonometric one both times (or the exponential both times); switching halfway just undoes the first step.
    Section 7.6, integration by parts. Basics: every method ends with an integral
  6. Solve for yy

    Putting II into (1):

    ye−x=sin⁡x−cos⁡x2 e−x+Cy=sin⁡x−cos⁡x2+Cex.\begin{aligned} ye^{-x} &= \frac{\sin x - \cos x}{2}\,e^{-x} + C \\ y &= \frac{\sin x - \cos x}{2} + Ce^x. \end{aligned}
    Multiply both sides by exe^x (never zero): e−xex=1e^{-x}e^x = 1⁠, and CC becomes CexCe^x⁠. The answer holds for every real xx⁠, since PP and QQ are defined everywhere.
    Section 9.4.3: the general solution. Basics: exponentials
  7. Check by substituting back

    From y=sin⁡x−cos⁡x2+Cexy = \frac{\sin x - \cos x}{2} + Ce^x⁠:

    dydx=cos⁡x+sin⁡x2+Cexdydx−y=cos⁡x+sin⁡x−sin⁡x+cos⁡x2=cos⁡x,\begin{aligned} \frac{dy}{dx} &= \frac{\cos x + \sin x}{2} + Ce^x \\ \frac{dy}{dx} - y &= \frac{\cos x + \sin x - \sin x + \cos x}{2} \\ &= \cos x, \end{aligned}

    for every CC⁠: the CexCe^x terms cancel.

    Substituting back proves the answer, and shows the role of each part: CexCe^x solves dydx−y=0\frac{dy}{dx} - y = 0 on its own, and sin⁡x−cos⁡x2\frac{\sin x - \cos x}{2} supplies the cos⁡x\cos x⁠.
    A solution makes L.H.S. = R.H.S. (Section 9.3). Lesson: general and particular solutions
Result

The general solution is y=sin⁡x−cos⁡x2+Cexy = \frac{\sin x - \cos x}{2} + Ce^x⁠, where CC is an arbitrary constant, for all real xx⁠. (Textbook answer: y=(sin⁡x−cos⁡x2)+Cexy = \left(\frac{\sin x - \cos x}{2}\right) + Ce^x⁠.)

Check it with numbers

Take C=1C = 1 and x=1x = 1⁠: sin⁡1≈0.8414710\sin 1 \approx 0.8414710⁠, cos⁡1≈0.5403023\cos 1 \approx 0.5403023⁠, e≈2.7182818e \approx 2.7182818⁠, so y≈2.8688662y \approx 2.8688662⁠. The equation says dydx=y+cos⁡x≈3.4091685\frac{dy}{dx} = y + \cos x \approx 3.4091685⁠.

The curve itself: y(1.001)≈2.8722766206y(1.001) \approx 2.8722766206 and y(0.999)≈2.8654582830y(0.999) \approx 2.8654582830⁠, so

2.8722766206−2.86545828300.002≈3.40917.\begin{aligned} &\frac{2.8722766206 - 2.8654582830}{0.002} \\ &\approx 3.40917. \end{aligned}
Common mistakes
  1. Taking P=1P = 1⁠. The standard form has +Py+Py⁠, so −y-y means P=−1P = -1 and I.F. =e−x= e^{-x}⁠.
  2. Adding a constant inside the I.F. or a second constant when finding II⁠; the general solution has one constant, the CC of Step 4.
  3. Changing the first function in the second integration by parts; that only takes you back to where you started.
  4. Forgetting to multiply CC by exe^x when solving for yy⁠: the answer is +Cex+Ce^x⁠, not +C+C⁠.
What to take away
  1. Linear equation: write dydx+Py=Q\frac{dy}{dx} + Py = Q⁠, read off PP and QQ with their signs, then I.F. =e∫P dx= e^{\int P\,dx}⁠.
  2. The solution is y (I.F.)=∫Q (I.F.) dx+Cy\,(\text{I.F.}) = \int Q\,(\text{I.F.})\,dx + C⁠; the constant appears once, here.
  3. ∫eaxcos⁡bx dx\int e^{ax}\cos bx\,dx and ∫eaxsin⁡bx dx\int e^{ax}\sin bx\,dx⁠: by parts twice, then solve for the integral.

Every fact used, and where it comes from

FactUsed inSource
Linear equation dydx+Py=Q\frac{dy}{dx} + Py = Q⁠; I.F. =e∫P dx= e^{\int P\,dx}⁠; y (I.F.)=∫(Q×I.F.) dx+Cy\,(\text{I.F.}) = \int(Q\times\text{I.F.})\,dx + CSteps 1, 2, 4Section 9.4.3, steps (i) to (iii) (Lesson)
Product rule: ddx(ye−x)=e−xy′−e−xy\frac{d}{dx}(ye^{-x}) = e^{-x}y' - e^{-x}yStep 3Chapter 5, Section 5.3 (Basics)
One arbitrary constant for a first order equationStep 4Chapter Summary (Basics)
Integration by parts; ∫e−x dx=−e−x\int e^{-x}\,dx = -e^{-x}Step 5Section 7.6; Section 7.2, formula (xi) with substitution (Basics)
(ex)′=ex(e^x)' = e^x⁠, (sin⁡x)′=cos⁡x(\sin x)' = \cos x⁠, (cos⁡x)′=−sin⁡x(\cos x)' = -\sin xStep 7Chapter 5, Section 5.4; Class XI (Basics)
Found an error, or want more?

Tell us if something on this page is wrong or unclear, or if you would like a fuller explanation, another method or a new feature. Send feedback on this problem →