Derivation of the variation of parameters in Second-Order Differential Eq. In Second-Order ODEs ,There is a problem which I haven't solved.
Method of Variation of Parameters;
In derivation of the method , there is a part which is following.
$$k'[2Pu'_1 + Qu_1] + k''[Pu_1]=0 \\
k'=\frac{e^{-\int [Q/P]dx}}{u_1^2}$$
But I find  $$k=\frac{e^{-\int [Q/P]dx}}{u_1^2}$$
I could't understand how they find k' like that.İs it typo or my result is wrong ?
Here is my attempt to solve;
$$[2Pu'_1 + Qu_1]\frac{dk}{dx}=-[Pu_1]\frac{d(\frac{dk}{dx})}{dx} \\
\int [2Pu'_1 + Qu_1]dk=\int [Pu_1]d(\frac{dk}{dx}) \\
[2Pu'_1 + Qu_1]k=[Pu_1]\frac{dk}{dx} \\
k=\frac{e^{-\int [Q/P]dx}}{u_1^2}$$
 A: The result with $k'$ is correct. The ODE is a first order ODE for $\kappa(x) = k'(x)$, given by
\begin{equation}
 \kappa' P u_1 + \kappa(2 P u_1' + Q u_1) = 0,
\end{equation}
which can be solved for $\kappa$, yielding
\begin{equation}
 \kappa(x) = c_1 \frac{e^{-\frac{Q}{x P}}}{u_1(x)^2}.
\end{equation}
Addition based on edited question: Let's solve your equation step by step. I'm making the $x$-dependence of all the functions involved explicit, because this matters quite a lot.
The equation you would like to solve is
\begin{equation}
P(x) u_1(x) \frac{\text{d}^2 k}{\text{d} x^2}(x) + \frac{\text{d} k}{\text{d} x}(x) \left( 2 P(x) \frac{\text{d} u_1}{\text{d} x} + Q(x)\, u_1(x)\right) = 0. \tag{1}
\end{equation}
Assuming that $P(x) \neq 0$, $u_1(x) \neq 0$ and $\frac{\text{d} k}{\text{d} x} \neq 0$ on the domain in question, we can rewrite $(1)$ to get
\begin{align}
\frac{\frac{\text{d}^2 k}{\text{d} x^2}(x)}{\frac{\text{d} k}{\text{d} x}(x)} &= -\frac{ 2 P(x) \frac{\text{d} u_1}{\text{d} x} + Q(x)\, u_1(x)}{P(x) u_1(x)}\\
&= -2\frac{\frac{\text{d} u_1}{\text{d} x}}{u_1(x)} -\frac{Q(x)}{P(x)}. \tag{2}
\end{align}
To solve this equation, we can integrate on both sides to $x$. Forget things like 'multiplying by $\text{d}x$', because this suggests that $\text{d}x$ is a quantity with which you can calculate without problems, which isn't true. Moreover, having a quite complicated ODE such as $(2)$, with a number of $x$-dependent functions involved, it is easy to loose track of what the dependent variable is.
Let's first integrate the left hand side of $(2)$. To do that, we can recognise the integrand as the derivative of $\ln \frac{\text{d} k}{\text{d} x}(x)$, so that
\begin{equation}
 \int^x \frac{\frac{\text{d}^2 k}{\text{d} x^2}(x)}{\frac{\text{d} k}{\text{d} x}(x)}\,\text{d} x = \int^x \frac{\text{d}}{\text{d} x}\left[\ln \frac{\text{d} k}{\text{d} x}(x)\right]\,\text{d} x = \ln \frac{\text{d} k}{\text{d} x}(x) + c_1,\tag{3}
\end{equation}
because the integral of a derivative is just the function itself. Here, $c_1$ is just an integration constant.
The integral to $x$ of the right hand side of $(2)$ can be split into two parts, namely
\begin{equation}
 \int^x -2\frac{\frac{\text{d} u_1}{\text{d} x}}{u_1(x)} -\frac{Q(x)}{P(x)}\,\text{d} x = -2 \int^x \frac{\frac{\text{d} u_1}{\text{d} x}}{u_1(x)} \,\text{d} x - \int^x \frac{Q(x)}{P(x)}\,\text{d} x. \tag{4}
\end{equation}
Similar to $(3)$, we can recognise the integrand of the first integral in $(4)$ as the derivative of $\ln u_1(x)$, so that
\begin{equation}
  -2 \int^x \frac{\frac{\text{d} u_1}{\text{d} x}}{u_1(x)} \,\text{d} x =  -2 \int^x \frac{\text{d}}{\text{d} x}\left[\ln u_1(x)\right] \,\text{d} x = -2 \ln u_1(x) + c_2. \tag{5}
\end{equation}
Because $P$ and $Q$ are general, we can't really say anything useful about the integral $\int^x \frac{Q(x)}{P(x)}\,\text{d} x$, so we leave that as it is.
Combining the results of $(3)$,$(4)$ and $(5)$ in $(2)$, we get
\begin{equation}
 \ln \frac{\text{d} k}{\text{d} x}(x) = -2 \ln u_1(x) - \int^x \frac{Q(x)}{P(x)}\,\text{d} x + c, \tag{6}
\end{equation}
where both integration constants $c_{1,2}$ are combined in $c$. We can solve $(6)$ for $\frac{\text{d} k}{\text{d} x}(x)$ by taking the exponential of both sides, yielding
\begin{equation}
 \frac{\text{d} k}{\text{d} x}(x) = e^{-2 \ln u_1(x) - \int^x \frac{Q(x)}{P(x)}\,\text{d} x + c} =\frac{1}{u_1(x)^2} e^{- \int^x \frac{Q(x)}{P(x)}\,\text{d} x + c}.
\end{equation}
A: Frits Veerman's described method:
$$k'[2Pu'_1 + Qu_1]=-[Pu_1]\frac{d(k')}{dx} \\
[2Pu'_1 + Qu_1]dx=\frac{d(k')}{k'} \\
k'=\frac{e^{-\int [Q/P]dx}}{u_1^2}$$
But when I try to direct solution based on k:
$$[2Pu'_1 + Qu_1]\frac{dk}{dx}=-[Pu_1]\frac{d(\frac{dk}{dx})}{dx} \\
\int [2Pu'_1 + Qu_1]dk=\int [Pu_1]d(\frac{dk}{dx}) \\
[2Pu'_1 + Qu_1]k=[Pu_1]\frac{dk}{dx} \\
k=\frac{e^{-\int [Q/P]dx}}{u_1^2}$$
Where exactly is my mistake ?
