## Get out of here!

– Congratulations on your new job!
– Oh, you mean the weather man thing?! That’s nothing! Anyone can do it.
– Really? I thought it was kind of hard.
– Not at all. Look at me!
– But what about all those averages you have to calculate?
– What do you mean? What averages?
– “The average temperature yesterday was 18°C.” How do you do that?
– We have a guy who adds the max and min temperature of the day and divides by two.
– How does he know the max and min temperatures? Does he stick around all day looking at the thermometer?
– He did that until recently. Now we have bought him a special thermometer so he doesn’t have to.
– I see.
– Do you know what kind of weather we will have tomorrow? The show starts in thirty minutes and I could need some help.
– One question. I have one question that just popped into my head. Do you have time?
– Shoot!
– How many people work on the set?
– Ten in all, I think.
– Do you know their heights?
– Their heights?
– Yes.
– No, but I could find out if you are interested.
– I want to calculate the average height.
– Oh, that?! You don’t need the height of all of them for that. I will find out the tallest guy and the shortest and just add their heights and divide by two.
– Will that give me the average height?
– You are talking to the weather man! If I don’t know, who does?

——

– Have you met our new neighbour?
– I saw him the other day, but I did not talk to him. He looks a bit strange.
– What do you mean?
– I don’t know. Just strange.
– Stranger than me?
– Sometimes you are strange too!
– Like when?
– You remember when you wrote down the temperatures outside every minute for an entire day?
– You find that strange? I just wanted to find the average temperature for the day.
– How would you do that?
– Why 1440?
– “Would have had”! Sounds like the story of your life, doesn’t it?
– I had to stop at reading 1334 as my fingers cramped.
– Is that what you call it when you give up?
– By the way, I talked to the new neighbour yesterday!
– Really?! What did you talk about. Don’t tell me you talked about your average temperature project?
– We did, actually. He was very interested.
– I told you he was weird!
– He asked me if I could give him the temperatures I measured at 4, 8, 16, and 22 hours.
– Is he a military man?
– I don’t think so. Anyway, I told him the temperatures were 5, 12, 24, and 15°C. Do you know what he did then?
– Hit you on the fingers?
– Don’t be silly! He invited me inside and showed me this graph on his computer.

– And why one earth did he do that?
– Can’t you see what it is?
– It is obviously the graph of
f(x) = -65/6048*x^3+121/432*x^2-11/27*x+536/189,
but I don’t see how that relates to anything.
– Look carefully at the values for x = 4, 8, 16, and 22!
– I see, the graph shows the temperatures for the day you were measuring. But, how come?! You said you only gave him four values.
– I did! He told me that if one assumes the temperature follows the graph of a third degree polynomial, four points is enough to draw it.
– And does the rest of the graph match your data?
– I haven’t had time to check that part yet, but there is more!
– He showed you another graph?
– He told me how to find the average temperature exactly.
– Anyone can do that, just integrate the function from 0 to 24 and divide by 24. It comes to 14.582, if I am not very much mistaken.
– Your number crunching skills do not stop to amaze me! However, he did something simpler.
– Like what?
– He added f(5.071667) and f(18.928333) and divided by two.
– What did he get?
– 14.582.
– Get out of here!

Will the neighbour’s method always work? How did he pick his two points? Will other point pairs work? What is the neighbour’s name? Does the temperature during a day really follow a third degree polynomial?

Problem kindly suggested by John Shonder.

——

To research the problem I used MapleV Student Edition.

interp([4,8,16, 22], [5,12,24, 15], x) ;
gave me the third degree polynomial called f(x) in the story using Lagrange interpolation formula.

plot(-65/6048*x^3+121/432*x^2-11/27*x+536/189,x=0..24);
gave me the graph.

evalf((int(-65/6048*x^3+121/432*x^2-11/27*x+536/189, x=0..24))/24, 5);
gave me the definite integral divided by 24, i.e. 14.582.

By the way, I had to delete the file Opengl32.dll in the folder BIN.wnt to get Maple to read my key punches.

### 8 Responses to “Get out of here!”

1. Michael says:

Neat! Apple’s Grapher application (free / included with OS X) did a fine job of this interpolation as well. I’d never really given any thought to how average temperatures are calculated but yeah I suppose this is the only way that makes sense.

2. I’m still interested to learn the method to determine the 2 values at which f must be evaluated. What constraints are there in the choice of the 4 values at which the original function is evaluated?

3. Jan Nordgreen says:

Have a look at this Wikipedia article:

4. John S. says:

Strange that when I click on Jan’s link above, wikipedia tells me there is no such page, but then offers to do a search, which then turns up a page with the same name.

What is interesting about the (high + low)/2 method (the “traditional” way of finding daily average temperature) is that in effect, it is saying that the integral of a function over a given range can be approximated by taking the average of the maximum and minimum values of the function on that range. I learned the trapezoid rule, and Simpson’s rule, but this is an approximation technique that no one ever mentioned in Intro to Calculus. Why does it work? Is it related to Gaussian quadrature? That is, does it work because the minimum tends to occur at or near 5.071667 hours from midnight, and the maximum at 18.928333 hours from midnight? I would think the maximum occurs earlier in the day.

5. Anceps says:

The link has a final dot.

6. By 2-point Gaussian quadrature, if c(x) is a cubic, the integral of c(x) over [-1…1] is

w_1 c(x_1) + w_2 c(x_2)

where the w_i are 1 and the x_i are ±1/sqrt(3). To convert the integral into the mean value, divide by the size of the range (2, in the above example), thus making the weights 1/2. In Jan’s example, the range is [0, 24], so scale by adding 1 and multiplying by 12. Now the x_i are 12(1±1/sqrt(3)) ~~ 5.0718 and 18.9282. Jan “added f(5.071667) and f(18.928333) and divided by two” because, among the x-values for which f had been recorded, those were nearest to the values demanded by 2-point Gaussian quadrature.

Gaussian quadrature played no part in the choice of “4, 8, 16, and 22 hours” as the times for which the values of f were requested for the purpose of approximating f by a cubic. Perhaps these times were chosen because they are a useful set of 4 for approximating the change of temperature throughout a winter day: for some latitudes, 8 is just after sunrise, so f(4) and f(8) show how the rising sun makes the temperature rise; 4pm is about sunset, so f(16) shows how the temperature has risen as a result of the sunshine in the daylight hours.

7. […] – A bit old, but there is an annoying temperature discussion at Think Again. Just what does “average temperature” […]

8. Rich says:

You know, I got curious about just this sort of thing a little while ago. I wrote a bash script which generated 10 random numbers (between 0 and 99) and computed the average, then I found the high and low values and averaged those. Here’s what I got…

\$ ./numbers

85 58 6 47 7 66 55 64 61 42

Average = 49.10
Min = 6, Max = 85, Total = 91
Average of Min and Max = 45.50

\$ ./numbers

75 21 85 19 41 73 66 88 53 81

Average = 60.20
Min = 19, Max = 88, Total = 107
Average of Min and Max = 53.50

\$ ./numbers

26 1 26 12 89 35 70 79 81 54

Average = 47.30
Min = 1, Max = 89, Total = 90
Average of Min and Max = 45.00

—————————–

As you can see, they are close, but they ain’t the same thing.
In these examples it looks like they can be up to 12% off. There
can be a significant difference.