Are elliptical orbits really elliptical? I have wondered for a long time how elliptical orbits can work. It seems awkward for a freely-moving object to come very close to a source of gravity and then return to the exact point where it started. I started to wonder even more after playing with the Box2D physics engine recently and finding that when I caused one object to be pulled toward another one, it didn't trace out a full ellipse. Instead, when the orbiting body approached the stationary body, it swerved in a different direction and started tracing out a new ellipse over there. The resulting orbit resembled the Treyarch logo, which I now suspect was inspired by physics demos in the company's early history.
So what I want to know is whether real-life "elliptical" orbits are really doing this. I suppose that if you apply relativity, it could still be called an ellipse.
For the record, I know that Box2D is only a rough approximation of physics.
 A: "The resulting orbit resembled the Treyarch logo, which I now suspect was inspired by physics demos in the company's early history."
Yes, indeed they are elliptical, but there are also extremely tiny deviations from this general case (which are extremely difficult to observe, in general, even after some time). It's important to note that computers have a fixed accuracy (i.e. limited by the mantissa and exponent) used for computation, and, frequently, when dealing with precise computations, even these small errors will amplify to large results, as is commonly studied in computational sciences.
So, overall, the orbits are indeed an ellipse--up to very, very, very tiny fluctuations from this, relative to orbit---, but what you are observing in your physics simulation is a rounding error due to the maximum precision for the type of data structure used to hold the position and other variables of importance in the simulation.
A: Elliptical orbits are only truly elliptical if the mass they orbit around is truly a point pass, or perfectly symmetrical.
True point masses exist only in models.  Therefore, perfectly ellptical orbits also exist only in models.  If a spacecraft orbits Earth, for example, the local gravity field changes continously.  The Earth is not a sphere, the Earth is not a spheroid, but the geoid has a rather complicated shape.  As a result, there are ever so slight variations in the orbit.
This is not just some theoretical consideration.  In fact, the GOCE spacecrafts use this exact principle for the purposes of Earth observation!  For example, by measuring slight changes in gravity, they can measure ocean currents and moving ice caps.  The differences are very small, and you're going to need very high precision to simulate it, but they're real and cannot always be neglected in the real world.
A: As Guillermo Angeris correctly pointed out, this is essentially a numerical roundoff problem, not a physical situation.
As a physical example, there are sungrazing comets that get very close to to Sun, yet they maintain their original elliptical (or hyperbolic) orbit, without the orbit precessing a full third of a circle as you seem to be seeing.
Computationally, there are a few interesting issues. As Kyle pointed out in a comment, many integration schemes are indeed unreliable in that roundoff error (which is always present in floating-point computations) can accumulate in a runaway feedback. Indeed I often advise using leapfrog methods over Euler (used by Box2D) or even Runge-Kutta (see for instance What is the correct way of integrating in astronomy simulations? over at the Computational Science Stackexchange).
However, I suspect your problem is even simpler, in the sense that even an unstable numerical scheme should work for one or two orbits. Given that everything is going wrong in just one pass, it seems that your timesteps are simply too large. A brief glimpse at the Box2D documentation suggests you don't change the timestep mid-simulation, so I presume you are just using a good value to simulate the whole process in reasonable time. The problem is that when gravitating bodies get close in their orbit, they move quickly, sometimes very quickly. The way the code works is it updates each object's position and velocity at each timestep, where the new velocity is determined by the force. As far as I can tell, this is done in line 206 of b2Island.cpp (v. 2.2.1):
v += h * (b->m_gravityScale * gravity + b->m_invMass * b->m_force);

Without looking at your code, I am guessing you simply calculate the gravitational force the body should feel at that moment, and have the simulation chug away. The problem is this moves the orbiting object in a straight line for the next timestep, and that straight line takes it too far away from the gravitating mass for that mass to properly curve its orbit into a closed ellipse. The quick schematic below shows the blue object moving to the tip of the red arrow, rather than staying on the path.

Physically, your timestep should be smaller than any timescale you encounter in the problem. Now for an orbit conserving angular momentum, the product of the orbiting body's mass, tangential velocity $v$, and distance from the other object $r$ should be constant: $v \sim 1/r$. At the same time, the acceleration $a$ it feels is given by Newton's law of gravity: $a \sim 1/r^2$. So one natural timescale in this problem is
$$ t \sim \frac{v}{a} \sim \frac{1/r}{1/r^2} \sim r $$
(omitting dimensional constants), which goes to show that if your timescale is just barely small enough and then you tweak the orbit so as to half the periapsis distance (distance of closest approach), then you would expect to need timesteps at least twice as small in order to preserve the integrity of the simulation.
A: Elliptical planetary orbits are apparent paths of planets about their central body, which is considered static in space.  By simple mechanics, it is physically impossible for a free macro body to orbit around a moving central body, in any type of geometrically closed path. Sun (central body of solar system) is a moving body, planets (and other macro bodies) in solar system are free macro bodies and elliptical planetary orbits are geometrically closed paths around sun. Therefore, contemporary elliptical planetary orbits are neither real nor around the central body. They are assumed paths with respect to central body as a static point in space. These structures help us to predict annually (cyclically) recurring events with respect to relative motions of central body and planets. These apparent structures helped us to formulate various physical laws used in physics, through mathematical analyses.
Equipment/programs to replicate elliptical orbits around a central body do not approximate real paths of cosmic bodies. These systems are based on many assumptions, which are used in contemporary planetary laws.
Considering apparent elliptical paths of planets as their real paths in analyses related to real motions of planets or central body would confuse the issue and invite many other illogical assumptions. If interested in explanations on real planetary orbital motions in space please refer to http://vixra.org/abs/1311.0018 and http://vixra.org/abs/1008.0010. (These articles are neither edited nor peer reviewed).
Nainan
