chapter 1 introductory concepts and calculus review

40
1 Chapter 1 Chapter 1 Introductory Introductory Concepts and Concepts and Calculus Review Calculus Review

Upload: gregory-bernard

Post on 30-Dec-2015

78 views

Category:

Documents


4 download

DESCRIPTION

Chapter 1 Introductory Concepts and Calculus Review. Introduction. The subjects The derivation of the algorithms The implementation of the algorithms Analyze the algorithms mathematically Accuracy, efficiency, and stability. 1.1 Basic Tools of Calculus. 1.1.1 Taylor ’ s Theorem. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 1  Introductory Concepts and Calculus Review

1

Chapter 1 Chapter 1 Introductory Introductory

Concepts and Concepts and Calculus ReviewCalculus Review

Page 2: Chapter 1  Introductory Concepts and Calculus Review

2

IntroductionIntroduction

The subjectsThe subjects The derivation of the algorithmsThe derivation of the algorithms The implementation of the algorithmsThe implementation of the algorithms Analyze the algorithms mathematicallyAnalyze the algorithms mathematically

Accuracy, efficiency, and stabilityAccuracy, efficiency, and stability

Page 3: Chapter 1  Introductory Concepts and Calculus Review

3

1.1 Basic Tools of Calculus1.1 Basic Tools of Calculus

1.1.1 Taylor’s Theorem1.1.1 Taylor’s Theorem

Integral mean value

theorem

Page 4: Chapter 1  Introductory Concepts and Calculus Review

4

Three particular expansions of Three particular expansions of Taylor’s TheoremTaylor’s Theorem

...!3

)0(

!2

)0(

!1

)0(

!0

)0( 03

02

01

00

ex

ex

ex

ex

ex

where x0= ?

Page 5: Chapter 1  Introductory Concepts and Calculus Review

5

Three particular expansions of Three particular expansions of Taylor’s TheoremTaylor’s Theorem

where x0= 0

where x0= 0

Page 6: Chapter 1  Introductory Concepts and Calculus Review

6

Example : eExample : exx

]1,1[x

Finally, n can be found! (here n = 9)

If we wantthen

Let x0= 0

Page 7: Chapter 1  Introductory Concepts and Calculus Review

7

Example : eExample : exx

p2 (x)

p9 (x)

exp(x)

Page 8: Chapter 1  Introductory Concepts and Calculus Review

8

Example : eExample : exx

Page 9: Chapter 1  Introductory Concepts and Calculus Review

9

Example : eExample : exx

The result tells usThe result tells us We can approximate the exponential function We can approximate the exponential function

to within to within 1010-6-6 accuracy using a specific accuracy using a specific polynomial, and this accuracy holds for all polynomial, and this accuracy holds for all xx in in a specified interval.a specified interval.

Page 10: Chapter 1  Introductory Concepts and Calculus Review

10

Example 1.1Example 1.1 Let Let f f ((xx) = () = (xx+1)+1)1/21/2,, then the second-order Taylor then the second-order Taylor

polynomial (computed about polynomial (computed about xx00= 0= 0) is computed ) is computed as follows:as follows:

22

Page 11: Chapter 1  Introductory Concepts and Calculus Review

11

Example 1.2: sinExample 1.2: sin Function:Function: Accuracy:Accuracy:

Page 12: Chapter 1  Introductory Concepts and Calculus Review

12

Example 1.3: arctanExample 1.3: arctan Function:Function:

http://zh.wikipedia.org/wiki/File:Atan_acot_plot.svg

Page 13: Chapter 1  Introductory Concepts and Calculus Review

13

Example 1.3: arctanExample 1.3: arctan Function:Function:

Error term

Let

and

Page 14: Chapter 1  Introductory Concepts and Calculus Review

14

Example 1.3 : arctanExample 1.3 : arctan Please determine the error in a Please determine the error in a ninthninth-degree -degree

Taylor approximation to the arctangent function.Taylor approximation to the arctangent function. Since Since 22n n +1 = 9+1 = 9 implies that implies that n n = 4= 4, we have, we have

Page 15: Chapter 1  Introductory Concepts and Calculus Review

15

Taylor’s Theorem ExpansionTaylor’s Theorem Expansion

Let x x + h and x0 x

Page 16: Chapter 1  Introductory Concepts and Calculus Review

16

1.1.2 Mean Value and Extreme Value 1.1.2 Mean Value and Extreme Value TheoremsTheorems

http://en.wikipedia.org/wiki/Mean_value_theorem

Page 17: Chapter 1  Introductory Concepts and Calculus Review

17

1.1.2 Mean Value and Extreme Value 1.1.2 Mean Value and Extreme Value TheoremsTheorems

W

Page 18: Chapter 1  Introductory Concepts and Calculus Review

18

1.1.2 Mean Value and Extreme Value 1.1.2 Mean Value and Extreme Value TheoremsTheorems

M m

Critical point

Critical point

Page 19: Chapter 1  Introductory Concepts and Calculus Review

19

1.1.2 Mean Value and Extreme Value 1.1.2 Mean Value and Extreme Value TheoremsTheorems

The integral mean value theorem (a corollary of the intermediate value theorem) states that a function continuous on an interval takes on its average value somewhere in the interval. More exactly, if  is continuous on       , then there exists  in        such that                         .

Page 20: Chapter 1  Introductory Concepts and Calculus Review

20

1.1.2 Mean Value and Extreme Value 1.1.2 Mean Value and Extreme Value TheoremsTheorems

Page 21: Chapter 1  Introductory Concepts and Calculus Review

21

1.2 Error, Approximate Equality, and 1.2 Error, Approximate Equality, and Asymptotic Order NotationAsymptotic Order Notation

1.2.1 Error1.2.1 Error AA : a quantity( : a quantity( 數量數量 ) we want to compute) we want to compute AAhh: an approximation(: an approximation( 近似值近似值 ) to that quantity) to that quantity

Relative error (Relative error ( 相對誤差相對誤差 ) is better.) is better. These errors are both computational errors.These errors are both computational errors.

Page 22: Chapter 1  Introductory Concepts and Calculus Review

22

1.2.2 Notation: Approximate 1.2.2 Notation: Approximate EqualityEquality

Approximate equalityApproximate equality

It is an equivalence relation, and satisfy the folIt is an equivalence relation, and satisfy the following properties:lowing properties: Transitive(Transitive( 遞移性遞移性 ):): Symmetric(Symmetric( 對稱性對稱性 ):): Reflexive(Reflexive( 反身性反身性 ):):

Page 23: Chapter 1  Introductory Concepts and Calculus Review

23

1.2.3 Notation: Asymptotic Order 1.2.3 Notation: Asymptotic Order (Big O)(Big O)

Page 24: Chapter 1  Introductory Concepts and Calculus Review

24

Example 1.4Example 1.4

LetLet

Simple calculus shows that Simple calculus shows that

so that we haveso that we have HereHere

Page 25: Chapter 1  Introductory Concepts and Calculus Review

25

1.2.3 Notation: 1.2.3 Notation: Asymptotic Order (Big O) Asymptotic Order (Big O)

Page 26: Chapter 1  Introductory Concepts and Calculus Review

26

Example 1.6Example 1.6

Page 27: Chapter 1  Introductory Concepts and Calculus Review

27

Page 28: Chapter 1  Introductory Concepts and Calculus Review

28

1.3 A Primer on Computer Arithmetic1.3 A Primer on Computer Arithmetic

Computer arithmetic is generally Computer arithmetic is generally inexact.inexact. While the errors are very small, they can While the errors are very small, they can

accumulate and dominate the calculation.accumulate and dominate the calculation. Example: floating-point arithmeticExample: floating-point arithmetic

Reference: An Introduction to Computer Science, Reference: An Introduction to Computer Science, Chapter 3, Excess System (Excess_127 or Chapter 3, Excess System (Excess_127 or Excess_1023)Excess_1023)

is the sign of the number, f is the fraction (0 <= f <= 1),is the base of the internal number system

Page 29: Chapter 1  Introductory Concepts and Calculus Review

IEEE standards for floating-point representation

(底數 尾數)(底數 尾數)

Page 30: Chapter 1  Introductory Concepts and Calculus Review

Example Example

Show the representation of the normalized number + 26 x 1.01000111001

SolutionSolution

The sign isThe sign is positivepositive. The Excess_127 representation of . The Excess_127 representation of the exponent is the exponent is 133133. You add extra 0s on the . You add extra 0s on the right right to to make it 23 bits. The number in memory is stored as:make it 23 bits. The number in memory is stored as:

00 1000010110000101 0100011100101000111001000000000000000000000000

Page 31: Chapter 1  Introductory Concepts and Calculus Review

31

ErrorsErrors

Rounding error v.s. chopping errorRounding error v.s. chopping errorRounding: Rounding: 四捨五入四捨五入Chopping: Chopping: 無條件捨去無條件捨去Discussion:Discussion:

Rounding is more accurate but chopping is fastRounding is more accurate but chopping is faster.er.

The chopping error is indeed lager than the rouThe chopping error is indeed lager than the rounding error.nding error.

Page 32: Chapter 1  Introductory Concepts and Calculus Review

32

ExampleExample

Rounding errorRounding error

Chopping errorChopping error

Page 33: Chapter 1  Introductory Concepts and Calculus Review

33

Subtractive CancellationSubtractive Cancellation

If If aa and and bb are accurate to 16 decimal digits. are accurate to 16 decimal digits. What about their difference What about their difference cc = = aa - - bb ? ?

Example: Example:

The result The result cc is accurate to 12 digits. is accurate to 12 digits. This is because we were subtracting two This is because we were subtracting two

nearly equalnearly equal numbers. numbers.

0050009999990000.02)1000/1( eb

9983339999000049.02)100/1( ea

Page 34: Chapter 1  Introductory Concepts and Calculus Review

34

ExampleExample

Function :Function :

We know that :We know that :

Taylor’s Theorem : Taylor’s Theorem :

Page 35: Chapter 1  Introductory Concepts and Calculus Review

35

…………

Page 36: Chapter 1  Introductory Concepts and Calculus Review

36

1.5 Simple Approximations1.5 Simple Approximations

Error function: Error function:

(probability theory)(probability theory) It isIt is notnot possible to evaluate this integral by possible to evaluate this integral by

means of the fundamental theorem of calculus.means of the fundamental theorem of calculus. Use Taylor’s Theorem to approximate.Use Taylor’s Theorem to approximate.

wherewhere

Page 37: Chapter 1  Introductory Concepts and Calculus Review

37

Substitution: Substitution:

DefineDefine

So that we haveSo that we have

SetSet

where where cc depends on depends on tt andand

Page 38: Chapter 1  Introductory Concepts and Calculus Review

38

Apply the Integral Mean Value Theorem:Apply the Integral Mean Value Theorem:

The structured form:The structured form:

wherewhere

Page 39: Chapter 1  Introductory Concepts and Calculus Review

39

Use the big Use the big OO notation: notation:

Use the approximate equality notation:Use the approximate equality notation:

Simplify: Simplify: if the values of if the values of xx between between 00 and and 22

if if k k >=1>=1

thusthus

Page 40: Chapter 1  Introductory Concepts and Calculus Review

40

Fundamental IdeaFundamental Idea

When confronted with a computation that When confronted with a computation that cannot be done exactly, we often replace cannot be done exactly, we often replace that relevant function with something that relevant function with something simpler that approximates it, and carry out simpler that approximates it, and carry out the computation exactly on the simple the computation exactly on the simple approximation.approximation.