Wave rate of energy confusion Consider we are exciting the edge $x=0$ of a string, so that $ y(0,t) = A\cos(ωt) $.
We know that the rate of energy is $$ \frac{1}{2}ρω^2Ac = \frac{1}{2}ω^2A\sqrt{Tρ}$$, where $ρ$ is the string density, $T$ the tension of the string and $c$ its traveling velocity.

If the density is variant, i.e. $ρ=ρ(x)$ and $ρ(x)$ is continuous, is it correct to say that for any point of the string
  $$ \frac{1}{2}ω^2A(x)\sqrt{Tρ(x)} = \frac{1}{2}ω^2A\sqrt{Tρ(0)} \implies A(x) = A\sqrt{\cfrac{ρ(0)}{ρ(x)}}$$
If so we have that $$y(x,t)=A(x)\cos(k(x)x-ωt) $$ where
  $$ k(x)=\dfrac{2π}{λ(x)}= \dfrac{2πc(x)}{ω}=
 \dfrac{2π}{ω} \sqrt{\dfrac{T}{ρ(x)}}$$
  and $y(x,t)$ should satisfy the differential equation
  $$ ρ(x)\cfrac{\partial^2y}{\partial t^2}=T\cfrac{\partial^2y}{\partial x^2}$$

Are the above correct?
Thank you in advance
 A: Intuitively, a variation of density implies that some scattering will occur. In particular some energy will then be flowing in the $-x$ direction, and none of your statement above will be rigorously valid. The obvious and extreme case is a very sharp discontinuity in density (something like a smoothed Heavyside step function, to maintain your hypothesis of continuity) yielding a forward transmitted wave with a modified velocity and a reflected wave.  
Now at the opposite, if the density function is varying very smoothly, I expect your approach with a solution of the type $A(x) \cos(k(x)x-\omega t)$ to be a fair approximation (I assume $k$ would also become a function of $x$ in this case). When writing the conservation of the power flow, the power flow passing by $x$ for an harmonic wave $A \cos (kx- \omega t)$ should be (unless I'm mistaken):
$$-T \frac{\partial y}{\partial x} \frac{\partial{y}}{\partial{t}} =Tk \omega A^{2} \sin^{2}(kx-\omega t) $$ 
Of course this power flow has to be properly evaluated when $A$ and $k$ become a function of $x$, but I guess you could retrieve the variation of $A(x)$ given the variation of $k(x)$ (or equivalently from a given $\rho(x)$). 
This type of situation with spatial variations of the wave velocity is usually handled with Green function expansions solutions in acoustics. The "Born approximation" may in particular be useful  to look at in the case of weak scattering (small fluctuations around a mean velocity).
I hope this helps.
