Kinetics energy with different reference frame (a fighter plane shoots a bullet)? Suppose a plane flies at 1km/s and shoots a 2kg projectile at 1km/s, so to the Earth the projectile flies at 2km/s with 2*2*2/2 = 4MJ.
The same gun, when fixed on Earth, shoots the same 2kg projectile at 1km/s, achieving 2*1*1/2 = 1MJ
The same projectile, before being fired from the plane, also has 1MJ. So the gun on Earth does 1MJ of work, but on the plane, does 3MJ of work. I know that energy depends on reference frame, but still can't understand this. Assume that the energy comes from burning propellant or electrical energy (railgun): How can the gun on the plane do more work than the same gun fixed on Earth?
Where does the added energy come from?
 A: The problem here is that you've neglected the effect of firing the bullet on the plane itself.  It turns out we can account for the bullet's extra energy by examining the energy lost by the plane.  To resolve this apparent contradiction, we need to examine the problem in terms of conservation of momentum:
In the second case, where the bullet is fired from a gun on the plane, conservation of momentum gives us
$$m_b v_0 + m_p v_0 = m_b (2 v_0) + m_p v_1$$
$$v_1 = \frac{m_p - m_b}{m_p} v_0$$
You can see that the velocity of the plane is slightly reduced after the bullet is fired.  This must mean that the plane has lost some kinetic energy, too:
$$\Delta KE_p = KE_{p, 1} - KE_{p, 0}$$
$$\Delta KE_p = \frac 1 2 m_p v_1^2 - \frac 1 2 m_p v_0^2$$
$$\Delta KE_p = \frac 1 2 m_p \left(\frac{m_p - m_b}{m_p} v_0\right)^2 - \frac 1 2 m_p v_0^2$$
$$\Delta KE_p = \frac 1 2 m_p \left(\frac{m_p - m_b}{m_p} v_0\right)^2 - \frac 1 2 m_p v_0^2$$
$$\Delta KE_p = \frac 1 2 \frac{(m_p - m_b)^2}{m_p} v_0^2 - \frac 1 2 m_p v_0^2$$
$$\Delta KE_p = \frac 1 2 (-2m_p + m_b)\frac{m_b}{m_p} v_0^2$$
Here we can simplify this a bit by assuming that $2 m_p >> m_b$:
$$\Delta KE_p = -2 \frac 1 2 m_b v_0^2$$
$$\Delta KE_p = -2 KE_{b, 0}$$
That's the solution there - the amount of energy that the plane loses is equal to twice as much as the bullet started with.  So in your situation, the bullet started out with 1 MJ of energy, and the plane loses 2 MJ of energy, which accounts for the anomalous extra 2 MJ of energy that the bullet gains.
Note:  If you are concerned about that last approximation we made, consider that we're just making up for the fact that we already cheated when we said the bullet doubled its speed when we fired it from the plane - that can't be true if we are to conserve momentum.  This approximation is just making up for that previous unacknowledged approximation.
A: The added energy comes from the plane. As the plane accelerates, the bullet's kinetic energy increases, with respect to the inertial reference frame of the Earth. When the gun is fired, the bullet receives 1MJ of additional kinetic energy. Thus from the point of view of the plane, it only has 1MJ, but from the point of view of a stationary observer on Earth it has 3MJ.
