Energy gain after collision.

Found this bug in JBox2d, reported to toucansam99 and was told the same bug exists in Box2d after he checked it.

The following is the bug report from the JBox2d google code.

What steps will reproduce the problem?

Run the varying restitution demo using the source and testbed from:

svn http://jbox2d.googlecode.com/svn/tags/jbox2d-2.1.2.0/

Tried different settings including 10, 20, 50, 100 iterations for position and velocity. all tried at 60 Hz, 100 Hz and 150 Hz.

What is the expected output? What do you see instead?

Expect the circle with restitution 1.0f to bounce back to its original height.
See the circle bouncing higher and gaining energy over time.

What version of the product are you using? On what operating system?

2.1.2, using Windows7, ran in eclipse. with Java 6.

Please provide any additional information below.

Also tried the JAR, got the same result.
In addition, the problem does not seem to exist in earlier versions, such as 2.0 in this demo:

http://www.jbox2d.org/v2demos/index.html

I'm using a fairly old version from early 2010, and did not see this problem either.

Tried to converting all the floats in the Jbox2d engine to doubles, the problem still exists. This rules out the bug caused by floating point rounding.
There is a small energy variation due to position correction (overlap resolution).
Is there a way to tune down this? The energy gain is quite obvious, gains about 10% after just 20 bounces.
Yes, use a smaller time step.

Original thread: https://box2d.org/forum/viewtopic.php?t=7462