an introduction of scientific computingctw/scientific... · an introduction of scientific computing...
TRANSCRIPT
An introduction of Scientific Computing
Institute of Mathematics Modelling and Scientific Computing
National Chiao-Tung University
Chin-Tien Wu
Why scientific computing?
• Simulation of natural phenomena• Virtual prototyping of engineering designs• More insights from unknown phenomenon• Much more
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
What should be cared in scientific computing?
Sources of approximation
Example 1
Error measurement
Where numerical errors come from?
More about error (I)
More about the error (II)
• Condition number of a problem f at value x:
( ) ( ) ( )ˆ
ˆ( ) 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
− = −
≤ ⋅ ⋅ −
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′
≈
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
≈
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
example2
( ) 2
2
tan sec tan2 2 22
condπ ε
π π π πε ε ε ε ε−
⎛ ⎞ ⎛ ⎞≈ − − − ≈ −⎜ ⎟ ⎜ ⎟⎝ ⎠ ⎝ ⎠
The reason is as following:
example3
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?