Why does the eccentricity vector equation always equal -1?

This is the eccentricity vector equation, $$e=\frac{1}{\mu}[(v^2-{\mu \over r})r-(r \cdot v)v]$$ $$e=|e|$$ Now this equation is written differently from many different sources but they essentially mean the same thing. I tried this equation out and no matter what values I gave to the variables, the answer is always -1 (or 1 in absolute terms). I understand that the eccentricity of a parabola is 1 but this equation is for ellipses as well. So why is the answer always -1? Am I missing something? Thanks in advance.

The expression on the right is meant to give the eccentricity vector but the vector notation has been lost.

Here it is in this answer:

$$e = {v^2 r \over {\mu}} - {(r \cdot v ) v \over{\mu}} - {r\over{\left|r\right|}}$$

and the vector nature is not clear either. We should write it as

$$\mathbf{e} = {v^2 \mathbf{r} \over {\mu}} - {(\mathbf{r} \cdot \mathbf{v} ) \mathbf{v} \over{\mu}} - {\mathbf{r}\over{r}}$$

where the bold face represents vectors and $$v=|\mathbf{v}|$$ and $$r=|\mathbf{r}|$$, or as

$$\mathbf{e} = {|\mathbf{v}|^2 \mathbf{r} \over {\mu}} - {(\mathbf{r} \cdot \mathbf{v} ) \mathbf{v} \over{\mu}} - {\mathbf{r}\over{\left|\mathbf{r}\right|}}$$

In the expression $$(\mathbf{r} \cdot \mathbf{v} ) \mathbf{v}$$ the term $$\mathbf{r} \cdot \mathbf{v}$$ is a vector dot product, and return a scalar, which then multiplies the vector $$\mathbf{v}$$.

Here's a quick calculation to confirm it. I chose $$\mu=1$$ and $$a=1$$ so that the orbital period is $$2 \pi$$. You can see that the eccentricity vector x component is +0.8 and constant, and the y component is 0.0 That confirms that the eccentricity vector always points towards the direction of periapsis and it's magnitude is always equal to the scalar eccentricity, which in this case is 0.8

Python script:

def deriv(X, t):
x, v = X.reshape(2, -1)
acc = -x * ((x**2).sum())**-1.5
return np.hstack((v, acc))

import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint as ODEint

halfpi, pi, twopi = [f*np.pi for f in (0.5, 1, 2)]
e     = 0.8
peri  = 1. - e
apo   = 1. + e

vperi = np.sqrt(2./peri - 1.)  # vis-viva equation

X0    = np.array([peri, 0] + [0, vperi])
times = np.linspace(0, twopi, 201)

answer, info = ODEint(deriv, X0, times, full_output=True)

r, v = answer.T.reshape(2, 2, -1)
vsq  = (v**2).sum(axis=0)
rabs = np.sqrt((r**2).sum(axis=0))

evec = vsq*r - (r*v).sum(axis=0) * v - r/rabs

if True:
x, y = r

plt.figure()

plt.subplot(2, 1, 1)
plt.plot(x, y)
plt.plot([0], [0], 'oy', markersize=16) # the Sun
plt.xlim(-2, 0.5)
plt.ylim(-1.25, 1.25)

plt.subplot(4, 1, 3)
plt.plot(times/twopi, x)
plt.plot(times/twopi, y)
plt.title('x, y', fontsize=16)

plt.subplot(4, 1, 4)
x, y = evec
plt.plot(times/twopi, x)
plt.plot(times/twopi, y)
plt.title('evec_x, evec_y', fontsize=16)

plt.show()

• Comments are not for extended discussion; this conversation has been moved to chat. Jul 16, 2019 at 12:40
• @uhoh Just to clarify, the vector dot product will always be 0 in a circular orbit right? Because the angle between where my velocity is taking me and the radius is always 90 degrees. And in a elliptical orbit, the vector dot product is 0 at apoapsis and periapsis. Jul 16, 2019 at 16:16
• @StarMan yep that's true. For a circular orbit, or for any periapsis and the apoapsis of an ellipse, $\mathbf{v}\cdot \mathbf{r}$ will be zero. As a quick check: for a circle with $e=0$, if the 2nd term on the right is zero, you have $0 = v^2 r / mu - 1$ which gives $v^2 = mu / r$ which is the vis-viva equation for a circular orbit where $r=a$.
– uhoh
Jul 16, 2019 at 22:48