question on PDE with chain rule We have PDE for $v(t,x)$:
$$\partial_tv+\frac{1}{2}\sigma^2x^2\partial_{xx}v=0$$
Then it says for $\tilde{v}$, with $x=S_t$ and $\tilde{x}=e^{rt}x$:

I understand the steps in between, but how do they then finally get to this PDE?
Apparently one can use the middle equality to recalculate the partial derivatives in the first PDE, but I didnt get to the resulting PDE then.
 A: Let me answer a different more general question 
$$
v(t,S) = \mathrm{e}^{-rt}U\left(t,g(x,t)\right).\tag{1}
$$
$$
v_t = -r\mathrm{e}^{-rt}U\left(t,g(x,t)\right) + \mathrm{e}^{-rt}U_t.\tag{2}
$$
now you must be happy with Eq.(2)?
so lets compute $U_t$,
$$
U_t = \dfrac{\partial U}{\partial t} + \dfrac{\partial U}{\partial g}\dfrac{\partial g(x,t)}{\partial t}
$$
so putting it all together we have
$$
v_t = \mathrm{e}^{-rt}\left[\dfrac{\partial U}{\partial t} + \dfrac{\partial g(x,t)}{\partial t}\dfrac{\partial U}{\partial g}\right]-r\mathrm{e}^{-rt}U\left(t,g(x,t)\right)
$$
To go further.
$$
U = \tilde{v},\\
g(x,t) = \tilde{x} = x\mathrm{e}^{rt}
$$
therfore 
$$
v_t = \mathrm{e}^{-rt}\left[\dfrac{\partial \tilde{v}}{\partial t} + rx\mathrm{e}^{rt}\dfrac{\partial \tilde{v}}{\partial \tilde{x}}\right]-r\mathrm{e}^{-rt}\tilde{v}
$$
now lets look at 
$$
v_x = \mathrm{e}^{-rt}\dfrac{\partial \tilde{v}}{\partial \tilde{x}}\dfrac{\partial \tilde{x}}{\partial x} = \mathrm{e}^{-rt}\dfrac{\partial \tilde{v}}{\partial \tilde{x}}\left(\mathrm{e}^{rt}\right) = \dfrac{\partial \tilde{v}}{\partial \tilde{x}},\\
v_{xx} = \frac{\partial}{\partial x}\dfrac{\partial \tilde{v}}{\partial \tilde{x}} = \mathrm{e}^{rt}\dfrac{\partial^2 \tilde{v}}{\partial \tilde{x}^2}
$$
remembering $x = \tilde{x}\mathrm{e}^{-rt}$
we find
$$
v_t + \frac{1}{2}\sigma^2v_{xx}
$$
is equivalent to
$$
\mathrm{e}^{-rt}\left[\dfrac{\partial \tilde{v}}{\partial t} + rx\mathrm{e}^{rt}\dfrac{\partial \tilde{v}}{\partial \tilde{x}}-r\tilde{v}\right] + \frac{1}{2}\sigma^2 \tilde{x}^2\mathrm{e}^{-2rt}\left[\mathrm{e}^{rt}\dfrac{\partial^2 \tilde{v}}{\partial \tilde{x}^2}\right]
$$
or finally
$$
\mathrm{e}^{-rt}\left[\dfrac{\partial \tilde{v}}{\partial t} + r\tilde{x}\dfrac{\partial \tilde{v}}{\partial \tilde{x}}-r\tilde{v} + \frac{1}{2}\sigma^2 \tilde{x}^2\dfrac{\partial^2 \tilde{v}}{\partial \tilde{x}^2}\right] = 0
$$
now all you have to do is a trivial re-arrangement.
A: In order to derive the Black-Scholes equation, you can do it in a more intuitive way (with economics). Also, this needs understanding of Brownian Motions and stochastic differential equations (SDEs), Îto's Lemma, and some basical assumptions that I will not list here (they're already available in Wikipedia and other references).
Let's see it in two steps:

Let's assume the asset $x$ evolves according to
$$dx=\mu x\,dt+\sigma x\,dW_t$$
Let $\Pi$ denote the valie of a portfolio of one long option position and a short position in a quantity $\Delta$ of the underlying:
$$\Pi=V(x,t)-\Delta x$$
The value of the portfolio changes partly because the change in the option value, and partly because of the change in the underlying: 
$$d\Pi=dV-\Delta dx$$
From Îto (because $W_t$ is a Brownian Motion), 
$$dV=V_tdt+V_xdx+\frac{1}{2}\sigma^2x^2V_{xx}dt$$
Then
$$d\Pi=V_tdt+V_xdx+\frac{1}{2}\sigma^2x^2V_{xx}dt-\Delta dx$$
Deterministic terms are those terms with $dt$. The random terms are those with $dx$, and are the risk in the portfolio.
Then, using Delta hedging ($\Delta=V_x$), to perfectly eliminate risk (dynamically), you have a portfolio whose value changes as
$$d\Pi=V_tdt+\frac{1}{2}\sigma^2x^2V_{xx}dt\qquad(1)$$
$(1)$ is a completely riskless situation.
This is the first part to derive the PDE of BS-PDE. Note that your fisrt PDE is wrong (you assume the porfolio value change is $0$).

If, from $(1)$, we have a completely risk-free change $d\Pi$ in the value $\Pi$, then it must be the same as the growth we would get if we put the equivalent amount of cash in a risk-free intereset-bearing account:
$$d\Pi=r\Pi dt=r\bigl(V-\Delta x\bigr)dt=r\bigl(V-V_xx\bigr)dt\qquad(2)$$
an example of the no arbitrage principle.

So, make $(1)=(2)$ and
$$\begin{array}{rcl}
d\Pi&=&d\Pi\\
V_tdt+\frac{1}{2}\sigma^2x^2V_{xx}dt&=&r\bigl(V-V_xx\bigr)dt\\
\end{array}$$
Finally,
$$V_t+\frac{1}{2}\sigma^2x^2V_{xx}+rxV_x-rV=0$$
Hope this helps understading the problem.
