Why is the internal energy of a real gas a function of pressure and temperature only? While studying thermodynamics, I read that the internal energy of an ideal gas is a function of temperature only. On searching the internet, i found an article which stated that the internal energy of a real gas is a function of temperature and pressure only. I could not find a proper reason for this.
So my question is: why is the internal energy of an ideal gas a function of temperature only and that of a real gas a function of temperature and pressure only? 
Is this property of ideal gases and real gases derivable through any equation?
 A: For any thermodynamic equilibrium state of a single phase fluid of constant composition, the pressure, temperature, and specific volume are inter-related by the Equation of State of the fluid.  So, once any two of these are specified, the third is determined.  That means that the internal energy per mole (which is a function of state) is likewise determined by any two of these.
From a combination of the first and second laws of thermodynamics, we find that we an express the change in internal energy per mole between any two closely neighboring thermodynamic equilibrium states of a single phase fluid of constant composition (including non-ideal gases) by the equation:
$$dU=C_vdT-\left[P-T\left(\frac{\partial P}{\partial T}\right)_V\right]dV$$where V is the molar volume.  So, in general, the internal energy is a function of two intensive properties, in this case T and V.  But, in the case of an ideal gas, the equation of state is such that the second term in this equation is identically equal to zero.  (Substitute P=RT/V to confirm this).  So the ideal gas is a special case in which the molar internal energy is a function only of temperature.
A: Ideal gas
In thermodynamics, the fact that the energy of an ideal gas depends only on temperature is an experimental observation from the free expansion of a diluted gas (which is approximately ideal) 1. In statistical mechanics, it can be proven 2. 
Ultimately, the reason is that the atoms of an ideal gas are non-interacting point particles. They only have kinetic energy, but don't "see" each other at all. The average kinetic energy is nothing else than the temperature of the ideal gas.
Therefore, no matter how much you decrease the volume of the box: since they don't interact, the energy will remain the same if the temperature (=average kinetic energy) is unchanged.
For more realistic models, you have an interaction potential $U$ which is usually assumed to be the sum of pairwise components that depend on the distance between particle $i$ and particle $j$,
$$U(\vec r_i, \dots, \vec r_N) = \sum_{i=1,j<i}^N u(|\vec r_i - \vec r_j|)$$
When the volume is reduced the average interparticle distance is reduced, and therefore, because of the presence of $U$, the energy will change even if $T$ is kept constant.
Real gas
In general the energy $E$ of a real gas will be a function of all the relevant thermodynamic parameters, which are $P,V$ and $T$:
$$E_{rg} = E(P,V,T)\tag{1}\label{1}$$
However, there is always an equation of state connecting $P,V$ and $T$:
$$f(P,V,T)=0\tag{2}\label{2}$$
An example is the van der Waals equation of state:
$$\left( P + \frac{a n^2}{V^2}\right) (V-nb) = nRT$$
You can solve \ref{2} for $V$, obtaining
$$V = g(P,T) \tag{3}\label{3}$$
Substituting \ref{3} in \ref{1}, you obtain
$$E(P,V,T)=E(P,g(P,T),T)= \tilde E(P,T)$$
So that $E$ only depends on two thermodynamic variables.

1 The experiment was first performed by Joule and it works like this: you let a diluted gas, initially confined in a side of a container, freely expand in the whole container. Assuming that the container is adiabatic (no heat exchange), the work done $W$ and the heat exchanged $Q$ are both zero. Therefore, from the first law, $\Delta E=0$: the energy is unchanged. The volume has changed, and also the pressure. Experimentally, it is observed that the temperature has not changed. You conclude therefore that $E$ must be a function of $T$ only. You can find this argument in E. Fermi, Thermodynamics, Chapter 2.
2 See for example K. Huang, Statistical Mechanics, Chapter 6.5
A: First off, let's start with a fundamental assumption: the internal energy of an gas consists of only its kinetic energy. This is the basic assumption of kinetic gas theory, and is a reasonable assumption for real gases. The temperature of any system is simply the average kinetic energy. Therefore, the kinetic energy of any one particle in a system is proportional to the temperature.
K ∝ T
This is the energy of a single particle. The energy of the entire system is simply the average kinetic energy times the number of particles, so:
K ∝ nT
So clearly, kinetic energy is a function of the number of moles of gas and their temperature. But by the ideal gas law, PV = nRT. This means this statement can be rewritten as:
K ∝ PV
As you can see, it is true that both a higher pressure and a higher temperature indicate a higher internal energy. However, they are functions of each other, not two components of the same equation. 
In my opinion, stating that kinetic energy is a function of temperature and the number of particles better expresses the essential concepts of the derivation. It might rather be said the pressure and volume are alternate ways of expressing those quantities.
A: In real gas Pressure and volume change when temperature changes so work and heat exchange with surroundings then internal energy changes during this process 
A: If we describe in short then you'll find that kinetics theory of gases is stated that 
Total energy of gas = kinetic energy
Because there is no attraction between the gas molecules i.e. Potential energy will be zero
And I think you know very well that KTG is applicable only for ideal gases while real gas molecules have attraction between gas molecules i.e. Potential energy is there
Total energy = KE + PE, for real gas...
I hope u have understood... 
