# Orbital equations given position, velocity, mass, and gravitational constant - where do I make an error?

Hello and thanks for helping. I am exploring orbital equations given position, velocity, mass, and gravitational constant ($$r, v, G, M$$). There likely are answers somewhere here that explain these equations, but I have implemented them in Desmos. I would appreciate if someone took a look at my equations and told me where I am wrong. The reason why I think I am wrong is because the path of the orbit does not intersect with the initial position (which, of course, should lie on the orbital path).

Here are the equations:

$$h = r \times v$$ $$E=0.5\cdot|v|^2-\frac{GM}{|r|}$$ $$a=-\frac{GM}{2E}$$ $$e=\sqrt{1+ \frac{2Eh^2}{G^2M^2} }$$ $$b=a\cdot\sqrt{1-e^2}$$

where h is angular momentum, E is specific mechanical energy, a is the semi-major axis, e is eccentricity, and b is the semi-minor axis. I then drew the ellipse with the following equation:

$$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$$

My Desmos implementation can be found here: https://www.desmos.com/calculator/kcc3afkuj0

• Thank you PM 2Ring. The mass of the rocket is neglible, and is disregarded. Thus the ellipse is centered on the large mass around which the rocket orbits. I used this page for the equation on specific energy: en.wikipedia.org/wiki/…. Jan 24 at 12:52

I then drew the ellipse with the following equation: $$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$$
This is your error. That's the equation for an ellipse with the center at the origin. You need the origin to be at a focus of the ellipse. The distance $$c$$ between the center and one of the foci is given by $$c = \sqrt{a^2 - b^2} = ae$$. Offset the ellipse by this amount (in this case, to the right) and all will be fine.