550 likes | 560 Views
This chapter provides an introduction to scientific computing, including an overview of computational errors and how they propagate in basic arithmetic operations. It discusses the importance of numerical analysis and its application to various scientific disciplines. The chapter also explores the concept of truncation error and the Taylor theorem.
E N D
Chapter 1Introduction Prof. Chuan-Ming Liu MCSE Lab, NTUT TAWIAN MCSE Lab, NTUT
Outline • Scientific Computing • Computational Errors • Error Propagation • Error Propagation in Basic Arithmetic Operations MCSE Lab, NTUT
Scientific Computing Scientific computing The interface of Computer Science, Engineering and Applied Mathematics. MCSE Lab, NTUT
Scientific Computing • People want the methods to be fast and accurate. • Applications of Scientific Computing • Fluid dynamics • Material science • Semiconductor device simulation • Weather modeling • Computational biology • Econometrics and computational finance • Computer graphics MCSE Lab, NTUT
Scientific Computing • In this course, we will consider the time complexity and accuracy for the solutions to some problems. • Time complexity relates to the algorithm analysis. • Accuracy relates to mathematic analysis. MCSE Lab, NTUT
Scientific Computing • Why do we need numerical analysis (methods)? • It is all about the reality. • Example: consider a 3D solid if revolution can be created by revolving the curve y = r(x) about the x-axis. MCSE Lab, NTUT
y y = r(x) x z Scientific Computing • If r(x) is simple, e.g. r(x) = ex , then close form solution MCSE Lab, NTUT
Scientific Computing • If r(x) is not simple, for example it is not possible to get the close form: MCSE Lab, NTUT
Scientific Computing • Numerical analysis then comes in. • To obtain the (approximated) value of V, we can subdivide the interval [0, 1] into n equal subintervals as MCSE Lab, NTUT
Scientific Computing • Rewrite the integration into the sum MCSE Lab, NTUT
constructing solving Physicalphenomena Mathematical models Mathematical solutions explanation or prediction Scientific Computing • Note: what we did here is the rectangular rule, we will discuss this rule later in this course. • In practice, many problems do not have a close form solution. MCSE Lab, NTUT
L θ m mgsinθ mg Scientific Computing • Example: motion of a pendulum L: string length θ: the angle, a function of time t. Using Newton’s second law, we can get the following model MCSE Lab, NTUT
Scientific Computing • Initial-value problems MCSE Lab, NTUT
Scientific Computing • The general solution MCSE Lab, NTUT
Scientific Computing MCSE Lab, NTUT
Scientific Computing • Note: • Note: This close form is inaccurate when θdoes not approach to 0. MCSE Lab, NTUT
Scientific Computing • Discussion on the first example (Integration) • discretization • discretization error • how the error is OK • efficiency • The scientific computing is used to denote the use of numerical methods in a complex hardware and software environment to solve models from various scientific disciplines. MCSE Lab, NTUT
3 Ω 5 Ω 1 2 100 v 10 Ω a 2 Ω 6 Ω 1 Ω 3 b 1 Ω 7 Ω 0 v 6 5 4 Scientific Computing • Example: consider the electrical network obtain the voltages at nodes 1 through 6. MCSE Lab, NTUT
Scientific Computing MCSE Lab, NTUT
Scientific Computing MCSE Lab, NTUT
Scientific Computing MCSE Lab, NTUT
Scientific Computing MCSE Lab, NTUT
Scientific Computing • In this course, we will learn many numerical methods as well as how to tell a method is good or not. First of all, we start with the “computational error”. MCSE Lab, NTUT
Computational Errors • The computational error comes from: • Machine representation • Number representation • Round off errors • Rounding • Chopping • Rounding up • Rounding down • Formula for the problem • Truncation error MCSE Lab, NTUT
0 ∞ -∞ real number Computational Errors • Roundoff errors • finite precision numbers present infinite precision numbers • The result of an operation on two machine-representable numbers is not necessarily a machine-representable number. MCSE Lab, NTUT
Computational Errors 11 digits e.g. : a = 9.99*104 and b = 9.99*10-4 a + b = (9.99+9.99*10-8)*10-4 =9.9900000999*104. Suppose the machine only computes to 6-digits.Then, a + b = 9.99*104 =>b has no effect !! (why ?) However, a/b = 108 a*b = 99.8001 are still valid (why ?) The reason will be discussed later 6-digit representation is OK with the result MCSE Lab, NTUT
Truncation error Computational Errors • Truncation error • Occurs when applying a formula MCSE Lab, NTUT
Please review how to calculate the derivatives for some common functions e.g. ex, sinx, logx Taylor Theorem MCSE Lab, NTUT
Taylor Theorem • Pn(x) is the nth Taylor polynomial for f about x0 • Rn(x) is the remainder term (or truncation error) associated with Pn(x). • The infinite series obtained by taking n ∞ is called the Taylor series for x about x0 • When x0 = 0, the Taylor polynomial is often called a Maclaurin polynomialand the Taylor series is called a Maclaurin series. MCSE Lab, NTUT
Taylor Theorem -Example • Determine (a) the second and (b) the third Taylor polynomials for f(x) = cosx about x0 = 0 and use these polynomials to approximate cos(0.01) • (a) MCSE Lab, NTUT
Taylor Theorem - Example (b) exercise. MCSE Lab, NTUT
Computational Errors approximation of derivative of function f. Let f be a function. Obtain the derivative at a where f is cont. on [a-h, a+h]. MCSE Lab, NTUT
Computational Errors MCSE Lab, NTUT
actual f ’(a) approximate f ’(a) a-h a a+h MCSE Lab, NTUT
Computational Errors • The more terms use to estimate, the more accurate the answer is MCSE Lab, NTUT
Computational Errors • Absolute v.s. relativeerrors • If P* is an approximation to P, • |P*-P| is the absolute error. • | P*-P |/|P| where |P|≠0 is the relative error. • Error tolerance • A computation is acceptable if the error (absolute or relative) is no more than a specific error tolerance. • |computed solution – exact solution| < tolerance i.e. | P*-P | < tol or |P*-P|/|P| < tol. MCSE Lab, NTUT
Computational Errors • Error tolerances should be part of the specifications of an algorithm. • High accuracy usually needs high cost! • Accuracy appr. MCSE Lab, NTUT
Computational Errors • The number of decimal places of accuracy, d, for fixed error, |error| = 10-dis given by d = -log10|error|, i.e. the approximation has d accurate decimal places. • example MCSE Lab, NTUT
Computational Errors MCSE Lab, NTUT
Computational Errors • example MCSE Lab, NTUT
Error Propagation • Error Propagation (overall) MCSE Lab, NTUT
Error Propagation MCSE Lab, NTUT
Error Propagation • Example: c = ? MCSE Lab, NTUT
Error Propagation • Sol. MCSE Lab, NTUT
Error Propagation • The sensitivity of a problem is indicated by the relative dependence of output error to input error. • Definition: MCSE Lab, NTUT
Error Propagation in Basic Arithmetic Operations • Error Propagation in Arithmetic Operations MCSE Lab, NTUT
Error Propagation in Basic Arithmetic Operations MCSE Lab, NTUT
(1+x)-1 = 1-x+x2+… Error Propagation in Basic Arithmetic Operations MCSE Lab, NTUT
Error Propagation in Basic Arithmetic Operations MCSE Lab, NTUT
Error Propagation in Basic Arithmetic Operations • Avoiding cancellation errors • Rationalization • Taylor expansion (two nearly equal numbers) MCSE Lab, NTUT