Why is this integration correct? Is it a $u$-substitution? I need help with equation $(4)$ in the following. I'm interested why it's mathematically correct to integrate both sides with different limits. Are there some extra steps which aren't explicit stated?
Here the power of a wave is derived, starting with:
$$
dK= \frac{1}{2} \mu v_y^2 \, dx \tag 1
$$
where $dm = \mu \, dx$.
"Each mass element oif the string oscillates with a velocity:"
$$
v_y=\frac{\partial y(x,t)}{\partial t}= A\omega \cos (kx-\omega t) \tag 2
$$
So
$$
dK= \frac{1}{2} A^2 \omega^2 \mu \cos^2(kx-\omega t) \, dx \tag 3
$$
"This kinetic energy can be integrated over the wavelength to find the energy associated with each wavelength of the wave", so at $t=0:$
\begin{align}
\int_0^{K_\lambda} dK
&= \frac{1}{2} A^2 \omega^2 \mu  \int_0^\lambda \cos^2(kx) \, dx \tag 4
\\
K_\lambda
&= \frac{1}{4} A^2 \omega^2 \mu  \lambda \tag 5
\end{align}
Update:
I assume it's a u-substitution which isn't explicit stated. How is it done? I have
$$
 \int_0^{K_\lambda} dK
 = \frac{1}{2} A^2 \omega^2 \mu  \int_0^\lambda \cos^2(kx) \, dx \tag 6
 $$
and because of $dK$ on the left side (I assume?) I want to write the LHS in terms of $K$. For simplicity I let $B=\frac{1}{2} A^2 \omega^2 \mu$.
Change of variable:
\begin{align}
K &= kx\\
\frac{1}{k} dK &= dx
\end{align}
New limits:
\begin{align} 
x=0: &\quad K=0 \\
x=\lambda: &\quad K=k\lambda
\end{align}
Now I can write $(6)$ as:
\begin{align}
\int_0^{K_\lambda} dK
= B \int_0^{k\lambda} \frac{1}{k}\cos^2(K) \, dK \tag 7
\end{align}
Is this the correct solution? The differential $dK$  appear now on both sides, but the limits are still different... how to proceed?
 A: Maybe a simple example demonstrating a similar thing might help. This is what I've came up with:
Lets have $y=x^2$. We want to find $\int_0^{x=3}x^2dx$.
Lets rewrite this in terms of $y$! $x^2$ is just $y$, and implicitly differentiating $y=x^2$, we have $dy=2xdx$, so $dx=dy/(2x)$.
Our integral is now:
$$\int_{y|_{x=0}}^{y|_{x=3}} y \frac{dy}{2x}=\frac{1}{2}\int_{y|_{x=0}}^{y|_{x=3}}\sqrt{y}dy=\frac{1}{3}y^{\frac{3}{2}}|^{9}_0=27$$
Notice that we changed limits: instead of $x=0$ and $x=3$ as lower and upper limits, we use the value $y$ for which the corresponding $x$ is $0$, and an upper limit $y$ where the corresponding $x$ is $3$ (ie the upper in the integral with respect to the variable $x$).
Denote these two numbers as $y|_{x=0}$ and $y|_{x=3}$.
Whereas $$\int_0^{x=3}x^2dx$$ is also 27, so we got the same result by integrating different funcitons, but the background meaning (ie when we are integrating with respect to $y$, what we are really doing is calling $x^2$ a different name than $x^2$), so we get the same result, even though our limits differ ($0$ and $3$ in the integration with respect to $x$ case, $0$ and $9$ in the integration with respect to $y$ case).

Sometimes it is not that easy to come up with two such integrals, but physical reasons can mean that we know the integral using one variable, and we also know that this should be equal to the integral with respect to another variable. In this case, the limits should correspond to the same physical phenomena. Ie in a $10$ hour journey from $A$ to $B$, where in every hour I progress $5 km$, in total I make $\int_0^{10}5 dh=50 km$, whereas if I look at a 1$:100 000$ scale map (where the distance between $A$ and $B$ is $50cm=0.5m$), the length of my journey from $A$ to $B$ is $\int_0^{0.5} 100 000 dl = 5 km$. Completely different limits, completely different integration variables, but the calculation gives the same answer.
A: Maybe try the following interpretation.
$$
dK= \frac{1}{2} A^2 \omega^2 \mu \cos^2(kx-\omega t) \, dx
$$
Physically, $dK$ is the energy associated with a bit of the wave (or rope, or whatever carries the wave): this bit has length $dx$. $dK$ has units energy, the $\frac{1}{2} A^2 \omega^2 \mu \cos^2(kx-\omega t)$ bit has units energy per (unit) length, and together with the $dx$ term, the bit $\frac{1}{2} A^2 \omega^2 \mu \cos^2(kx-\omega t) \, dx$ has energy.
If you want to calculate how much energy is stored in the wave, just integrate up all the bits contributing:
$$\int_{0}^{\lambda} \frac{1}{2} A^2 \omega^2 \mu \cos^2(kx-\omega t) \, dx$$
where the limits are set because: lets measure $x$ from where a wavelength starts, so the lower limit is 0. The higher limit is where the wavelength ends, so its $\lambda$.
Note that $dx$ and the limits both have the same dimensions (length). Also worth noting that $\int_0^{\lambda} dK$ does not makesense, since the uppper limit $\lambda$ has dimensions length, and $dK$ has dimensions energy. (So, how would you evaluate that then? the integral would evaluate to $K|_0^{\lambda}=\lambda$, so we added up a lot of energy bits (ie $dK$ bits) and the result is length (ie $\lambda$): something must be wrong.)
The $LHS$ of the result, ie $K_{\lambda}$ is the energy per wavelength. Strictly speaking, we don't need an integral to go from $dK$ to $K_{\lambda}$: the right hand side (ie integrating the energy bits associated with each $dx$ bit) by definition gives us the energy per wavelength, ie $K_{\lambda}$. So I think the $\int_0^{K_{\lambda}}dK$ integral is a bit overkill. Nevertheless, if we still want to understand it, we can think about it as: $dK$ is a bit of energy associated with the wave. $\int_0^{K_{\lambda}}dK=\sum_i \text{all energy bits}$, where the index $i$ means that we are adding up all the energy bits until we get to the total energy stored in each wavelength. The upper limit $K_{\lambda}$ is the expression of the same idea: we are adding up all the energy bits, until we get to $K_{\lambda}$, ie the energy for each wavelength.
$\int_0^{K_{\lambda}}dK$  is just a fancy way of saying $K_{\lambda}$. We call the RHS $K_{\lambda}$, and we write it as $\int_0^{K_{\lambda}}dK$, to have an integral on both sides.
