# How do you add temperatures?

This will probably be considered very simple, but I am just a beginner:

I'm developing a software application where temperatures need to be added and subtracted. Some temperatures are in Celsius, some in Kelvin. I know how to convert to/from Kelvin (273.15), but how should one go about adding and subtracting these? Should everything be converted to Celsius first?

For example:

0°C + 0°C = 0°C
0°C + 500°C = 500°C


But:

0°C + 273.15K = ?


If we put everything in Kelvin, we get:

273.15K + 273.15K = 546.3K


If we put everything in Celsius, we get:

0°C + 0°C = 0°C


But obviously, 546.3K isn't equals to 0°C.

Now, you might say I can't add temperature to temperatures (but should be adding energy or something? not sure). But the reason I'm doing this is because we need to interpolate. I have a collection of key-value-pairs, like this:

973K  -> 0.0025
1073K -> 0.0042
1173K -> 0.03
1273K -> 0.03


Now I need to get the value for 828°C. So I need to interpolate, which means adding/subtracting values.

I hope I'm making sense.

• As long as you stick with one unit, you can interpolate as usual. The average of 400K and 500K is (400+500)/2. Your problem is probably to apply a proper interpolation method. Your 828 degrees are outside of the key value data set, so you need to extrapolate. Maybe you can change the question towards this direction? – Aziraphale Aug 27 '14 at 11:13
• I am curious, why do you want to add temperatures? To get an average temperature for a location? – anna v Aug 27 '14 at 14:22
• @Aziraphale The given table is in $K$, so perfectly fine imo :) – Bernhard Aug 27 '14 at 18:10
• Why do you need to add temperatures? While there are some legitimate situations where you might want to add temperatures, they are rather rare in everyday use. I suggest that you clarify the intended usage in your question. – 200_success Aug 27 '14 at 18:54
• The scenarios that I'm dreaming up that involve adding temperature (other than the averaging already noted for which you convert to like units first and then just proceed) involve a temperature and a change-in-temperature. The distinction is important because $\Delta T_1 = 50\,^\circ\mathrm{C}$ and $\Delta T_2 = 50\,\mathrm{K}$ are the same while $T_3 = 50\,^\circ\mathrm{C}$ and $T_4 = 50 \,\mathrm{K}$ are different. – dmckee --- ex-moderator kitten Aug 27 '14 at 23:51

You may always add the numbers in front of the units, and if the units are the same, one could argue that the addition satisfies the rules of dimensional analysis.

However, it still doesn't imply that it's meaningful to sum the temperatures. In other words, it doesn't mean that these sums of numbers have natural physical interpretations. If one adds them, he should add the absolute temperatures (in kelvins) because in that case, one is basically adding "energies per degree of freedom", and it makes sense to add energies.

Adding numbers in front of "Celsius degrees", i.e. non-absolute temperatures, is physically meaningless, unless one is computing an average of a sort. This is a point that famously drove Richard Feynman up the wall. Read Judging books by their covers and search for "temperature". He was really mad about a textbook that wanted to force children to add numbers by asking them to calculate the "total temperature", a physically meaningless concept.

It only makes sense to add figures with the units of "Celsius degrees" if these quantities are inteprreted as temperature differences, not temperatures. As a unit of temperature different, one Celsius degree is exactly the same thing as one kelvin.

If you interpolate or extrapolate a function of the temperature, $$f(T)$$, you do it as you would do it for any other function, ignoring the information that the independent variable is the temperature. Results of simplest extrapolation/interpolation techniques won't depend on the units of temperatures you used.

• This also shows how care must be taken when converting between temperature scales. If you want to convert 10 °C into kelvins, the result will be 283.15 K if the original number is interpreted as an absolute temperature, but the answer is 10 K if the quantity was a temparature difference (similarly with temperature gradients, heat capacities, etc.). So measure scales with an arbitrary zero point lead to problems. – Jeppe Stig Nielsen Aug 27 '14 at 22:41
• @JeppeStigNielsen: I'm no physicist so I had a bit of a hard time understanding the temperature difference vs temperature measurement thing, but your comment suddenly made it very clear, thanks! – Peter Aug 28 '14 at 7:43
• A word: torsor (math.ucr.edu/home/baez/torsors.html). – Martín-Blas Pérez Pinilla Aug 28 '14 at 15:46
• In the celcius scale, the zero is off by -273.15 degrees celcius ;) That is, zero is the temperature at which water boils rather than zero temperature. – Jenia Ivanov Mar 29 '19 at 1:35

Just convert everything into kelvins (or Celsius, or Fahrenheit, it doesn't matter as long as you're consistent), then do the interpolation, then convert back if you need to. You will almost certainly find that this does work, and that it does give the same answer no matter which unit system you use.

The reason is that when you do interpolation, you're not adding and subtracting temperatures, you're adding and subtracting temperature differences, and this means that the terms that arise from using a different zero point (such as the 546.3K in your calculation) will always cancel out.

• that's "kelvins" with a little k – user21433 Aug 27 '14 at 12:43
• @SeanD thanks, corrected. (For future reference: this is Stack Exchange, you can just edit for little things like that.) – Nathaniel Aug 27 '14 at 13:09
• @Nathaniel Unless this site has been configured differently, suggested edits (since SeanD has less than 2K rep) to the body must be at least 6 characters. SeanD could not have made a suggested edit to change that one character. – nobody Aug 27 '14 at 17:15
• @AndrewMedico ah yes, now I remember that, good point. – Nathaniel Aug 28 '14 at 6:04

You're going to have to tell us why you'd want to do this. I take a stab at it below, where I assume you want to interpolate the temperature between two sensors.

As Motl pointed out you don't "add" temperatures. It's physically meaningless - and dangerous since there's a fundamental misunderstanding in how the program works.

However, you can mix materials - say you added cold milk to your hot coffee. In this case you are mixing the phases. A simple way to get the resulting temperature (and good enough for simple mixtures) is to do a weighted average the temperatures where the weights are the heat capacity (that is the specific heat of the material times the mass). However, if there is heat released upon mixing (say, pouring acid into water) this would not work.

Now, let's say you're programing a temperature interpolation routine to get an estimate of the temperature somewhere between two sensors. Within the program it appears that you're adding (or subtracting) temperatures, but really you're averaging them weighted in length (assuming a homogenous material). Here "adding temperatures" only works if the material is the same - the heat capacities cancel out. Otherwise you should solve the Laplace equation.

• That's more or less what I'm doing yes. But it's actually one sensor that gives me a temperature, and based on that temperature, we need to use another value for something else. This value has been defined in a table where several predefined temperatures map to such a value. But the sensor will hardly ever give you a temperature that is in the table. Which is why we need to interpolate (or extrapolate). – Peter Aug 28 '14 at 7:34
• It would appear that you were meant to use an interpolation, but I'd ask your colleagues to confirm this (for example there might be a specific type of interpolation that is required) – Lenzuola Sep 18 '14 at 16:23

You need to distinguish between a temperature measurement and a temperature difference. (Though others may have better terms for these concepts.) A measurement (in this sense) is tied to some (usually physical) reference, such as the freezing point of water. A difference may use the same size units as a measurement but there is no reference point.

If you convert a temperature measurement from C to F you multiply by 1.8 and add 32. But if you convert a temperature difference from C to F you simply multiply by 1.8.

1. measurement - measurement => difference
2. measurement + measurement => meaningless
3. difference +/- difference => difference
4. measurement +/- difference => measurement
5. (measurement + measurement)/2 => measurement

Another way to look at it:

Suppose you're talking about locations. Does it make sense to add the location of Chicago to the location of New York? Not really. You might, however, subtract one location from the other and come up with a (vector) distance between them. Or you can add a (vector) distance to one location to come up with a new location. Or you can average several locations to come up with a "centrally located" average location.

(There must be a mathematical term for this distinction between measurement and difference or location and distance, but I'm not aware of it.)

Temperature is an intensive property (of a substance), that is, the value of the property does not depend on the amount of substance - for example, if you take a glass of water from a bucket of water, the glass of water will have the same temperature as the bucket of water has. Density is another example of an intensive property of a system. Since intensive propeties cannot be combined (added or subtracted) to obtain a resultant value; temperatures (or densities) cannot be combined to get a resultant temperature (density). This is the reason (intensive quantity) why one cannot add or subtract temperatures.

Extensive properties, such as volume, heat etc., can be combined (added or subtracted) to give a resultant value.

When we mix two samples of water at different temperatures, to get the temperature of the resulting mixture of water, we convert the intensive quantities to the corresponding extensive quantities, which can be added to get the resultant value, from which we can extract the value of the intensive property.

Since delta values of quantities do not depend on the zero of the scale, the delta values can be added to get a new delta value. But, values of quantities can only be added if the zeroes of the scales coincide and the values of unit coincide as well.

In the case of Celsius and Kelvin tempertures the zeros of the scales don't coincide while the values of unit coincide. In the case of Celsius and Fahrenheit scales neither the zeros of the scales coincide nor the units coincide. Hence, care suld be excercised in dealing with conversions from one to another scale of temperatures.

I would recommend you to convert everything in Kelvin and then use the Kelvin values to interpolate between the values. You should use Kelvin for this since it is the only more or less common scale which is relative to the absolute zero and so you will not have to handle negative temperatures - though this seems very unlikely compared to the example values you provided. Additionaly this will prevent any zero-value results where they should not be (like in your example). The other reason for this is that it seems that all the values to interpolate from are given in Kelvin and therefore it is more reasonable to stick to this unit rather than switching to and from different units gratuitously. But think before adding temperatures. As you see it is normally only reasonable when changes appear. You will be better off if you can somehow switch the units for your interpolated value to something else like the total amount of heat energy in the material or the sample. Adding ice at 0°C to your drink at 20°C will not simply add the temperatures but some of the heat energy stored in your drink will be used to compensate the difference in the temperature between the drink and the ice. So please check that way first, it might be easier to calculate and it will definitely be a lot easier to understand and therefore be easier to check your results quickly.

You can make a square with 2 equal right angled triangles. Therefore, you could say that 2 triangles = 1 square, just like how 273.15K = 0°C. But what happens if you try to calculate 1 square + 2 triangles, do you get 2 squares? No, because even though the 2 triangles resemble the shape of 1 square, they will never BE 1 square (there's a line in the middle, the mass is not equal, you can't move them as a whole unless you glue them together).
So you will have to devise a way to convert triangles to squares and then add them. Just like that, you have to convert °C to K before adding them, if you want to do it right.

• Not a bad analogy, but if anything one should convert the other way around, Celsius to Kelvin. There are some rare circumstances in which I could imagine adding values in Kelvins is legitimate, but I can't think of any circumstance under which adding two Celsius temperatures is the right thing to do. – David Z Aug 28 '14 at 18:36
• @DavidZ Fair enough, I don't really know more about them than what I learned in high school so I wouldn't know that :P I'll edit the answer if that makes it more correct. – Kevin Aug 28 '14 at 18:47

You simply cannot add temperatures - such a sum is meaningless !

Using Celsius is simply totally wrong in nearly every circumstance as Celsius involves negative numbers

Science states very clearly that the only way to sum up in thermodynamics involves using the Stefan-Boltzmann equation.

Using the examples you show there are no consistent values anyway and any interpolation you make is thus useless.

• Why is the sum of temperatures meaningless? Temperatures have units, right? – HDE 226868 Dec 17 '15 at 2:16

I disagree with your statement "I need to interpolate, which means adding/subtracting values." The reason I disagree, is that there are various methods of interpolation. The addition/subtraction method is typically used for linear interpolation. For your case, this method is not accurate because your data is not only not linear, but also, it reaches saturation.
The best method is to get the equation of the "best fit" curve for your data, in the vicinity of the point of interest (826 degr. C), and then just enter into the equation the point of interest and obtain its corresponding pair value. In other words, when the number on the left is entered (degr. C), the number on the right is obtained: $$700 -> 0.0025$$ $$800 -> 0.0042$$ $$826 -> 0.0054$$ $$900 -> 0.0300$$ $$1000 -> 0.0300$$

There are a number of programs that can give you the "best fit" curve for any given set of data.

• Well, I'm actually just the programmer. It's the engineers who design this stuff, and apparently, they use (linear) interpolation/extrapolation. In the past (Fortran), these were just numbers. Now (C#), we've made them into real amounts (the combination of a number and a unit). That's why I was adding/subtracting temperatures. – Peter Sep 8 '14 at 8:17

I'm a software engineer, not really a physicist, but I do want to suggest that you don't deal with raw numbers if possible. It's way too easy for someone to assume one number is in the wrong units, and then give you bad results. (Such as bringing down a spacecraft.)

Create a class or something to abstract temperature conversions, so you're always dealing with some Temperature object rather than numbers. Internally it would always store temperatures in Kelvin.

// Constructor methods
static Temperature fromCelsius(double) { ... }
static Temperature fromKelvin(double) { ... }

// Conversion methods
double toCelsius() { ... }
double toKelvin() { ... }


Then you'd use it like so:

Temperature temp1 = Temperature.fromCelsius(0.0);
Temperature temp2 = Temperature.fromKelvin(273.15);
assert temp1.toKelvin() == temp2.toKelvin();


Except when doing calculations, always prefer to pass around Temperature objects rather than a number. No need to make assumptions about what unit you're dealing in.

• This has been sent into the Low Quality Review queue. While it is not really low quality and I think your advice would be somewhat solid if we were talking about how to implement temperatures (already knowing how to add/subtract them), it does not really address the question, which asks about the right way to deal with adding/subtracting temperatures. – ACuriousMind Aug 27 '14 at 23:42
• Actually, I'm not assuming unit and I am using something like that (based on and extended a little from here). But @ACuriousMind is correct, this is about implementation and doesn't answer the question. – Peter Aug 28 '14 at 7:39

The following wiki article is about the "level of measurement" or "scale of measure". Also a link to the article of the psychologist S.S Stevens from which originate a popular classification of scales.

Even if it is possible to numerical operation with numbers that are the results of measurements these operations do not always make sense.

Does adding temparature make sense? The situation is similar to adding time

It does not make sense to add the date $2014/06/14$ to the date $2013/09/23$. You can add each position to get $4027/15/37$ but then you don get a valid date. What makes sense is calculation the difference of two dates. The difference

$$2014/06/14-2013/09/23 = 264 \;\text{days}$$

or $$2013/09/23-2014/06/14=-264 \;\text{days}$$

If you use an other calendar, which means another starting point of your time calculation, the differende remains $264$ days. That is similar from changing form Celsius to Kelvin.

Adding a time difference to a point in time makes sense too:

$$2013/09/23 - 264 \;\text{days} = 2014/06/14$$

Note tha difference has an orientation (a sign). So the difference of the date $p_1$ and $p_2$ and the difference between $p_2$ and $p_1$ have different orientation and therefore add up to $0$.

This also works if one change the calendar

Similar consideration can be done for the points of a plane. The points have coordinates. If one changes the coordinate system, the coordinates of the points change. The addition of points does not make

sense, the difference of points make sense. But in contrast to the time the difference is not a number but a 2 component vector, like "300 kilometers north west".

similar considerations can be done with the temparature. I used the time example because it is more clear from the notation if we are talking about a point in time or about a time difference. In these examples where the origin is arbitrary chosen :the freeze point of water, the year when the birth of christ was supposed, the intersection of medidian through greenich and the equator. In the

nomenclatura of Stevens we are talking about interval scales: the difference has a meaningful interpretation. The following operations are meaningful when using such a scale:

difference of to points (measurements) adding/subtracting a difference to/from a oint adding/subtracting a difference from another difference multiplying a difference by a number (two and a half time the distance between Rome and Paris) dividing a difference by another (to get a number) (the arithmetic mean and the product of differences are special things that I want not dicuss here) the following does not make sense: adding two points multiplying two points, a point by a difference multiplying a point by a number ...

So back to your temparature question. 10C + 15C does not make sense if both are point on the scale. But if one of them is a scale it makes sense. Then we get 25C. Assume the right one is the difference. THen the physical meaning is something

like: if the temparature of the object is currently $10C$ and we raise its temparature by $15C$ then its final temparature has $25C$. So lets assume that the right value is always the difference. Than all of the following makes sense

$$0C + 273.15K = 273.15C$$ $$273.15K + 0C = 273.15K$$ $$0C + 40R = 50C$$ $$40R+0C=40R$$ $$20R+90F=60R$$ $$90F+20R=135F$$ $$20C+0F=20C$$

If you look at the formulas of linear interpolation

$$y=y_0+(y_1-y_0)\frac{x-x_0}{x_1-x_0}$$

or polynomial interpolation that they contain only operations that where called meaningfull above:

Calculating temparature differences, e.g. $x_1-x_0$, dividing temparature differences bei another temparaure difference to get a number , $\frac{x-x_0}{x_1-x_0}$, multiplying a difference by a number, $(y_1-y_0)\frac{x-x_0}{x_1-x_0}$ to get a difference and adding a difference to a point $y_0$. So $y$ should have interval scale, too. The same is true for a polynomial interpolation.

• This doesn't contribute anything to OP's question. The question is about interpolating – Pranav Hosangadi Aug 27 '14 at 23:04
• @Pranav Hosangadi: No I don't think so. I missed the question about interpolation when I read the OP. But the question about the meaningless operation off adding temperatures. I now added a paragraph that shows that linear interpolation consists of meaningfull operations of interval scale data and not of meaningless additions of temparatures. – miracle173 Aug 28 '14 at 0:16