Question: What formula returns speed of a planet, e.g. Earth orbiting Sun, on its ellipse like trajectory orbiting Sun? Input variables have to be $a,b$ (ellipse) and some more, because the speed of the planet movement is not constant, as I have read.

Answer: 
You can calculate the speed $v$ of a planet at any time
using the so-called [vis-viva equation](https://en.wikipedia.org/wiki/Vis-viva_equation)

$$v=\sqrt{GM\left(\frac{2}{r}-\frac{1}{a}\right)}$$
where

* $G$ is Newton's gravitational constant,
* $M$ is the mass of the sun,
* $r$ is the planet's distance from the sun at this time,
* $a$ is the semi-major axis of the ellipse.

The linked article also describes how this equation can be derived
from the constant total energy of the planet
and the elliptic shape of its orbit.
According to Kepler's laws, a planet orbits the Sun in an ellipse, with the Sun at a focus of the ellipse. Of course, this is only an approximation, because it assumes that the Sun doesn't move, and it ignores the gravity of other bodies, but it's a good approximation.

An ellipse with semimajor axis $a$, semiminor axis $b$, with the major axis on the X axis and a focus at the origin has the polar equation

$$r = \frac{a(1 - e^2)}{1 + e\cos\theta}$$
where $r$ is the distance to the origin, $e$ is the eccentricity of the ellipse, and $\theta$ is the polar angle from the origin to the point on the ellipse.

Let $f$ be the distance of the focus from the centre of the ellipse, i.e., the distance between the foci is $2f$. Then $f = ae$. It can be shown that
$$a^2 = b^2 + f^2$$
So
$$e^2 = 1 - \left(\frac ba\right)^2$$

$\theta = 0°$ when the planet is on the X axis at its closest approach to the Sun (perihelion), when $r=a-f$, and $\theta = 180°$ when the planet is on the X axis at its furthest point from the Sun (aphelion), when $r=a+f$.

To determine the planet's velocity at any point on the orbit, we can use the [vis-viva equation](https://en.wikipedia.org/wiki/Vis-viva_equation):
$$v^2 = GM\left(\frac2r - \frac1a \right)$$
where $G$ is the universal gravitational constant, and $M$ is the total mass of the Sun & the planet. All planets are much lighter than the Sun, so it's common to ignore the planet's mass.

We can combine that equation with the ellipse equation to get the speed as a function of $\theta$.

$$v^2 = GM\left(\frac{1+2e\cos\theta+e^2}{a(1-e^2)}\right)$$

---

Unfortunately, it's very hard to measure $G$ precisely, so we only know it to around 5 significant figures. But we *can* measure $GM$ quite well, so we usually use that product, known as the [standard gravitational parameter](https://en.wikipedia.org/wiki/Standard_gravitational_parameter), when doing calculations like this.