an introduction of scientific computingctw/scientific... · an introduction of scientific computing...

21
An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung University Chin-Tien Wu

Upload: others

Post on 12-Jul-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

An introduction of Scientific Computing

Institute of Mathematics Modelling and Scientific Computing

National Chiao-Tung University

Chin-Tien Wu

Page 2: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

Why scientific computing?

• Simulation of natural phenomena• Virtual prototyping of engineering designs• More insights from unknown phenomenon• Much more

Page 3: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung
Page 4: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung
Page 5: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung
Page 6: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

What is scientific computing?

Design and analysis of algorithms for numerically solving mathematical problems in science and engineering. Traditionally called numerical analysis

Distinguishing features of scientific computing

Approximate continuous quantities by discrete quantities. Considers effects of approximations including error and sensitivity

Page 7: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

What should be cared in scientific computing?

Page 8: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

Sources of approximation

Page 9: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

Example 1

Page 10: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

Error measurement

Page 11: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

Where numerical errors come from?

Page 12: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

More about error (I)

Page 13: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

More about the error (II)

• Condition number of a problem f at value x:

Page 14: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

( ) ( ) ( )ˆ

ˆ( ) sup

ˆxx

f x f x f xcond f

x x x−

=−

( ) ( ) ( )relative input error

ˆ ˆ( )xf x f x f x cond f x x x− ≤ ⋅ −

Condition number of a function f at variable value x is defined as:

Relative propogated error (rounding error) can be estimated by:

Relative computational error (truncation error) can be estimated by:

( ) ( ) ( ) ( ) ( ) ( )

( )( )

relative backward error

ˆ ˆ ˆˆ ˆ ˆ

ˆ ˆˆ ˆ ˆ( )x

f x f x f x f x f x f x

f xcond f x x x

f x

− = −

≤ ⋅ ⋅ −

Page 15: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

Evaluate the forward error, backward error and the condition number:

( ) ( ) ( )( ) ( )

( )( )( )

( ) ( ) ( )

ˆEvaluate function for approximate input instead ofthe true input , we have

Absolute forward error =

Relative forward error =

Condition number supx

f x x xx

f x x f x f x x

f x x f x f xx

f xf x

f x x f x f xxΔ

= + Δ

′+ Δ − ≈ Δ

+ Δ − ′≈ Δ

+ Δ −=

Δ( )( )

f xx

x f x′

Page 16: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

In what condition the backward error can be controlled?

( )( )Clearly, when ,

cond ff x

< ∞⎧⎪⎨ < ∞⎪⎩

ˆ 0x x

f fx−

→ ⇔ →

( ) ( ) ( ) ( )

( )( ) ( )( )

( ) ( ) ( ) ( )

2

ˆ

12

ˆ when ~ .

f x f x f x f x

f x x x f x x x

x xf x f x f x cond f x x

x

− = −

′ ′′= − + −

−⇒ − ≈ ⋅

Consider:

Moreover, the backward error can be estimated by

Relative forward errorRelative backward Condition number

Page 17: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

An algorithm is said to be well-posed if or well-conditioned if f̂

ˆ( ) for all xcond f x<< ∞

Relative error in the solution (output) is insensitive to the relative small change in the input.

A problem f is said to be well-posed if or well-conditioned if

( ) for all xcond f x<< ∞

A problem f or an algorithm is said to be stable if the

relative backward error is smallf̂

Accurate numerical solution can be obtained only when a problem and computational algorithm are well-conditioned and stable

Page 18: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

example2

Page 19: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung
Page 20: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

( ) 2

2

tan sec tan2 2 22

condπ ε

π π π πε ε ε ε ε−

⎛ ⎞ ⎛ ⎞≈ − − − ≈ −⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠

The reason is as following:

example3

Page 21: An introduction of Scientific Computingctw/Scientific... · An introduction of Scientific Computing Institute of Mathematics Modelling and Scientific Computing National Chiao-Tung

Example 4

( ) ( )( ) ( ) ( )

( )

2-x 2

0

ˆConsider approximating =e by 1 ˆ ˆ ˆFor 1 , we have , this implies ln .

1 lnClearly, the backward error at x=1 is lim

1

ˆThe approximation to is unstable near x=1.

f x f x x

x f x f x x

f f

ε

ε ε ε

ε ε

ε→

= −

= − = = = −

− − −= ∞

Exercise: Estimate the backward error by the formula given at p.11.Could you explain why the estimation is nothing close to the real error?