Given the position $(p,q)$ and velocity $(v_p,v_q)$ of a satellite in perifocal coordinates $(\hat{p},\hat{q})$ where $\hat{p}$ is pointing toward periapsis, I can easily calculate the specific angular momentum $h$ with: \begin{equation} h = (p \times v_q) - (q \times v_p) \end{equation} And I can get the eccentricity $e$ with the orbit equation naturally: \begin{equation} e = \frac{\left(\frac{h^2}{μ r} - 1\right) }{\cos(\theta)} \end{equation} where $\mu$ is the graviational parameter of the body being orbited and the radius $r$ and true anomaly $\theta$ was calculated with: \begin{equation} r = \sqrt{p^2 + q^2}, \mathrm{and} \end{equation}
\begin{equation} \theta = \arccos\left(\frac{p}{r}\right). \end{equation} However, I am having trouble calculating the eccentricity directly using the speed $v$ instead of the specific angular momentum.
Using these equations: \begin{eqnarray} h^2 = \mu r (1 + e \cos(\theta)), \\ h = v_\text{perp} r, \\ v_\text{radi} = \frac{\mu}{h} e \sin(\theta), \\ v^2 = v_\text{perp}^2 + v_\text{radi}^2 \end{eqnarray} where $v_\text{perp}$ and $v_\text{radi}$ are the perpendicular and radial speed relative to the position vector from the orbited body, I derived an equation to solve for the eccentricity: \begin{equation} \theta = \frac{\mu}{r} e^2 + \left[\left(\frac{2\mu}{r} - v^2\right) \cos(\theta)\right] e + \left(\frac{\mu}{r} - v^2\right). \end{equation} This is just a quadratic and the solution looks like this: \begin{equation} e = \frac{- \left[\left(\frac{2\mu}{r} - v^2\right) \cos(\theta)\right] \pm \sqrt{\left[\left(\frac{2\mu}{r} - v^2\right) \cos(\theta)\right]^2 - \frac{4\mu}{r}\left(\frac{\mu}{r} - v^2\right)}}{\frac{2\mu}{r}} \end{equation}
This all looked OK to me, but when I tried to compare the first equation (for $h$) with this last equation (for $e$), I find inconsistent results. For example, consider a satellite with these parameters: \begin{eqnarray} (p,q) = (7000, 9000), \\ (v_p,v_q) = (-5, 7). \end{eqnarray} Using the first equation to find $h$ gives: \begin{equation} h = 94000 \end{equation} Now, here I try to calculate $h$ by first calculating $e$ using $v$, $r$ and $\theta$ (in these units, I'll say $\mu = 398600$): \begin{equation} v = \sqrt{v_p^2 + v_q^2} = 8.602, \end{equation} \begin{equation} r = \sqrt{p^2 + q^2} = 11401, \end{equation} \begin{equation} \theta = \arccos\left(\frac{p}{r}\right) = 0.90975. \end{equation} So we have (taking the positive solution to the quadratic equation above): \begin{equation} e = 1.0932, \end{equation} and working back through the orbit equation, I get $h$ again: \begin{equation} h = \sqrt{\mu r (1 + e \cos(\theta))} = 87149. \end{equation} But this is inconsistent with my previously calculated value for $h$ of 94000. I have checked my math several times and feel I must be making some fundamental error though I don't see it.
For reference, I'm trying to reconcile two examples (2.12 and 3.6) found in Curtis' book "Orbital Mechanics for Engineers," 3rd ed.