[Subject home], [FAQ], [progress],   Bib', Alg's,  C , Java - L.A., Friday, 29-Mar-2024 17:36:03 AEDT
Instructions: Topics discussed in these lecture notes are examinable unless otherwise indicated. You need to follow instructions, take more notes & draw diagrams especially as [indicated] or as done in lectures, work through examples, and do extra reading. Hyper-links not in [square brackets] are mainly for revision, for further reading, and for lecturers of the subject.

Numerical:   Introduction

Numerical accuracy and errors.
e.g. IEEE "single precision" floating-point  representation:
S exponent (8) mantissa or fraction (23)
0 1 2 3 4 5 6 7 8 9 1011 1213 1415 1617 1819 2021 2223 2425 2627 2829 3031
S EEEEEE EE FFFFF FFFFF FFFFF FFFFF FFF
(Also IEEE "double precision": 64-bit, S 1-bit, E 11-bits, F 52-bits.)

It is generally better to combine small numbers first before combining them with large numbers.

Consider   SUMi=1.. ( 1 / i )   -- sum to infinity is a divergent series

SUM i=1.. ( 1 / i )  

Ideally the sum from 1 up to n and the sum from n down to 1 should be equal, but . . .

Also see [oneOverN.c].

There is a number   `delta'   s.t.   delta > 0   and yet apparently   1.0 = 1.0 - delta.
[lecturer: use the demo'; class: note value of delta & probable representation.]
In some cases limited numerical accuracy can cause severe errors . . .

e.g. consider Big = Big' = 1.0, and small = delta
©
L
.
A
l
l
i
s
o
n

Problem: Solve f(x) = 0

Solving f(x)=0

Problem: Integration



See algorithm . . .
[lecturer: briefly or can skip; class: study at home]
double rectangle(double f(double x), double lo, double hi, int N)
 { double width = (hi-lo)/N;
   double sum = 0.0;

   int i;
   for(i=0; i < N; i++)
      sum += f( lo+(i+0.5)*width );
          */ f() at centre of i-th interval */

   return sum*width;
 }


See algorithm . . .
[lecturer: briefly or can skip; class: study at home]
double trapezoidal(double f(double x), double lo, double hi, int N)
 { double width = (hi-lo)/N;
   double sum = (f(lo)+f(hi))/2;

   int i;
   for(i=1; i < N; i++)
      sum += f( (lo*(N-i) + hi*i)/N );

   return sum*width;
 }
[lecturer: do derivation / proof; class: take notes]

See algorithm . . .
[lecturer: briefly or can skip; class: study at home]
double Simpson(double f(double x), double lo, double hi, int N)
/* PRE: N is even */
 { double width = (hi-lo)/N;
   double sum = f(lo)+f(hi);

   int i, odd=true;
   for(i=1; i < N; i++)
    { sum += f(lo+i*width) * (odd ? 4 : 2);
      odd = !odd;
    }

   return sum*width/3;
 }

Integration

Numerical:   Summary

real / float and double.

© L.Allison, Friday, 29-Mar-2024 17:36:03 AEDT users.monash.edu.au/~lloyd/tilde/CSC2/CSE2304/Notes/20numerical.shtml
Computer Science, Software Engineering, Science (Computer Science).