Introduction to Numerical Methods - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Introduction to Numerical Methods

Description:

Many problems can be formulated in simple mathematical equations ... not associative and not distributive, but they are to a very good approximation ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 27
Provided by: mat132
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Numerical Methods


1
Introduction to Numerical Methods
  • Andreas Gürtler
  • Hans Maassen (maassen_at_math.ru.nl)tel. 52991

2
Plan for today
  • Introduction
  • Errors
  • Representation of real numbers in a computer
  • When can we solve a problem?
  • A first numerical methodBisection method for
    root-finding (solving f(x)0)
  • Practical part Implementation of the bisection
    method

3
What are numerical methods for?
  • Many problems can be formulated in simple
    mathematical equationsThis does not mean, that
    they are solved easily!
  • For any application, you need numbers?
    Numerical Methods!
  • Needed for most basic things exp(3),sqrt(7),sin(
    42), log(5) , ?
  • Often, modeling and numerical calculations can
    help in design, construction, safety
  • Note many everydays problems are so complicated
    that they cannot be solved yet ? Efficiency is
    crucial

4
Numerics is about numbers
  • Numerical methods Numerical approximation of
    solutions to understood problems
  • Numerical representation of real numbers has
    far-reaching consequences
  • Two main objectives
  • quantify errorsApproximation without error
    estimation is useless
  • increase efficiencySolutions which take years or
    need more resources that you have are useless
  • Nowadays, many fields depend on numerics

5
  • Errors

6
Numerical errors
  • Roundoff error finite precisionnumerical
    calculations are almost always approximations
  • Truncation error a calculation has to
    stopExamples
  • Approximation (e.g. finite Taylor series)
  • Discretization
  • It is crucial to know when to stop (i.e. when a
    calculations is converged!). To check this,
    change parameters (e.g. step size, number of
    basis states) and check result.
  • modeling error

7
Truncation errors
  • Truncation errors are problem specific
  • Often, every step involves an approximation,e.g.
    a finite Taylor series
  • The truncation errors accumulate
  • Often, truncation errors can be calculated

8
Roundoff errors
  • Precision of representation of numbers is
    finite - errors accumulate
  • a real number x can be represented as fl(x)
    x(1?) floating point computer
    representation fl(x)-x ?x
    absolute error (often also ?x) fl(x)-x/x
    ? relative error
  • Example Logistic Mapxi1r xi (1-xi)
  • x0 0.7 r4
  • single and double precision

9
  • Computer representation of numbers

10
back to Matlab data types
  • Real numbers floating point representation
    double (64 bit) standard! single (32
    bit) less precision, half memory
  • Integer signed and unsigned (8,16,32
    bit)auint8(255), bint16(32767),
    cint32(231-1)Integers use less space,
    calculations are precise!
  • Complexw23i vcomplex(x,y) x,y can be
    matrices!
  • Boolean true (1) or false (0) Strings
    s'Hello World'
  • special valuesinf, -inf, NaN Infinity,
    Not-a-Numbercheck with isinf(x), isnan(x)

11
(No Transcript)
12
(No Transcript)
13
floating point caveats
  • not all real numbers can be represented as
    FP0.10.10.10.10.10.10.10.10.10.1-1
    -1E-16
  • Floating point calculations are not
    precise!sin(pi) is not 0, 1E201-1E20 is not
    1
  • never compare two floats (ab) directlytry
    100(1/3)/100 1/3 FALSE!!! use
    abs(a-b)lteps (eps2.2E-16)
  • be careful with mixing integer and
    FPiint32(1)i/2 produces 1 as i/2 stays
    integer!i/3 produces 0 ! This is much more
    dangerous in C and FORTRAN etc. Solution
    explicit type conversion double(i)/2 produce
    s 0.5

14
  • What can we solvenumerically?

15
What can we solve
  • Suppose we want to evaluate f(x) with perfect
    algorithm
  • we have FP number x?x with error ?x?f(x)
    f(x?x)-f(x) ? f(x)?x (if f differentiable)
  • relative error
  • Definition condition number
  • ? gtgt1 problem ill-conditioned
  • ??small problem well-conditioned

16
well- and ill-conditioned methods
  • Lets try a simple calculation 99-70sqrt(2)
    (?0.00505)
  • suppose we have 1.4 as approximation for ?2
  • We have 2 mathematically equivalent methods
  • f1 99-70?2 f1(1.4) 1
  • f2 1/(9970?2) f2(1.4) ? 0.0051
  • Condition numbers f1(x) 99-70 x ????2? ?
    20000f1(x) 1/(9970 x) ????2? ? 0.5

17
what happened?
  • f1 99-70?2
  • f2 1/(9970?2)
  • Condition number of subtraction,
    additionf(x)x-a ?? -x/(x-a) ill-condition
    ed for x-a0f(x)xa ?? x/(xa)
    ill-conditioned for xa0
  • Condition number for multiplication,
    divisionf(x)ax ? xa/(ax) 1
    f(x)1/x ? xx-2/(x-1) 1 well-conditioned

18
numerical disasters
  • Patriot system hit by SCUD missile
  • position predicted from time and velocity
  • the system up-time in 1/10 of a secondwas
    converted to seconds using 24bit precision (by
    multiplying with 1/10)
  • 1/10 has non-terminating binary expansion
  • after 100h, the error accumulated to 0.34s
  • the SCUD travels 1600 m/s so it travels gt500m in
    this time
  • Ariane 5
  • a 64bit FP number containing the horizontal
    velocity was converted to 16bit signed integer
  • range overflow followed
  • from
  • http//ta.twi.tudelft.nl/nw/users/vuik/wi211/disas
    ters.html

19
Root finding a standard numerical problem
  • A common task is to solve an equation f(x)0
  • task find the zero-crossing (root) of f(x)
  • Pitfalls f(x) might have
  • no roots
  • extrema
  • many roots
  • singularities
  • roots which are not FP numbers
  • roots close to 0 or at very large x
  • There are different methods with advantages and
    disadvantages

20
(No Transcript)
21
(No Transcript)
22
convergence
  • Bisection always converges, but maybe slow
  • f ? Ca,b and f(a)f(b)lt0 then pn
    converges to a root p of f andpn-p ?
    (b-a)/2n
  • Proof?n ?1 bn-an (b-a)/2n-1 and p ?
    (an,bn)
  • convergence is linear

23
order of convergence
Let converge to p with
if positive ???? exist with
then pn converges with order ??1 linear
convergence?2 quadratic convergence
24
(No Transcript)
25
Exercise
  • Implement the Bisection method in Matlab
  • use it to solvex3 ln(1x)
    (xgt0)

26
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com