home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1995 / ARCHIVE95.iso / discs / pipeline / 8_02 / CrossCheck / ReadMe < prev   
Text File  |  1994-07-28  |  13KB  |  242 lines

  1. %OP%VS4.13 (28-Apr-92), Gerald L Fitton, R4000 5966 9904 9938 
  2. %OP%DP0
  3. %OP%IRY
  4. %OP%PL0
  5. %OP%HM0
  6. %OP%FM0
  7. %OP%BM0
  8. %OP%LM4
  9. %OP%PT1
  10. %OP%PDPipeLine
  11. %OP%WC2,1238,44,1748,0,0,0,0
  12. %CO:A,72,72%
  13. %C%Cross Checks
  14. %C%by Gerald L Fitton
  15. Keywords:
  16. Check Error Fitton
  17.  
  18.  
  19. Introduction
  20.  
  21. Although my 'day job' is teaching almost anything related to 
  22. Mathematics (from Statistics, Fourier Analysis, Stress Analysis of 
  23. Structures and even Economics) at the local College of Further 
  24. Education my knowledge of what goes on (Mathematically speaking) in 
  25. Primary and Secondary Schools is limited to tales told me by my 16 year 
  26. old students.  Perhaps a PipeLine article is not the place to enter 
  27. into a discussion as to whether the standards of pre Further Education 
  28. Numeracy have risen or fallen; I don't intend to say anything on that 
  29. subject at present (but I'm more than willing to listen to your 
  30. comments).  However, I do feel able to say, without fear of being 
  31. corrected, that that the Mathematics taught at Primary and Secondary 
  32. Schools nowadays is definitely different from that which I was taught.
  33.  
  34. Hence, it is with some trepidation and in anticipation of being deluged 
  35. by "Things ain't what they used to be" mail (but I won't mind - honest) 
  36. that I mention the instruction I received at Market Drayton (Salop) 
  37. Junior School when I was eight years old.  I must remind those of you 
  38. who never knew the nature of the Education system before the 1944 
  39. Education Act that there was no 11+ but there was an Examination called 
  40. the "Scholarship".  Those who passed the "Scholarship" were entitled to 
  41. a "Special Place" at the local Grammar School.  The Grammar School was 
  42. a private body and pupils paid fees unless they had a "Special Place" 
  43. (in which case the school fees were means tested and paid, at least in 
  44. part, by the Local Education Authority).  We were poor so that the only 
  45. way I could get to the Grammar School would be by passing the 
  46. "Scholarship" and so gaining a "Special Place".  In those days going to 
  47. the Grammar School was considered to be a 'good thing' for middle or 
  48. working class children (such as me).  It was something I (and many 
  49. others) believed we had to to work toward whilst at the Junior School.  
  50. Teachers at the Junior School were pleased for and proud of pupils who 
  51. passed the "Scholarship".
  52.  
  53. At the age of eight my education was (almost) exclusively English and 
  54. Arithmetic - in preparation for the "Scholarship" which we would take 
  55. at the age of 9, 10 or 11 (according to ability).  In English we were 
  56. taught Grammar and Comprehension as well as Parts of Speech!  In 
  57. Arithmetic we were taught fractions, ratios and proportion and - wait 
  58. for it - the subject of this article - "Cross Check Arithmetic".
  59.  
  60.  
  61. Error Checks
  62.  
  63. During the last six months I have received a wealth (?) of mail asking 
  64. about "Cross Checks".  This topic has come to the fore in recent
  65. correspondence primarily because the spreadsheet part of Versioná1.07 
  66. of Fireworkz sometimes does its arithmetic incorrectly (or not at all).  
  67. This would not be so bad (and there are 'work arounds') except for the 
  68. fact that it does so without generating any error message.  Of course, 
  69. this is potentially disastrous for those using Fireworkz for their 
  70. accounts and I can understand why those who experience this phenomenon
  71. write to me using emotive phraseology rather than objective comment!
  72.  
  73. Generally, if the Fireworkz spreadsheet is small then the risk of an 
  74. error is small and when one occurs it is fairly obvious; if the 
  75. spreadsheet (or set of linked documents) is large then such an 
  76. unreported error is more likely and much harder to spot.
  77.  
  78. I have had occasion to note that PipeDream sometimes fails to include 
  79. the most recent numerical entry into its recalculation; these occasions 
  80. are when I use <CtrláFGS> to Save a large sheet which has not finished 
  81. recalculating.  Generally PipeDream puts itself right at the next entry 
  82. so I usually don't bother worrying about it until I have completed all 
  83. my transactions.  My main check is to enter all transactions into a 
  84. separate simple (credit, debit, balance) file as I go and check that 
  85. the final balance agrees with the main (large) spreadsheet.  This is 
  86. not a 'Cross Check' in the 'when I was eight' sense of the phrase but 
  87. it is a useful way of ensuring that all entries have been made 
  88. correctly and have been 'calculated' by the main spreadsheet.
  89.  
  90. From my comments above the more perceptive of you will realise that, 
  91. although I have both, I still use PipeDream in preference to Fireworkz 
  92. for the main part of my serious spreadsheet work.  Unreported errors in 
  93. Fireworkz is only part of the reason - the relative speeds of PipeDream 
  94. and Fireworkz is another.  I wonder how you feel about Fireworkz when 
  95. you compare it with PipeDream?
  96.  
  97.  
  98. Cross Checks
  99.  
  100. Load the file [ErrorCheck] from this directory and you will see that 
  101. the block B5E8 consists of sixteen entries, all of which are what, as 
  102. an eight year old, I would have called "decimals" but which I believe 
  103. are now called "decimal fractions".
  104.  
  105. The sums of the columns appear in row 10 and the sums of the rows 
  106. appear in column G.  If you then add the values in row 10, B10E10, it 
  107. should be (exactly) the same as the sum of column G, G5G8.
  108.  
  109. When I was eight years old this "Cross Check Arithmetic" is something I 
  110. had to practice for hours on end (without the aid of a calculator).  
  111. Incidentally I found that adding columns was much easier than adding 
  112. along a row - even though I had never heard of (to use modern 
  113. terminology) 'place notation'.  I took to doing what I now know as 
  114. 'transposing' the array of numbers (so that the rows became columns and 
  115. the columns became rows) and adding only columns.  I found that the 
  116. time taken to rewrite the array in its transposed form was more than 
  117. compensated for by the time taken to correctly add up the rows.  I 
  118. suppose that, with a calculator, it doesn't make a lot of difference 
  119. whether you're adding down a column or along a row.  Such is progress!
  120.  
  121. Before I introduce you to the formulae in H10, I10 and J10 let me draw 
  122. your attention to a subtle point about the formulae in row 10 and 
  123. column G.  For example, have a look at B10 where you will find 
  124. sum(B4B9) and not sum(B5B8) as you might have expected.  What I have 
  125. done is to introduce two blank rows, row 4 and row 9 and include them 
  126. in the sum().  You might wonder why.  The reason is that, if you do it 
  127. my way, you can mark the rows 5 to 8 (containing the data) and use a 
  128. Sort operation (such as <CtrláBSO>) on the marked block without 
  129. 'corrupting' the formula in B10.  If you used the formula sum(B5B8) in 
  130. B10 and then sorted the block in such a way that row 8 changed position 
  131. to become, say row 7 then the sum(B5B8) would be 'corrupted' to become 
  132. sum(B5B7), which you don't want to happen because the new row 8 would 
  133. be left out of the sum!  It is 'good practice' to leave blank lines 
  134. above, below, left and right of a block of data for this reason.
  135.  
  136. Those of you who create data bases of text with each row a record and 
  137. each column a field would do well to note this 'tip' of leaving a blank 
  138. line in any computation on the columns.
  139.  
  140. As an aside - I think it is good practice to include blank rows and 
  141. columns when defining a PipeDream Name to refer to a block of data if 
  142. there is any chance you're going to sort it.
  143.  
  144.  
  145. The Erroneous Cross Check
  146.  
  147. The 'obvious' cross check formula is that in slot H10.  Surprisingly it 
  148. gives the message "Error"!  The reason is interesting and I have 
  149. referred to it in earlier articles.  Essentially, decimal fractions are 
  150. not (and can not) be stored accurately in binary (though they can be 
  151. stored accurately in binary coded decimal) since a number such as the
  152. decimal 0.1 is a non terminating series of 1 and 0 in binary.  At this 
  153. stage I must acknowledge the many correspondents who have written to 
  154. me, many sending me a worked value for 1á≈á10 using binary long 
  155. division.  The infinite series of (binary) 1 and 0 has to be truncated 
  156. at some point.  This truncation generates the 'inaccuracy' with which 
  157. values such as 0.1 are stored in the computer.
  158.  
  159. Whether or not you follow the reasoning of the previous paragraph, the 
  160. essential point to grasp is that the sum of the values in row 10 is a 
  161. sum of approximations and that the sum of the values in column G (which 
  162. is also a sum of approximations) can easily be slightly different.  The 
  163. displayed value won't be different because the difference between the 
  164. two values is a very small number (about 0.0000000000000001) and the 
  165. display is shown only to two decimal places.  If your 'Cross Check' is 
  166. to compare the two approximations for an exact match then sometimes you 
  167. will be told that there is an "Error" when, in truth the calculation is 
  168. (near enough) "OK".
  169.  
  170.  
  171. A 'Pragmatic' Cross Check
  172.  
  173. Now have a look in slot I10 and you will see the formula which has been
  174. developed as a result of correspondence about error checks between 
  175. myself and Dennis Howard.  Thanks Dennis for the inspiration!
  176.  
  177. The difference between the two values (remember that this difference is 
  178. theoretically zero if the numbers are exactly the same) is divided by 
  179. twice their average and the absolute value of this ratio is compared 
  180. with a small number - in this case (1e-10) ie 0.0000000001.  I have 
  181. used the function abs() to get rid of any negative value for the 
  182. difference before comparing it with the small positive number (1e-10).  
  183. This method of dividing the difference by (twice) the average allows 
  184. you to check both large and small numbers without having to change the 
  185. value of (1e-10) to match the (average) size of the two numbers.
  186.  
  187.  
  188. The Custom Function
  189.  
  190. I have written a simple custom function called "same_number" which you 
  191. will find in the file [c_Same].  This custom function accepts two 
  192. numbers as its parameters and checks whether they are the same to about 
  193. one part in 1000000000000000 (one part in a thousand million million).  
  194. As an example of the way in which this custom function may be used have 
  195. a look at slot [ErrorCheck]J10 and you will see that it returns the 
  196. value "OK".
  197.  
  198. I haven't tried this custom function out for enough examples to be sure 
  199. it is the best compromise between accuracy and common sense but you'll 
  200. find that if you change the (1e-16) in slot [c_Same]A11 to (1e-17) then 
  201. this custom function returns "Error" in [ErrorCheck]J10 showing that 
  202. my error function does have a value greater than 0.00000000000000001!
  203.  
  204. The 'experiment' of the previous paragraph shows that the value of 
  205. (1e-16) is right on the limit of producing false error messages with 
  206. this example.  I think I'd be happier with (1e-14) or (1e-10) for 
  207. general use - but I'd like to know what your experience is of using 
  208. such a function.  False error messages from a known cause is 'safer' 
  209. than false "OK" messages (or, as in Fireworkz, no message at all).  
  210. As I said, this is a case for further experimentation.  If you get 
  211. false error messages with (1e-16) then try a slightly larger value but 
  212. never more than (1e-10) and let me know what you eventually find is a 
  213. reasonable value.  I'll report back on a future disc.
  214.  
  215.  
  216. Finally
  217.  
  218. My general advice to those of you with large spreadsheets (or many 
  219. linked spreadsheets) and who have both PipeDream and Fireworkz is to 
  220. stick to using PipeDream until we find out the extent to which the next 
  221. version of Fireworkz is 'better' than the current version.  I keep 
  222. saying that PipeDream is a 'mature' package with few 'bugs' that are, 
  223. in the main "obscure and known".  What I mean is that I am confident 
  224. that I can use PipeDream to get answers I can believe in whereas I've 
  225. had a few near disasters with my accounts using Fireworkz.
  226.  
  227. The problem with the 'exact' cross check of [ErrorCheck]H10 is not one 
  228. of PipeDream's making; it is inherent in the nature of binary 
  229. arithmetic.  The 'work around' of seeing if two numbers are 'near 
  230. enough' the same can be implemented by means of a custom function.  If 
  231. you have a lot of such cross checks in your spreadsheet then you'll 
  232. find that using the custom function gives you the usual benefits of 
  233. using custom functions.  The benefits of custom functions range from 
  234. smaller spreadsheets (which load and save more quickly) to consistency 
  235. and readability (consistency and readability make modifications to the 
  236. sheet easier, more rapid and more sure).
  237.  
  238. Please let me know if you feel you have something to say on this 
  239. subject and particularly if you develop the custom function further.  
  240. Definitely let me know how you would like me to develop my articles on 
  241. the general subject of spreadsheet design.
  242.