Aj83 said:
So does that mean that ideal gas equation which is based on boyle's law is not applicable unless the expansion or compression is isothermal?
It is still applicable. Indeed, it is the basis for the explanation I gave you.
[STRIKE]Boyle's law is simply ##PV \propto T##, which the ideal gas law expands by setting the proportionality constant,[/STRIKE]
Boyle's law is simply ##PV = \text{const.}## (for a given amount of gas at constant ##T##), so it is "included" in the ideal gas law:
$$
PV = N k_B T = n R T
$$
If you compress a gas, the work done on the gas is
$$
W = -\int_{V_i}^{V_f} P dV
$$
If ##P## is constant, you then have ##W = -P \Delta V##, otherwise you need to rewrite ##P## as a function of ##V## (for instance, by using the ideal gas law). At the same time, you have the change in energy of the gas as
$$
dU = Q + W
$$
where ##Q## is the heat entering the gas. If ##Q=0## (adiabatic process), then ##dU = W##, which is greater than 0 if you are compressing the gas. Considering that the change of energy for an ideal gas is also given by
$$
dU = N \frac{f}{2} k_B dT
$$
where ##f## is the number of degrees of freedom of the gas (##f=3## for a monatomic gas), you see that ##T## must increase if ##U## increases. The only way around that is to have ##Q=-W##: you have to take out heat from the gas at the rate you are putting it in by compressing.