The Wolfram|Alpha Blog is now part of the Wolfram Blog. Join us there for the latest on Wolfram|Alpha and other Wolfram offerings »
Jason Martinez

Optimizing Home Energy Costs (Heating vs. Cooling)

July 21, 2014 —
Comments Off

As summer heats up, we instinctively reach for the air conditioning (AC) controls. This miracle of modern technology lets us create a cool breeze to banish the crushing heat. At the same time, AC brings soaring electric bills. How can we optimize our use of air conditioning, keeping cool while minimizing our costs?

Wolfram|Alpha provides several helpful formulas in this area, the first of which is a method for calculating the degree days for a location over a period of time. Degree days is a measure of how often the temperature was above (for cooling) or below (for heating) a given temperature or range of temperatures. It is used in a wide range of climate and energy cost-related areas, from agriculture to monitoring the heating and cooling costs of climate-controlled buildings.

In our case we want to know about the number of cooling degree days in June for Champaign with a base temperature of 72 °F:

Cooling degree days in June for Champaign with a base temperature of 72 degrees F

This turns out to be 128 days Fahrenheit degrees difference. As the “Base temperature dependence” shows, the magnitude of degree days increases the lower we place the temperature that triggers cooling. This picture becomes more complicated when we include heating as well. While there is little need for heating in Champaign in the summer, San Francisco has quite cool mornings, even in June. The degree days in June for San Francisco with cooling base temperature 72 °F and heating base temperature 65 °F shows that there is a higher contribution from heating than cooling:

Higher contribution from heating than cooling

So we can see the amount of air conditioning needed, either to heat or cool, can vary substantially depending on location and time of year.

Degree days as defined above is fairly inaccurate for determining how much heating or cooling we need depending on the circumstances. It works well for a continually occupied residence. But for an office or a home where no one is present during portions of the day, it overestimates the amount of heating and cooling required to maintain a comfortable temperature. Just as you might switch off all your electrical items when going on a vacation, turning off or limiting your AC usage during portions of the day when they are not needed can greatly reduce the electric costs.

We can improve our calculations using the Wolfram Language. First let us make some assumptions. We will assume we are discussing a home, one where the inhabitants are out working between the hours of 8am and 5pm. The occupants wish to keep the temperature of the house between 65 and 75 °F. The air temperature inside a home is typically 2 to 3 degrees warmer than the exterior due to insulation and the various heat sources in the building. So we will be interested in exterior temperatures between 62 and 72 °F. For our purposes we will look at temperatures in June 2014 and locate our fictional home in Sacramento, California.

We can extract the amount of time the temperatures exceed these limits from the historical data for that month:

Extract the amount of time temperatures exceed limits

A visualization of that data shows the daily fluctuations:

Daily fluctuations

To simplify our calculations, we will sample the data by hour, noting how many hours the temperature was above or below our range of comfort.

Hours above or below comfort range

From this we see that if we want to remain within our desired comfort band, we will be running the AC quite a bit in June. But let’s omit the portion of the day between 8am and 5pm (adjusting the data to account for the time zone):

Omitting 8am to 5pm

Now we see that we have drastically reduced the amount of cooling needed. With more lenient temperature guidelines, such as allowing the heating temperature to remain lower at night or raising the acceptable cooling temperature around midday, further cost savings can be found.

Ultimately we will be running our AC for a portion of the day regardless, and it is useful to know how much air conditioning we will need and what our electric bill will be like. Wolfram|Alpha provides an air conditioner sizing guide. By specifying the area of the space being cooled, how long it will run each day, the average price of electricity per kWh, as well as important properties (such as the level of insulation), Wolfram|Alpha will calculate not only what your monthly costs will be, but how big an AC unit you will need.

Returning to our example home, we will suppose we are dealing with a modest sized home with 1,500 square feet of interior space. It has little tree cover, but good insulation. There are two full-time occupants. In this part of California, electricity rates are about 10 cents per kWh currently. If you don’t have a current electric bill handy, you can estimate your cost per kilowatt hour with Wolfram|Alpha. Based on our calculations above, we need to cool the house for an average of 6.7 hours a day. The air conditioner sizing guide shows:

Air conditioner sizing guide

Based on this, you would need a 29300 BTU/hour capacity air conditioning unit to cool your home, and your bill would be roughly $173. Over the course of the month, that would be 5.89 million BTU, or a 12th of what the average car uses in a year in the USA.

Finally, with your AC running and thermostat set to lower costs, you can lean back and relax in the coolness of your own home.


I’m considering purchasing an Air Conditioner because the temperature in my city is increasing compared to several years ago, all this formulas would help me calculate my electricity bill.

I just wish that Indonesian electricity price is available on the input, just like California electricity price example.

Posted by Arisanto G Pratama July 21, 2014 at 5:55 pm

    Thank you for your interest! Currently we do not have the data for Indonesia but we are always working to expand Wolfram|Alpha’s capabilities and hope to extend our coverage of energy prices to other parts of the world in the future.

    Posted by The Wolfram|Alpha Team July 24, 2014 at 12:52 pm

Nice post. Most electric companies use a graduated rate scale, especially in the summer, that charges more per kWh above a given threshold. They do this to help reduce the demand to keep it within the means of production.

Let’s turn the problem around: suppose that we have a budget for electricity use and want to find the operating settings (time on, time off, cooling base temperature) for the AC to stay with the budget. We already have the AC unit we purchased a few years ago, so that’s fixed, as are the environmental factors.

Posted by Bob Nachbar July 28, 2014 at 7:28 am

    Good idea! I hope they will implement that!

    Posted by Mabie July 28, 2014 at 7:07 pm

Living in Miami-Florida the temperature of my house fluctuates heavily throughout the day. Using your air conditioner sizing guide helped me find the right AC unit for my home! I recommend you size your air conditioner and purchase one to save your self the struggle with the temperature and price of your electricity bill.

Posted by Fernando July 29, 2014 at 1:29 pm

Great read, interesting to see all the facts and figures laid out when it comes to heating and ac!

Posted by McCrea Heating and AC January 2, 2015 at 4:32 pm

Living in Arizona I know that the cost of cooling can be quite expensive. Does this math still hold true to very hot areas (> 110 degrees)?

Could you train this algorithm based on previous months electricity bill & cooling setting?



Posted by Rob Corte January 22, 2015 at 9:45 am

Great post! Thank you so much for sharing! Love the video.

Posted by Green Homes Together May 13, 2015 at 3:44 am

Hello Jason,

I am trying to run your code inside the Wolfram Development Platform, and I’m encountering some difficulties. I needed to do this for the temperature data in Bucharest, for the year 2012.
I got the ‘not a valid dataset or list of datasets’ error, so I have tried to type the code you typed:

data = AirTemperatureData[Sacramento, {DateObject[{2014,5,30}], DateObject[{2014,7,1}]}];

I still cannot get the plot you got, instead I keep getting the ‘not a valid dataset or list of datasets’ error.

Can you please tel me where I am going wrong?

Thank you,

Posted by Felicia November 24, 2015 at 2:37 pm