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: 
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.
We can use the concept of **Orbital Velocity**, it is a concept of satellites revolving around planets. Here, in your case, we can use it for planet to sun revolutions.
[Also check this out for a better visualization](https://planetfacts.org/orbital-speed-of-planets-in-order/)
**ORBITAL VELOCITY:**
orbital velocity, velocity sufficient to cause a natural or artificial satellite to remain in orbit. The inertia of the moving body tends to make it move on in a straight line, while gravitational force tends to pull it down. The orbital path, elliptical or circular, thus represents a balance between gravity and inertia.

$$\text{orbital velocity} = \frac{2\pi R}{T} \text{ (if considered as circle)}$$

As per your convention let us take it as an ellipse and the formula goes like

$$\text{orbital velocity} = \frac{\pi (a + b)}{T} \text{ (FOR ELLIPSE)}$$

These formulas give approx values, to get the perfect answers, you can approach like this,
The area under the distance-time graph gives "non-uniform velocity". As you consider the speed is not constant

So now you can integrate the Ellipse formed in the distance-time graph,

**DERIVATION:**
Let the ellipse be $\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$.

$$\Rightarrow
 y=b\sqrt{1-\frac{x^2}{a^2}}
 =\frac{b}{a}\sqrt{a^2-x^2}.$$

By symmetry, it is clear that the area of the ellipse having its center at the origin is equally distributed among the four quadrants.

$$\Rightarrow
A=4\int\_0^a y\ dx
 =4\int\_0^a \frac{b}{a} \sqrt{a^2-x^2}\ dx
 =\frac{4b}{a}\int\_0^a \sqrt{a^2-x^2}\ dx.$$

Let $x=a\sin\theta \Rightarrow dx=a\cos\theta\ d\theta$.

Then, when $x=0,\theta=0$ and when $x=a,\theta=\pi/2$.

$$\Rightarrow
A=\frac{4b}{a} \int\_0^{\pi/2} \sqrt{a^2-a^2\sin^2\theta}\ a\cos\theta\ d\theta
 =4ab \int\_0^{\pi/2} \cos^2\theta\ d\theta \\
 =4ab \int\_0^{\pi/2} \frac{1+\cos 2\theta}{2}d\theta
 =2ab \left[\theta+\frac{\sin 2\theta}{2}\right]\_0^{\pi/2}
 =2ab(\pi/2)$$

$$\Rightarrow A=\pi ab$$
You can use the middle product terms as your formula.

**EXPERIMENTAL VALUES:**
Mercury 47.9 km/s
Venus 35.0 km/s
Earth 29.8 km/s
Mars 24.1 km/s
THANK YOU...