Research has shown that to properly understand people's economic behavior, it is important to take into account their emotional attitudes towards each other. Behavioral economics shows that different attitudes results in different economy-related behavior. A natural question is: where do these emotional attitudes come from? We show that, in principle, such emotions can be explained by people's objective functions. Specifically, we show it on the example of a person whose main objective is to increase his/her country's GDP: in this case, the corresponding optimization problem leads exactly to natural emotions towards people who contribute a lot or a little towards this objective.