How to calculate a planet's tangential velocity moving in an elliptic orbit? [duplicate]

Consider a planet of mass $m$ moving around the Sun of mass $M$ in a circular orbit of radius $r$. By equating the centripetal force to $\frac{mv^2}{r}$ to gravitational attraction $\frac{GMm}{r^2}$, one finds $v=\sqrt{\frac{GM}{r}}$ where $v$ is the planet's tangential velocity.

How does one calculate the tangential velocity if the planet's actual orbit (which is elliptical) is taken into account?

marked as duplicate by sammy gerbil, stafusa, Jon Custer, peterh, Kyle KanosDec 19 '17 at 18:48

$$v^2 = GM\left(\frac{2}{r} - \frac{1}{a}\right)$$
For a circular orbit $a=r$ and the equation simplifies to the usual one for circular motion:
$$v^2 = \frac{GM}{r}$$