# NCERT Solutions for Class 12 Maths Chapter 9 Differential Equations

Q. Find the general solution of the differential equation $$\frac{dy}{dx} = \frac{1-cos\space x}{1+cos\space x}.$$

$$\textbf{Ans. }\text{Given differential equation is } \\ \frac{dy}{dx} = \frac{1-cos\space x}{1+cos\space x} \\ dy = \left(\frac{1-cos\space x}{1+cos\space x}\right)dx \\ dy = \left(\frac{2sin^2\frac{x}{2}}{2cos^2\frac{x}{2}}\right)dx \\ dy = tan^2 \frac{x}{2}dx \\ dy = \left(sec^2\frac{x}{2}-1\right)dx \\ \text{Integrating both sides: } \\ y = \int\left(sec^2 \frac{x}{2}-1\right)dx + C \\ y = \frac{tan\frac{x}{2}}{\frac{1}{2}}-x+C \\ y = 2 \space tan\frac{x}{2}-x + C \\ \text{which is the required general solution.}$$

Q. Find the general solution of the differential equation $$\frac{dy}{dx}+y = 1, \space (y\not= 1).$$

$$\textbf{Ans. } \text{Given differential equation is, }\\ \frac{dy}{dx}+y = 1 \\ \Rightarrow \space \space \space \frac{dy}{dx} = 1-y \\ \Rightarrow \space \space \space \frac{dy}{1-y} = dx \\ \text{Integrating both sides} \\ \text{– log (1 – y) = x + C} \\ \text{⇒\space \space log (1 – y) = – x – C} \\ \Rightarrow 1-y = e^{-x-C} = e^{-x}.e^{-C} \\ \Rightarrow \space \space 1-y = Ae^{-x}, \space \space \text{where }\space A = \space e^{-C} \\\Rightarrow \space \space y = 1-Ae^{-x} \\ \text{which is the required general solution.}$$

Q. Find the particular solution of $$\frac{dy}{dx}+2y\space tan\space x = sin\space x \space \textbf{satisfying condition } x = \frac{\pi}{3}\space =\space \textbf{when} \space y = 0.$$

$$\textbf{Ans. } \text{Given differential equation is, } \\ \frac{dy}{dx}+ 2y \space tan\space x = sin\space x \space \space …(i) \\ \text{Here} \space \space P = 2 \space tan\space x,\space Q = sin\space x \\ I.F. = e^{\int P\space dx}= e^{2\int tan\space x\space dx} \\ = e^{2(-log\space cos\space x)} \\ = e^{log\space (cos\space x)^{-2}} = \frac{1}{cos^2 \space x} \\ \text{Multiplying equation (i) by I.F.} \\ \frac{1}{cos^2x}\frac{dy}{dx} + 2y \frac{tan\space x}{cos^2x} = \frac{sin\space x}{cos^2 x} \\ \frac{d}{dx}(y\space sec^2 x) = sec\space x \space tan\space x \\ \text{Integrating both sides } \\ y \space sec^2x = \int sec\space x \space tan\space x \space dx \space + C \\ y\space sec^2\space x = sec \space x + C \space \space \space …(i) \\ \text{When} \space \space \space x = \frac{\pi}{3}, y = 0 \\ 0 = sec\frac{\pi}{3}+ C \\ \therefore \space \space \space C=-2 \\ \text{Put in equation (ii), } \\ y\space sec^2 x = sec\space x -2 \\ \text{which is the required solution.}$$

Q. Solve the differential equation : $$\space \left( xcos\frac{y}{x}+ ysin\frac{y}{x}\right)y- \left(ysin\frac{y}{x}-xcos\frac{y}{x}\right)x\frac{dy}{dx} = 0$$

$$\textbf{Ans. } \text{Given differential equation is } \\ \left( xcos\frac{y}{x}+ ysin\frac{y}{x}\right)y- \left(ysin\frac{y}{x}-xcos\frac{y}{x}\right)x\frac{dy}{dx} = 0 \\ \Rightarrow \space \space \left( xcos\frac{y}{x}+ ysin\frac{y}{x}\right)y= – \left(ysin\frac{y}{x}-xcos\frac{y}{x}\right)x\frac{dy}{dx}\\ \Rightarrow \space \space \frac{dy}{dx} = \frac{\left( xcos\frac{y}{x}+ ysin\frac{y}{x}\right)y}{\left( ysin\frac{y}{x}- xcos\frac{y}{x}\right)x} \\= \frac{x\left(cos\frac{y}{x}+\frac{y}{x}sin\frac{y}{x}\right)y}{x\left(\frac{y}{x}sin\frac{y}{x}-cos\frac{y}{x}\right)x} \\ \Rightarrow \space \space \space \frac{dy}{dx} = \frac{\left(cos\frac{y}{x}+\frac{y}{x}sin\frac{y}{x}\right)\frac{y}{x}}{\frac{y}{x}sin\frac{y}{x}-cos\frac{y}{x}} \space \space \space …(i)\\ \text{Put} \space \space \frac{y}{x} = t \\ \Rightarrow \space \space y = xt \\ \text{Differentiate w.r.t. x } \\ \frac{dy}{dx} = x\frac{dt}{dx}+ t \\ \text{Put in equation (i), } \\ x\frac{dt}{dx}+ t = \frac{t(cos\space t + tsin\space t)}{tsin\space t-cos\space t} \\ \Rightarrow \space \space x\frac{dt}{dx} = \frac{tcos\space t+t^2 sin\space t}{tsin\space t-cos\space t}-t \\ = \frac{tcos\space t + t^2 \space sin\space t-t^2sin\space t + t\space cos\space t}{tsin\space t-cos\space t} \\ \Rightarrow \space \space x\frac{dt}{dx} = \frac{2t\space cos\space t}{tsin\space t – cos\space t} \\ \Rightarrow \space \space \frac{tsin\space t -cos\space t}{2t\space cos\space t}dt = \frac{dx}{x} \\ \left(\frac{tsin\space t}{2t\space cos\space t}-\frac{cos\space t}{2t\space cos\space t}\right)dt = \frac{dx}{x} \\ \text{Integrating both sides} \\ \int \left(\frac{1}{2}tan\space t – \frac{1}{2t}\right)dt = \int \frac{dx}{x}+C \\ \Rightarrow \space \space \frac{1}{2}(-log|\space cos\space t \space |-log|t|) = log \space |x| + C \\ \Rightarrow \space \space log|\space cos\space t \space |+ log|t| = -2 log \space |\space x\space|-2C \\ \Rightarrow \space \space log(t\space cos \space t) = -log\space x^2 -2C \\ \Rightarrow \space \space log\space (t\space cos\space t) + log\space x^2 =-2C \\ \Rightarrow \space \space log\space (t\space cos\space t × x^2) = -2C \\ \Rightarrow \space \space x^2 t\space cos \space t = e^{-2C}\\ \Rightarrow \space \space \frac{y}{x}\left(cos\frac{y}{x}\right)x^2 = A \space \space \begin{bmatrix}\because \space t = \frac{y}{x} \end{bmatrix} \\ (\text{where} \space A \space = e^{-2C}) \\ \Rightarrow \space \space xy\space cos \frac{y}{x} = A \\ \text{which is required solution.}$$

Q. Find the particular solution of the following differential equation :  $$x\frac{dy}{dx}-y+x sin\frac{y}{x}\space =\space 0, \space \textbf{given that when}\space x = 2,\space y = \pi.$$

$$\textbf{Ans. } \text{Given differential equation is, } \\ x\frac{dy}{dx}-y + xsin\space\frac{y}{x} = 0 …(i) \\ \text{Divide by x } \\ \frac{dy}{dx}-\frac{y}{x}+ sin\frac{y}{x}=0 \\ \Rightarrow \space \space \frac{dy}{dx} = \frac{y}{x}-sin\frac{y}{x} \space \space …(ii) \\ \text{Put} \space \space \frac{y}{x} = t \Rightarrow \space y = xt \space \\ \text{Differentiate w.r.t. x } \\ \frac{dy}{dx} = x\frac{dt}{dx} + t \\ \text{Put in equation (ii) } \\ x\frac{dt}{dx}+t = t-sin\space t \\ \Rightarrow \space \space x\frac{dt}{dx} = -sin\space t \\ \Rightarrow \space \space \frac{dt}{sin\space t} = -\frac{dx}{x} \\ \Rightarrow \space \space cosec\space t \space dt =\space – \frac{dx}{x} \\ \text{On integrating both sides, we have } \\ \Rightarrow \space \space \int cosec\space t \space dt = -\int \frac{dx}{x} \\ \Rightarrow \space \space log | \space cosec\space t – cot\space t| = -log\space x + log\space C \\ \Rightarrow \space \space log \begin{vmatrix}cosec \frac{y}{x}-cot\frac{y}{x} \end{vmatrix}= – log\space x + log\space C \\\Rightarrow \space \space log \begin{vmatrix}cosec \frac{y}{x}-cot\frac{y}{x} \end{vmatrix} = log\frac{C}{x}\\ \Rightarrow \space \space cosec\frac{y}{x}-cot\frac{y}{x} = \frac{C}{x} \space \space …(iii) \\ \text {Put x = 2, y = π} \\ \Rightarrow \space \space cosec\frac{\pi}{2}-cot\frac{\pi}{2} = \frac{C}{2} \\ \Rightarrow \space 1-0 = \frac{C}{2} \\ \Rightarrow \space \space C = 2 \space \\ \text{Put in equation (iii)} \\ cosec\frac{y}{x}-cot\frac{y}{x}= \frac{2}{x} \\ \text{which is the required solution of given differential equation.}$$

Q. Show that the differential equation $$x\frac{dy}{dx}sin\frac{y}{x}+ x-ysin\frac{y}{x} = 0\space \textbf{is homogeneous and find the particular solution when x = 1 and y = } \frac{\pi}{2}$$

$$\textbf{Ans. } \text{Given differential equation is, } \\ x\frac{dy}{dx}sin\frac{y}{x} + x – ysin\frac{y}{x} = 0 \space \space …(i) \\ \Rightarrow \space \space x\frac{dy}{dx}sin\frac{y}{x} = y\space sin\frac{y}{x} – x \\ \Rightarrow \space \space \frac{dy}{dx} = \frac{ysin\frac{y}{x}-x}{xsin\frac{y}{x}} \\ \Rightarrow \space \space \frac{dy}{dx} = \frac{\frac{y}{x}sin\frac{y}{x}-1}{sin\frac{y}{x}} \space \space …(ii) \\ \text{which is homogeneous differential equation of the form } f\left(\frac{y}{x}\right) \\ \text{Put }\frac{y}{x}=t, \space \space y = xt \\ \text{Differentiate both sides w.r.t. x }\\ \frac{dy}{dx} = x \frac{dt}{dx}+ t \\ \text{ Put in equation (ii)} \\ x\frac{dt}{dx} + t = \frac{tsin\space t-1}{sin\space t}\\ \Rightarrow \space \space x\frac{dt}{dx}= \frac{tsin\space t – 1 – t\space sin\space t}{sin\space t}\\ \Rightarrow \space \space x\frac{dt}{dx} = -\frac{1}{sin\space t} \\ \Rightarrow \space \space sin\space t \space dt = – \frac{dt}{x} \\ \text{Integrating both sides : } \\ -cos\space t = -log\space x + C \\ \Rightarrow \space \space -cos\space \frac{y}{x} = -log\space x + C \space \space …(iii) \space \begin{bmatrix}\because \space t = \frac{y}{x} \end{bmatrix}\\ \text{Put}\space x = 1 \space and \space y = \frac{\pi}{2} \\ \Rightarrow \space \space -cos\frac{\pi}{2} = -log\space 1 + C \\ \Rightarrow \space \space C = 0 \\ \text{Equation (iii) becomes : } \\ -cos \frac{y}{x} = -log\space x + 0 \\ \Rightarrow \space \space cos\frac{y}{x} = log\space x \\ \text{which is the required particular solution. }$$

Q. Show that the given differential equation is homogeneous and solve each of them. $$\textbf{(i)}\space (x^2 + xy)\space dy = (x^2 + y^2)\space dx$$

$$\textbf{Ans. } \text{The given differential equation is, } \\ (x^2 + xy) dy = (x^2 + y^2) dx \\ \Rightarrow \space \space \frac{dy}{dx} = \frac{x^2+y^2}{x^2 + xy} \\ = \frac{x^2\left(1+\frac{y^2}{x^2}\right)}{x^2 \left(1+\frac{y}{x}\right)}\\ \Rightarrow \space \space \frac{dy}{dx} = \frac{1+\left(\frac{y}{x}\right)^2}{1+\frac{y}{x}} \space \space …(i) \\ \therefore \text{It is homogeneous equation of the form } \space f\left(\frac{y}{x}\right) \\ \text{Put}\space \frac{y}{x} = t, \Rightarrow y = xt \\ \text{Differentiate w.r.t. x } \\ \frac{dy}{dx} = x\space \frac{dt}{dx}+t \\ \text{Put in equation (i), } \\ x\frac{dt}{dx} + t = \frac{1+t^2}{1+t} \\ \Rightarrow \space \space x\frac{dt}{dx} = \frac{1+t^2}{1+t}-t \\ \Rightarrow \space \space x\frac{dt}{dx} = \frac{1+t^2-t-t^2}{1+t} \\ \Rightarrow \space \space x\frac{dt}{dx} = \frac{1-t}{1+t} \\ \Rightarrow \space \space \frac{1+t}{1-t}dt = \frac{dx}{x} \\ \text{Integrating both sides } \\ \int\left(-1+\frac{2}{-t+1}\right)dt = \frac{dx}{x} \\ \Rightarrow \space \space -t-2log\space |-t+1| = log\space x+C \\ \Rightarrow \space \space -2log\space |1-t| = log\space x + t + C \\ \Rightarrow \space \space -2\space log | \space 1-t\space | -log\space x=t+C \\ \Rightarrow \space \space -(2\space log\space | 1-t| + log \space x) = t + C \\ \Rightarrow \space \space log\space (1-t)^2 + log\space x = -t-C \\ \Rightarrow \space \space log[x(1-t)^2] = -t-C \\ \Rightarrow \space \space log\begin{bmatrix} x\left(1-\frac{y}{x}\right)^2\end{bmatrix} = -\frac{y}{x}-C \space \space \left(\because t = \frac{y}{x}\right) \\ \Rightarrow \space \space x\left(1-\frac{y}{x}\right)^2 = e^{-y/x-C} \\ \Rightarrow \space \space x\left(1-\frac{y}{x}\right)^2= e^{-y/x.}e^{-C} \\ \Rightarrow \space \space \frac{x(x-y)^2}{x^2} = e^{-y/x.}A, \space \space \text{where}\space A = e^{-C} \\ \Rightarrow \space \space (x – y)^2 = xe^{– y/x} A \\ \text{which is the required solution. }$$

$$\textbf{(ii)} \space x^2\frac{dy}{dx} \space = x^2-2y^2+xy$$

$$\textbf{Ans. } \text{Given differential equation is} \\ \space x^2\frac{dy}{dx} \space = x^2-2y^2+xy \\ \Rightarrow \space \space \space \frac{dy}{dx} = \frac{x^2}{x^2}-2\frac{y^2}{x^2}+\frac{xy}{x^2} \\ \Rightarrow \space \space \frac{dy}{dx} =\space 1-2\left(\frac{y}{x}\right)^2 + \frac{y}{x} \space \space …(i) \\ \text{which is homogeneous equation of the form } f\left(\frac{y}{x}\right) \\ Put\space \frac{y}{x} = t \Rightarrow \space \space y = xt \space \\ \text{Differentiate w.r.t. x, } \\ \frac{dy}{dx} = \space x\frac{dt}{dx} + t \\ \text{Put in equation (i), } \\ x\frac{dt}{dx}+t = 1 – 2t^2 + t \\ \Rightarrow \space \space x\frac{dt}{dx} = 1-2t^2 \\ \Rightarrow \space \space \frac{dt}{1-2t^2} = \frac{dx}{x} \\ \text{Integrating both sides } \\ \frac{1}{2}\int \frac{dt}{\left(\frac{1}{\sqrt{2}}\right)^2-t^2} = \int \frac{dx}{x}+C \\ \Rightarrow \space \space \frac{1}{2}.\frac{1}{2×\frac{1}{\sqrt{2}}}log\begin{vmatrix}\frac{\frac{1}{\sqrt{2}}+t}{\frac{1}{\sqrt{2}}-t} \end{vmatrix} = log\space x + C \\ \Rightarrow \space \space \frac{1}{2\sqrt{2}}log\begin{vmatrix}\frac{1+\sqrt{2}t}{1-\sqrt{2}t} \end{vmatrix} = log\space x + C \\ \Rightarrow \space \space \frac{1}{2\sqrt{2}}log\begin{vmatrix}\frac{1+\sqrt{2}\frac{y}{x}}{1-\sqrt{2}\frac{y}{x}} \end{vmatrix} = log\space x + C \\ \Rightarrow \space \space \frac{1}{2\sqrt{2}}log \begin{vmatrix}\frac{x+\sqrt{2}y}{x-\sqrt{2}y} \end{vmatrix} = \text{log x} +C \\ \text{which is the required solution. }$$

Q. Find the particular solution of the differential equation $$2xy + y^2 – 2x^2 \frac{dy}{dx} = 0, \space \textbf{given} \space y = 2 \space \textbf{when} \space x = 1.$$

$$\textbf{Ans. } \text{Given differential equation is, }\\2xy + y^2 – 2x^2\frac{dy}{dx} = 0 \\ \Rightarrow \space \space 2x^2 \frac{dy}{dx} = 2xy + y^2 \\ \Rightarrow \space \space \frac{dy}{dx} = \frac{2xy}{2x^2}+\frac{y^2}{2x^2} \\ \Rightarrow \space \space \frac{dy}{dx} = \frac{y}{x}+\frac{1}{2}\left(\frac{y}{x}\right)^2 \space \space …(i)\\ \text{which is homogeneous equation of the form }\space f\left(\frac{y}{x}\right) \\ \text{Put} \space \frac{y}{x} = t \space \space \Rightarrow \space \space y = xt \\ \text{Differentiate w.r.t. x } \\ \frac{dy}{dx} = x\frac{dt}{dx}+ t \\ \text{Put in equation (i), } \\ x\frac{dt}{dx}+ t = t + \frac{1}{2}t^2 \\ \Rightarrow \space \space x\frac{dt}{dx} = \frac{t^2}{2} \\ \Rightarrow \space \space \frac{2dt}{t^2} = \frac{dx}{x} \\ \Rightarrow \space \space 2t^{-2}dt = \frac{dx}{x} \\ \text{Integrating both sides } \\\frac{2t^{-1}}{-1} = \text{log x } + C \\ \Rightarrow \space \space -\frac{2}{t} = \text{log x } + C \\ \Rightarrow \space \space \frac{-2x}{y} = log\space x + C \begin{bmatrix}\because \space t = \frac{y}{x} \end{bmatrix}\space \space …(ii) \\ \text{When x = 1, y = 2 } \\ -\frac{2}{2} = log\space 1 + C \\ \therefore \space \space C = – 1 \\ \text{Put in equation (ii), } \\ -\frac{2x}{y} = \space log\space x-1 \\ \Rightarrow \space \space \frac{2x}{y} = 1-log\space x \\ \text{which is the required solution. }$$

Q. Find the particular solution of the differential equation (x – y) $$\frac{dy}{dx} \textbf{= (x+2y), given that y = 0 when x = 1.}$$

$$\textbf{Ans. } \text{We\space have, } \\ (x-y)\frac{dy}{dx} = (x+2y) \\ \Rightarrow \space \space \frac{dy}{dx} = \frac{x+2y}{x-y} \space \space \space \text{…(i)} \\ \text{Putting y = Vx and }\\ \frac{dy}{dx} = V + x\frac{dV}{dx} \\ \Rightarrow \space \space V + x\frac{dV}{dx} \space = \frac{x+2Vx}{x-Vx} \\ \Rightarrow \space \space V + x\frac{dV}{dx} = \frac{1+2V}{1-V} \\ \Rightarrow \space \space x\frac{dV}{dx} = \frac{1+2V}{1-V}-V\\ x\frac{dV}{dx} = \frac{1+2V-V+V^2}{1-V} \\ \frac{1-V}{1+V+V^2}dV = \frac{dx}{x} \\ \text{On integrating both sides, we get} \\ \int\frac{1-V}{1+V+V^2}dV = \int \frac{dx}{x} \space \space \text{…(ii)} \\ Let \space \space I = \int \frac{1-V}{1+V+V^2}dV \\ = \frac{-1}{2} \int \frac{2(V-1)}{1+V+V^2}dV \\ =\frac{-1}{2} \int\frac{(2V+1)-3}{1+V+V^2}dV \\ =\frac{3}{2}\int \frac{1}{1+V+V^2}dV-\frac{1}{2} \int \frac{2V+1}{1+V+V^2}dV \\ \text{Now put in (ii)} \\ \frac{3}{2}\int\frac{1}{1+V+V^2}dV- \frac{1}{2}\int \frac{1+2V}{1+V+V^2}\space dV = \int \frac{dx}{x} \\ \Rightarrow \space \space \frac{3}{2}\int \frac{dV}{\left(V+\frac{1}{2}\right)^2 + \left(\frac{\sqrt{3}}{2}\right)^2}-\frac{1}{2}\int \frac{1+2V}{1+V+V^2}\space dV = \int \frac{dx}{x} \\ \Rightarrow \space \sqrt{3}\space tan^{-1} \left(\frac{2V+1}{\sqrt{3}}\right)-\frac{1}{2}\space log\space |\space 1+V+V^2\space | = log\space |x| + C \\ \Rightarrow \space \space \sqrt{3}\space tan^{-1} \left(\frac{2y+x}{\sqrt{3}x}\right)-\frac{1}{2}log |x^2+xy +y^2| = C \space \space \text{…(iii)}\\ \text{Now, given y = 0, when x = 1. } \\ So, \space \sqrt{3} \space tan^{-1}\left(\frac{2(0)+1}{\sqrt{3}}\right)-\frac{1}{2}\space log\space |1+0+0| = C \\ \Rightarrow \space \space C = \space \sqrt{3}\space tan^{-1}\left(\frac{1}{\sqrt{3}}\right) \\ = \frac{\sqrt{3}\pi}{6} \\ \text{Putting the value of C in (iii), we get } \\ \sqrt{3}\space tan^{-1}\space \left(\frac{2y+x}{\sqrt{3}x}\right)-\frac{1}{2}\space log\space |x^2 + xy + y^2| = \frac{\sqrt{3}\pi}{6} \\ \text{Which is the required solution. }$$

Q. Solve the following differential equation : $$x\frac{dy}{dx} \textbf{+ y - x +xy cot x = 0}$$

$$\textbf{Ans. } \text{Given differential equation is }\\ x\frac{dy}{dx} + y – x +xy\space cot\space x = 0 \\ \Rightarrow \space \space x\frac{dy}{dx}+y(1+x\space cot \space x) = x \\ \Rightarrow\space \space \frac{dy}{dx}+ \frac{1+x\space cot\space x}{x}y = 1 \space \space \text{…(i)} \\ \text{Here}\space P = \space \frac{1+x\space cot\space x}{x}, Q = 1 \\ \text{I.F.} = e^{\int P \space dx} = e^{\int \left(\frac{1}{x}+ cot\space x\right)\space dx} \\ = e^{log\space x + log\space sin\space x} \\ = e^{log\space x\space sin\space x} \\ \Rightarrow \space\space \text{I.F.} = \space x\space sin\space x \\ \text{Multiply equation (i) by I.F. } \\ x\space sin\space x \frac{dy}{dx}+ x\space sin\space x \frac{1+x\space cot\space x}{x}y = x\space sin \space x \\ \frac{d}{dx}(xy\space sin\space x) = x\space sin\space x \\ \text{Integrating both sides : } \\ xy\space sin\space x = – x \space cos\space x – \int (-cos\space x) dx + C \\ xy \space sin\space x = -x\space cos\space x + sin\space x + C \\ \text{which is the required solution. }$$

Q. Solve the differential equation $$x\frac{dy}{dx} \textbf{+ y = x cos\space x + sin\space x, given that y = 1, when x = } \space \frac{\pi}{2}=$$

$$\textbf{Ans. } \text{Given differential equation is : } \\ x\frac{dy}{dx}+y = x \space cos\space x + sin\space x \\ \frac{dy}{dx}+ \frac{y}{x} = cos\space x + \frac{sin\space x}{x} \\ \text{which is of the form } \frac{dy}{dx} + Py = Q \\ \text{Where} \space P = \frac{1}{x}, Q = cos\space x + \frac{sin\space x}{x} \\ \text{I. F.} = e^{p\space dx} = e^{\frac{1}{x}dx} = e^{log\space x} = x \space \\ \text{Required solution is } \\ \text{y. I.F. }= \int \text{Q.I.F} + C \\ y.x = \int\left(cos\space x + \frac{sin\space x}{x}\right)\space x \space dx + C \\ \\ = \int\space x\space cos\space x\space dx + \int sin\space x \space dx + C \\ = x. \int cos\space x\space dx – \int \begin{bmatrix}\frac{d}{dx}(x). \int cos\space x dx \end{bmatrix}\space dx – cos\space x + C \\ \Rightarrow \space \space xy = x\space sin\space x – \int sin\space x\space dx – cos\space x + C \\ \Rightarrow \space \space xy = x\space sin\space x + cos\space x -cos\space x + C \\ \Rightarrow \space \space xy = x\space sin\space x + C\space \space \text{…(i)} \\ \text{Given, y = 1 when x } = \frac{\pi}{2} \\ \text{From eq. (i), } \\ 1× \frac{\pi}{2} = \frac{\pi}{2}sin\frac{\pi}{2} + C \\ \frac{\pi}{2}= \frac{\pi}{2}+ C \\ \Rightarrow \space \space C = 0 \\ \text{Substitute the value of c = 0 in (i), we get }\\ \text{xy = x sin x } \\ \text{y = sin x, which is the required solution. }$$

Q. Find the general solution of the differential equation $$\frac{dy}{dx}+ 3y = e^{-2x}$$

$$\textbf{Ans. } \text{We have,} \\ \frac{dy}{dx}+ 3y = e^{-2x}\space \space …(i) \\ \text{It is linear equation of the form of } \\ \frac{dy}{dx}+ Py = Q \\ \text{Here, } \space P = 3, Q = e^{-2x} \\ I.F. = e^{\int P\space dx} = e^{\int 3\space dx} = e^{3x} \\ \text{Multiply equation (i) by I.F. } \\ e^{3x}\frac{dy}{dx} + 3ye^{3x} = e^{3x.}e^{-2x} \\ \frac{d}{dx}(ye^{3x}) = e^x \\ \text{Integrating both sides }\\ ye^{3x} = e^x + C \\ y = e^{-2x} + Ce^{-3x} \\ \text{which is required solution.}$$