Grafana math function

Anyone here knows what the math function really does to the input variables?
I am trying to display the incremental cost of energy for a system I am monitoring over time. However, that is is not working as whenever I update, the values reduce drastically from the previous indication. Is there anyone who has experienced such a problem? And why is it that if I collect values over an hour, then I query the database to give the total cost for an hour and for three hours, those are values are different. How doe that algorithm work?

I think you need to give an example of exactly what query you are running and what you see.