Enigmatic Code

Programming Enigma Puzzles

Enigma 1526: Degrees of error

From New Scientist #2689, 3rd January 2009 [link]

Joe did not trust the accuracy of his two digital thermometers, but he knew he could be confident that their percentage errors were constant over the range he needed to use them.

He placed the sensors of both thermometers in a beaker of oil and noted the temperatures indicated as the oil slowly warmed up. When one indicated 76.3°C the other indicated 150.1°F, and when one indicated 98.1°C, the other indicated 184.3°F.

As the oil cooled down, one indicated temperature was 167.2°F and Joe found he was able to calculate the corresponding true temperature of the oil in degrees celsius.

What was the true temperature?



3 responses to “Enigma 1526: Degrees of error

  1. Jim Randell 23 July 2012 at 8:47 am

    This Python program is an expansion of the Perl code I wrote originally to solve the problem. It checks possible temperatures for the first reading (from 20.0°C to 200.0°C in increments of 0.1°C), computes the errors for each thermometer and then finds the value for which the calculated second temperatures for each thermometer are closest. It runs in 44ms.

    from itertools import count
    from enigma import printf
    m = None
    # possibilities for the actual temperature of the first reading
    for t1 in count(20.0, 0.1):
      if t1 > 200.0: break
      # calcuate the errors in the thermometers
      c = 76.3 / t1
      f = 150.1 / (1.8 * t1 + 32.0)
      # compute actual temperatures for second reading
      # according to each thermometer
      t2c = 98.1 / c
      t2f = (184.3 / f - 32.0) / 1.8
      # record the closest readings
      d = abs(t2c - t2f)
      if not(m is None or d < m[0]): continue
      t3f = (167.2 / f - 32.0) / 1.8
      m = (d, t1, t2c, t2f, t3f, c, f)
    # what's the best solution?
    (d, t1, t2c, t2f, t3f, c, f) = m
    printf("t1={t1} t2={t2c},{t2f} t3={t3f} c={c} f={f}")

    Solution: The true temperature is 80°C.

    • Jim Randell 23 July 2012 at 8:48 am

      And here’s an algebraic solution using SymPy.

      from sympy import symbols, solve, Eq, Rational
      from enigma import printf
      # let the three temperatures be t1, t2, t3
      # and the errors in the thermometers be c, f
      (t1, t2, t3, c, f) = symbols('t1 t2 t3 c f')
      # use Rationals to avoid floating point numbers
      # convert Celcius to Farenheit
      def farenheit(t):
        return 32 + Rational(9, 5) * t
      s = solve([
        # first reading
        Eq(c * t1, Rational(763, 10)),
        Eq(f * farenheit(t1), Rational(1501, 10)), 
        # second reading
        Eq(c * t2, Rational(981, 10)),
        Eq(f * farenheit(t2), Rational(1843, 10)),
        # third reading
        Eq(f * farenheit(t3), Rational(1672, 10)),
      ], t1, t2, t3, c, f)
      for (t1, t2, t3, c, f) in s:
        printf("t1={t1} t2={t2} t3={t3} c={c} f={f}")
      • Hugh Casement 16 October 2014 at 12:39 pm

        I think this one can be done with pencil and paper. Let’s suppose the readings need to be multiplied by c and f respectively to give the true temperatures:
        1.8 × 76.3 c = 150.1 f – 32
        1.8 × 98.1 c = 184.3 f – 32

        Not the neatest pair of simultaneous equations, but they can be solved to give f = 20/19 = 1/0.95.
        So we divide 167.2 by 0.95 to give 176°F = 80° Celsius. That’s probably what you’re doing, but less transparently!

        I have to say it’s a most unreasonable assumption that a thermometer would have an error proportional to the difference from some arbitrary point (the freezing point of water or the temperature of Herr Fahrenheit’s ice & salt mixture). I have one where the crossover point appears to be about 12.5°, but the slope could just as easily be negative.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: