So I wanted to derive the total energy for an elliptical orbit, $E = -GmM/2a,$ and while I was doing it, I ran into this hurdle. So at the closest point to the focus, the orbiting object is at a distance of $a(1-e)$ from the focus, where a is the semi-major axis and e is the eccentricity. So if we were to take the centripetal force at this point we should get $$\frac{mv^2}{r} = \frac{GmM}{r^2}$$ and $r = a(1-e)$ so then we would get $$\frac{1}{2}mv^2 = \frac{GmM}{2a(1-e)}$$ which is the kinetic energy. If we were to add this to the potential energy $$U = -\frac{GmM}{a(1-e)},$$ we get the total energy as $$E = -\frac{GmM}{2a(1-e)}.$$ Isn't this wrong because the total energy of an ellipse is $E = -GmM/2a$? Why did I end up with a total energy not equal to that?
I asked my teacher about this and she said that we can only use mv^2/r for circular orbit but at the closest point in the ellipse, isnt the force perpendicular to the velocity so there shouldn't be any tangential acceleration, and therefore we can use the centripetal force equation?