Miscalculating Area and Angles of a Needle-like Triangle
( from Lecture Notes for Introductory Numerical Analysis Classes )

Prof. W. Kahan,  19 July 1999

Abstract:
This case study drawn from an elementary numerical analysis course is aimed at
computer language designers and implementors who took no competent course on the
subject or forgot it and consequently subscribe to principles of language design
inimical to the best interests of writers and users of software with a little
floating-point arithmetic in it.  Though triangles rarely matter to computer
language designers and implementors,  recollections of their high-school
trigonometry and calculus will enable them to follow the discussion,  which is
intended primarily to expose and correct common misconceptions.  The first of
these is that classical trigonometric formulas taught in schools and found in
handbooks and software must have passed the  Test of Time.  Actually they have
withstood it;  they are unnecessarily inaccurate,  sometimes badly,  for some
data some of which is unexceptionable.  Better formulas are supplied here.  Even
if these are impeccably accurate and cost no more than the classical formulas
they should supplant,  the expectation that the better formulas will supplant
the worse is based upon misconceptions too  (see  pp. 5,  9, 16  and  21). 
Other misconceptions addressed herein  ( on indicated pages )  are ... 
=  That subtractive cancellation always causes numerical inaccuracy,  or is the
     only cause of it.  (3, 5)
=  That a singularity always degrades accuracy when data approach it.
     (4, 5, 7, 8, 10, 12-16)
=  That algorithms known to be numerically unstable should never be used.  (10) 
=  That arithmetic much more precise than the data it operates upon is pointless.
     (7, 9-12, 14, 17-21)
=  That modern  "Backward Error-Analysis"  explains everything,  or excuses it.
     (12, 14-17)
=  That bad results are due to bad data or bad programmers,  never to a 
     programming language.  (9-12, 18-20)
Misconceptions like these hinder programming languages from conveying to owners
of by far the majority of computers now on desk-tops the benefits of their 
hardware's superior floating-point semantics.  (9-11, 19-20)

Contents:
$1.  Classical Formulas for  Area  and Angle C                         page  2
$2.  How to compute  Area                                                    3 
$3.  How to compute  C                                                       3 
$4.  Why Cancellation Cannot Hurt                                            3 
$5.  Examples                                                                4 
      Table 1:   Area  and  Angle  C                                         4 
$6.  Opposite Side  c  and  Adjacent Angle  B                                5
$7.  How to compute  c                                                       5 
$8.  How to compute  B                                                       5 
$9.  How Accurate is  B ?                                                    7 
      Table 2:  Angle  B ,  New Formula B(...)  vs.  Classical  BS(...)	     7
      Table 3:  Uncertainty  dB  due to  Roundoff                            9 
$10. Must the Classical Formulas be Amended ?                                9 
      Table 4:  Formats of  IEEE Std. 754  for  Bin. Floating-Pt. Arith.     9 
$11. What Extra Precision Does for  B                                       11 
$12. How Much Accuracy do Data Deserve ?                                    12 
$13. A Triangle is an Object                                                13 
      Table 5: Side  c ,  cb(a,A,b)  vs. cB(a,A,B(a,A,b))                   13 
$14. Three  Caveats and a  Picture                                          14 
$15. Proper Precision Management                                            18 
$16. Different Floating-Point Semantics                                     19
$17. Conclusion                                                             21 
$18.  Acknowledgments and Bibliography                                      22
$19.  Footnote about Examples                                               22

22 pp. Acrobat Reader  .pdf file:
http://http.cs.berkeley.edu/~wkahan/Triangle.pdf