Temperature — Question 10

Section 1-7 · Chemistry pages 145–146

Show solutionHide solution

Question 10

A conversion bug can preserve changes while corrupting temperatures

A program should calculate Celsius values using tC=(5/9)(tF−32)t_C=(5/9)(t_F-32). Instead it uses tbug=(5/9)tF−32t_{\mathrm{bug}}=(5/9)t_F-32. Treat these as numerical scale equations with exact constants.

Diagram shown in the original SVG worksheet.

  1. For inputs 32∘F32^\circ\mathrm F and 212∘F212^\circ\mathrm F, calculate the correct and faulty Celsius outputs. Report faulty outputs to two decimal places.

  2. Derive the difference tbug−tCt_{\mathrm{bug}}-t_C for any input and explain why it is constant.

  3. Would a test that checks only the temperature rise from 32 to 212∘F212^\circ\mathrm F detect the bug? Propose a better test.

Question 10 - Solution

A conversion bug can preserve changes while corrupting temperatures

Diagram shown in the original SVG worksheet.

(a) Evaluate two reference inputs

Correct outputs are 0∘C0^\circ\mathrm C and 100∘C100^\circ\mathrm C. Faulty outputs aretbug(32)=59(32)−32=−14.222…→−14.22∘C,t_{\mathrm{bug}}(32)=\tfrac59(32)-32=-14.222\ldots\to-14.22^\circ\mathrm C,tbug(212)=59(212)−32=85.777…→85.78∘C.t_{\mathrm{bug}}(212)=\tfrac59(212)-32=85.777\ldots\to85.78^\circ\mathrm C.The subtraction must occur before multiplication in the correct equation.

(b) Subtract the equations

tbug−tC=(59tF−32)−(59tF−1609)=−1289.t_{\mathrm{bug}}-t_C=\left(\tfrac59t_F-32\right)-\left(\tfrac59t_F-\tfrac{160}{9}\right)=-\frac{128}{9}.Every faulty output is about 14.22∘C14.22^\circ\mathrm C too low. The input-dependent terms cancel because the slopes match.

(c) Test both slope and offset

No. Both formulas give a rise of 100∘C100^\circ\mathrm C between those inputs; the constant error cancels in the difference. Test at least one absolute reference output, such as 32∘F↦0∘C32^\circ\mathrm F\mapsto0^\circ\mathrm C, and also test a second point to check the slope.

Check and interpretation

A correct interval conversion does not prove a correct temperature conversion. An offset error can pass every difference-only test.