Skip to content
Worked Examples · Example 14

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

CBSENCERTSubjective· 3mImportance★★★★★
27% · 61/222 Questions
✓ Free question

This is a first-order linear ODE solved using the integrating factor method. The general solution is y=12sin⁡x−12cos⁡x+Cexy = \frac{1}{2} \sin x - \frac{1}{2} \cos x + C e^{x}.

The equation dydx−y=cos⁡x\frac{dy}{dx} - y = \cos x is a first-order linear ordinary differential equation. It has the standard form dydx+P(x)y=Q(x)\frac{dy}{dx} + P(x) y = Q(x), where here P(x)=−1P(x) = -1 and Q(x)=cos⁡xQ(x) = \cos x.

The key idea: we cannot directly integrate because yy and its derivative are mixed. But we can multiply both sides by a cleverly chosen function — the integrating factor — that turns the left-hand side into the derivative of a product. Once that happens, we just integrate both sides.


Step-by-step solution

1. Identify the integrating factor.

For an equation of the form dydx+P(x)y=Q(x)\frac{dy}{dx} + P(x) y = Q(x), the integrating factor is

μ(x)=e∫P(x) dx.\mu(x) = e^{\int P(x) \, dx}.

Here P(x)=−1P(x) = -1, so

∫P(x) dx=∫(−1) dx=−x.\int P(x) \, dx = \int (-1) \, dx = -x.

Thus

μ(x)=e−x.\mu(x) = e^{-x}.

2. Multiply the entire equation by μ(x)\mu(x).

Original: dydx−y=cos⁡x\frac{dy}{dx} - y = \cos x.

Multiply by e−xe^{-x}:

e−xdydx−e−xy=e−xcos⁡x.e^{-x} \frac{dy}{dx} - e^{-x} y = e^{-x} \cos x.

Notice the left-hand side is exactly the derivative of y⋅e−xy \cdot e^{-x} with respect to xx (by the product rule). Check:

ddx(ye−x)=dydxe−x+y⋅(−e−x)=e−xdydx−e−xy.\frac{d}{dx} \left( y e^{-x} \right) = \frac{dy}{dx} e^{-x} + y \cdot (-e^{-x}) = e^{-x} \frac{dy}{dx} - e^{-x} y.

So the equation becomes

ddx(ye−x)=e−xcos⁡x.\frac{d}{dx} \left( y e^{-x} \right) = e^{-x} \cos x.

3. Integrate both sides.

ye−x=∫e−xcos⁡x dx+C.y e^{-x} = \int e^{-x} \cos x \, dx + C.

Now we need the integral I=∫e−xcos⁡x dxI = \int e^{-x} \cos x \, dx. This is a classic integration by parts (or use the formula for ∫eaxcos⁡(bx) dx\int e^{ax} \cos(bx) \, dx). Let's do it carefully.

›Proof

Evaluating ∫e−xcos⁡x dx\int e^{-x} \cos x \, dx

Use integration by parts twice. Let u=e−xu = e^{-x}, dv=cos⁡x dxdv = \cos x \, dx. Then du=−e−xdxdu = -e^{-x} dx, v=sin⁡xv = \sin x.

I=e−xsin⁡x−∫sin⁡x⋅(−e−x) dx=e−xsin⁡x+∫e−xsin⁡x dx.I = e^{-x} \sin x - \int \sin x \cdot (-e^{-x}) \, dx = e^{-x} \sin x + \int e^{-x} \sin x \, dx.

Now integrate ∫e−xsin⁡x dx\int e^{-x} \sin x \, dx by parts again: let u=e−xu = e^{-x}, dv=sin⁡x dxdv = \sin x \, dx, so du=−e−xdxdu = -e^{-x} dx, v=−cos⁡xv = -\cos x.

∫e−xsin⁡x dx=−e−xcos⁡x−∫(−cos⁡x)(−e−x) dx=−e−xcos⁡x−∫e−xcos⁡x dx.\int e^{-x} \sin x \, dx = -e^{-x} \cos x - \int (-\cos x)(-e^{-x}) \, dx = -e^{-x} \cos x - \int e^{-x} \cos x \, dx.

Substitute back:

I=e−xsin⁡x+(−e−xcos⁡x−I)=e−xsin⁡x−e−xcos⁡x−I.I = e^{-x} \sin x + \left( -e^{-x} \cos x - I \right) = e^{-x} \sin x - e^{-x} \cos x - I.

So 2I=e−x(sin⁡x−cos⁡x)2I = e^{-x} (\sin x - \cos x), hence

I=12e−x(sin⁡x−cos⁡x).I = \frac{1}{2} e^{-x} (\sin x - \cos x).

Thus

ye−x=12e−x(sin⁡x−cos⁡x)+C.y e^{-x} = \frac{1}{2} e^{-x} (\sin x - \cos x) + C.

4. Solve for yy.

Multiply both sides by exe^{x}:

y=12(sin⁡x−cos⁡x)+Cex.y = \frac{1}{2} (\sin x - \cos x) + C e^{x}.

Watch out

A common mistake is forgetting the constant of integration CC or misplacing the sign when integrating by parts. Always check by differentiating your final answer.


✓Final answer

The general solution is y=12sin⁡x−12cos⁡x+Cexy = \frac{1}{2} \sin x - \frac{1}{2} \cos x + C e^{x}.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.