users.isc.tuc.gr/~adelis/ENG407.

html users isc tuc gr/~adelis/ENG407 html

Lectures 1 2 L t 1-2

Dr A.I. Delis TUC 2010

Part 1 (Chapters 1-4)

1

Logistics
• Lectures: 09:00-11:00 Mon-Tue and Thu-Fri
announced the day before!!) (location will be

• Lab Sessions: Tue 11:00 – 13:00 (Lab Instructor : Marianna Papadomanolaki) • Textbook: Numerical Methods for Engineers by Steven C. Chapra and
Raymond P Canale McGraw Hill N Y 5th edition 2006 P. Canale, Hill, N.Y., edition, 2006.

• Office Hours: at the New Sciences Building: Department of Sciences
(Office 145.B.99)

• Course Evaluation (under negotiation!): Quizzes (30%), Assignments (25%) and a Final Exam (45%) (closed books closed notes) adelis@science.tuc.gr
Dr A.I. Delis TUC 2010

Part 1 (Chapters 1-4)

2

What are Numerical Methods?
Techniques by which mathematical p problems are formulated so that they can y be solved with arithmetic operations {+,-,*,/} {+ * /} that can then be performed by a computer.

Dr A.I. Delis TUC 2010

Part 1 (Chapters 1-4)

3

Numerical methods are extremely powerful problem-solving tools. numerical methods in order to be a better user. Numerical methods are an efficient vehicle for learning to use computers. Numerical methods provide a good opportunity for you to reinforce your understanding of mathematics.I. f f You need that in your life as an engineer or a scientist Part 1 (Chapters 1-4) 4 • • • • • Dr A. you must write your own program of numerical methods.Why You Need to Learn Numerical Methods? • During your career. Delis TUC 2010 . you may often need to use commercial computer programs (canned programs) that involve numerical methods You need to know the basic theory of methods. You will often encounter problems that cannot be solved by existing canned programs.

Delis TUC 2010 Part 1 (Chapters 1-4) 5 .Motivation (a) Pre-computer era (b) Computer era Dr A.I.

Dr A.. Delis TUC 2010 Part 1 (Chapters 1-4) 6 . also in curve fitting and differential equations. Experimental results are often of the first type. It occurs routinely in engineering contexts. Two types: regression and interpolation.I. structure. e. electric circuits.Problems to solve in this course Roots of equations: concerns with finding the value of a variable that satisfies a single nonlinear equation – especial valuable in engineering design where it is often impossible to explicitly solve design equations of parameters. (not in this course) Curve fitting: to fit curves to data points. They arise in all disciplines of engineering. Systems of linear equations: a set of values is sought that simultaneously satisfies a set of linear algebraic equations. Optimization: determine a value or values of an independent variable that correspond to a “best” or best optimal value of a function. It has many applications in engineering practice.g. Integration: determination of the area or volume under a curve or a surface. fluid networks.

Examples: steady-state distribution of temperature of a heated plate (two spatial dimensions) or the time-variable temperature of a heated rod (time and one spatial dimension).I.. Delis TUC 2010 Part 1 (Chapters 1-4) 7 . Partial differential equations: used to characterize engineering systems where the behavior of a physical quantity is couched in terms of the rate of change with respect to two or more independent variables. Dr A. Initial value and boundary value y y problems. because many physical laws are couched in terms of the rate of change of a quantity rather than the magnitude of the q g q y g quantity itself. fluid flows etc….Problems to solve (cont) Ordinary differential equations: very important in engineering practice.

without fundamental understanding of engineering problems. g g g p . they will be useless. •Computers are great tools. Delis TUC 2010 Part 1 (Chapters 1-4) 8 .Mathematical Modeling and Engineering Problem solving Chapter 1 •Requires understanding of engineering systems –By observation and experiment (empiricism) –Theoretical analysis and generalization y g These two are closely coupled (with a two way connection as one compliments the other). Dr A.I. however.

What is the relationship between mathematic modeling and engineering problem-solving? bl l i ? Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 9 .I.

• A mathematical model is represented as a functional p relationship of the form Dependent Variable =f independent forcing variables. functions • Dependent variable: Characteristic that usually reflects the state of the system • I d Independent variables: Dimensions s ch as time and space d t i bl : such along which the systems behavior is being determined • Parameters: reflect the system’s properties or composition system s • Forcing functions: external influences acting upon the system Part 1 (Chapters 1-4) 10 . parameters.

” • The model is formulated as F = m a (1. Delis TUC 2010 Part 1 (Chapters 1-4) 11 .2) F=net force acting on the body (N) m=mass of th object (kg) f the bj t (k ) a=its acceleration (m/s2) ( Dr A.An Example: Newton’s 2nd law of Motion Newton s • States that “the time rate change of momentum f y q gf g of a body is equal to the resulting force acting on it.I.

e.g.I. consequently. Delis TUC 2010 Part 1 (Chapters 1-4) 12 . results. a = m/F /F Dr A. – Finally it yields reproducible results consequently Finally.• F Formulation of N t ’ 2nd l l ti f Newton’s law h several has l characteristics that are typical of mathematical models of the physical world: – It describes a natural process or system in p y mathematical terms – It represents an idealization and simplification of reality (focuses on its essential manifestations). can be used for predictive purposes.

I. Dr A. • Complex models may not be solved exactly or Co p e ode s y o so ved e c y o require more sophisticated mathematical techniques than simple algebra for their solution. p g – Example modeling of a falling parachutist: Example.• Some mathematical models of physical phenomena may be much more complex. Delis TUC 2010 Part 1 (Chapters 1-4) 13 .

Delis TUC 2010 v=t terminal velocity ( / ) i l l it (m/s) t = time (s) m = mass of the object ( g) j (kg) g = gravitational constant (9.I.dv F d = dt m F = FD + FU FD = mg FU = −cv dv mg − cv g = dt m Dr A.81 m/s2) c = drag coefficient (kg/s) Part 1 (Chapters 1-4) 14 .

dv c =g− v dt m • This is a differential equation and is written in terms of the differential rate of change dv/dt of the variable that we are interested in predicting. Delis TUC 2010 ( ) Independent variable Parameters 15 Part 1 (Chapters 1-4) .I. • If the parachutist is initially at rest (v=0 at t=0). using calculus we get an analytical (or exact) solution gm −( c / m ) t v(t ) = 1− e c Dependent variable Forcing function Dr A.

Dr A. The exact solution for differential equation can be solved using calculus or by g y approximation using numerical methods.• Solution for differential equation cannot always be solved analytically using simple algebraic solution solution. Delis TUC 2010 Part 1 (Chapters 1-4) 16 .I.

For steady-state condition in falling parachute.I. dv =0 dt mg v= c Dr A. We have thus. Delis TUC 2010 Part 1 (Chapters 1-4) 17 .

Eq. e c ge s o e s e (s e dy s e). Change = increases – decreases (1.I. i li h ih i ( i ) • If the change is nonexistent (steady-state).13) becomes Increases =Decreases I D Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 18 .Conservation Laws and Engineering • Conservation laws are the most important and g g fundamental laws that are used in engineering. (1.13) • Ch Change implies changes with time (transient).

momentum and energy Dr A.6 • For steady-state incompressible fluid flow in pipes: Flow in = Flow out or 100 + 80 = 120 + Flow4 Flow4 = 60 In general we are interested in conservation of mass. Delis TUC 2010 Part 1 (Chapters 1-4) 19 .Fig 1.I.

Delis TUC 2010 Part 1 (Chapters 1-4) 20 .I. y • Large vs small systems: With computers and numerical methods large scale and multi-component systems can be g p y examined. • Ideal vs nonideal laws: engineering. nonideal laws computationally demanding.Practical issues in engineering applications • Linearity vs Nonlinearity: Linearization in order to p permit analytical solutions. Idealized laws abound in are more realistic but • Sensitivity Analysis: how a system responds to different • Design: determine a systems parameters to a required performance. Dr A. p y g conditions.

Delis TUC 2010 Part 1 (Chapters 1-4) 21 . it is important that they should be able to do both! Dr A. There are two ways in g p using computers: – Use available software – Or write computer programs to extend the Or.Programming and Software g g Chapter 2 • Objective is how to use the computer as a tool g to obtain numerical solutions to a given engineering model. such as Excel and Matlab. capabilities of available software.I. • Engineers should not be tool limited.

• To be able to perform engineering-oriented numerical calculations. Delis TUC 2010 Part 1 (Chapters 1-4) 22 . . and intrinsic functions) – Input/Output – Logical representation (sequence. Dr A. and type p f p ( . selection. you should b f ili l l ti h ld be familiar with th f ll i ith the following programming topics: – Simple information representation (constants. assuming that you have some prior exposure to programming. yp declaration) – Advanced information representation (data structure. arrays. priority rules. and repetition) – Modular programming (functions and subroutines) • We will focus the last two topics.I. and records) – Mathematical formulas (assignment. variables.• Computer programs are set of instructions that direct the p p g computer to perform a certain task.

I. test. Easily sharable Easy to debug and test Requires shorter time to develop. Delis TUC 2010 Part 1 (Chapters 1-4) 23 . and repetition Dr A.Structured Programming • Structured programming is a set of rules that prescribe god style habits for programmer. selection. – – – – An organized well structured code organized. and update • Th k id i th t any numerical algorithm can The key idea is that i l l ith be composed of using the three fundamental structures: t t – Sequence.

I.Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 24 .

The structure can be expressed as a flowchart or pseudocode. Delis TUC 2010 Part 1 (Chapters 1-4) 25 . unless you instruct y otherwise. Dr A.I.• Sequence: Computer code must be implemented one p instruction at a time.

• Selection: Splits the program’s flow into branches based on b d outcome of a logical condition condition. Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 26 .I.

Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 27 .• Repetition: means to implement instructions repeatedly.I.

that can be developed and tested separately. • Modules should b as i d d l h ld be independent and self contained d d lf i d as possible. or modules. • Advantages to modular d i are: d d l design – It is easier to understand the underlying logic of smaller modules – They are easier to debug and test – Facilitate program maintenance and modification – Allow you to maintain your own library of modules for later use Part 1 (Chapters 1-4) 28 .Modular Programming • The computer programs can be divided into subprograms.

Delis TUC 2010 Part 1 (Chapters 1-4) 29 . MATLAB® is closely related to programming programming. Dr A.I.Programming and Software We W are going to use the computer as a i t th t tool to obtain numerical solutions to a given engineering model. Selected soft are MATLAB® softwareMATLAB® is originally developed as a matrix laboratory.

Delis TUC 2010 Part 1 (Chapters 1-4) 30 . 4) Check th answers MATLAB® gave Ch k the and make sure you understand them. 3) Try any other exercises.I.Familiar yourself with MATLAB® !! How to do it?? 1) Install MATLAB® software in your notebook. Dr A. 2) Explore yourself the Appendix B in Chapra ( ) and Canale (2006).

Dr A.I. Delis TUC 2007 Part 1 (Chapters 1-4) 31 .

Approximations and Round-Off Errors pp Chapter 3 • F many engineering problems. unavoidable round-offs. Therefore there is probably error in the input information. • Numerical methods yield approximate results.I. We cannot exactly compute the errors associated with numerical methods. – Only rarely given data are exact. we cannot obtain analytical For i i bl t bt i l ti l solutions. e. results that y pp . Delis TUC 2010 Part 1 (Chapters 1-4) 32 . – Algorithm itself usually introduces errors as well.. • How confident we are in our approximate result? • The question is “how much error is present in our calculation and is it tolerable?” tolerable? Dr A. s ce t ey o g ate o measurements. etc … – The output information will then contain error from both of these sources. since they originate from O y a e y g ve a e e act. are close to the exact analytical solution.g.

A systematic deviation from the actual value value. Dr A. p • Inaccuracy (or bias). How close is a computed or measured value to the true value • Precision (or reproducibility).I. Delis TUC 2010 Part 1 (Chapters 1-4) 33 .• Accuracy. Magnitude of scatter. • Imprecision (or uncertainty). How close is a computed or measured value to previously computed or measured values.

Delis TUC 2010 Part 1 (Chapters 1-4) 34 .I.Accuracy? Inaccuracy? Precision? Imprecision? I i i ? Dr A.

Numerical errors rise… Numerical error equal to discrepancy between pp the truth and approximation: true error E t = t r u e v a l u e − a p p r o x i m a ti o n True percent relative error. we use approximation .In numerical methods. t r u e e r r o r ×100% εt = tr u e v a l u e Dr A. Delis TUC 2010 εt Part 1 (Chapters 1-4) 35 .I. pp to represent the exact mathematical operations.

Delis TUC 2010 Part 1 (Chapters 1-4) 36 . ε t = true value Dr A.I.Error Definitions True Value = Approximation + Error Et = True value – Approximation ( / ) (+/-) True error true error True fractional l ti T f ti l relative error = true value true error ×100% True percent relative error.

If we cannot solved the problem analytically to get the true value. ε a c u r r e n t a p p r o x . Delis TUC 2010 Part 1 (Chapters 1-4) 37 . how to calculate its true error? We normalize the error to approximate value.. Dr A. made on the basis of a previous approximation.×100% εa = c u rr e nt a p p r o x.p r e v i o u s a p p r o x .I. Numerical methods use iterative approach to compute answers A present approximation is answers. Percent relative error.

In real world applications.I. y answer a priori. Then Approximate error A i t εa = ×100% pp Approximation • Iterative approach.Previous approximation εa = ×100% Current approximati C t i tion Dr A. the true value will be known only when we deal with functions that y can be solved analytically (simple systems). example Newton’s method Current approximation . Delis TUC 2010 Part 1 (Chapters 1-4) 38 .• For numerical methods. we usually not know the pp .

The ε a may be in + or – signs. Delis TUC 2010 Part 1 (Chapters 1-4) 39 . εa < εs Dr A. But. The Th calculation should proceed until th l l ti h ld d til the absolute value of ε a lower than percent tolerance given. ε s .I. the most important is its absolute value value.

3….I.2.5×10 ( 2− n )% (See Example 3.2) Dr A. n= 1. . Delis TUC 2010 Part 1 (Chapters 1-4) 40 . εs = 0. .Result is correct/almost exact after the iteration to at least n significant figures.

• Use absolute value. • Computations are repeated until stopping criterion is satisfied. satisfied

ε a 〈ε s

Pre-specified % t l P ifi d tolerance b based d on the knowledge of your solution

• If the following criterion is met

ε s = (0.5 ×10(2-n) )%
you can be sure that the result is correct to at least n significant figures.
Dr A.I. Delis TUC 2010

Part 1 (Chapters 1-4)

41

Significant Figures g g
• Number of significant figures indicates precision. Significant digits of a number are those that can be used with confidence, e.g., the number of certain di i plus one estimated di i i digits l i d digit. 53,800 How many significant figures? 5.38 x 104 5.380 x 104 5.3800 x 104 3 4 5

Zeros are sometimes used to locate the decimal point not significant figures. 0.00001753 0 00001753 0.0001753 0.001753
Dr A.I. Delis TUC 2010

4 4 4
Part 1 (Chapters 1-4) 42

Type of errors: Round-off Errors Round off
• Numbers such as π, e, or 7 cannot be expressed by a fixed number of significant figures. • Computers use a base-2 representation, they cannot p precisely represent certain exact base-10 numbers. y p • Fractional quantities are typically represented in computer using “floating point” form, e.g., floating point
Integer part

m⋅ be
mantissa

exponent Base of the number system used

Dr A.I. Delis TUC 2010

Part 1 (Chapters 1-4)

43

Figure 3.3 Dr A.I. Delis TUC 2010 Part 1 (Chapters 1-4) 44 .

I.4 Representation of the decimal integer -173 on a 16-bit computer Dr A.Figure 3. Delis TUC 2010 Part 1 (Chapters 1-4) 45 .

I.5 The manner in which a floating point number is stored Dr A.Figure 3. Delis TUC 2010 Part 1 (Chapters 1-4) 46 .

2941 x 10-1 Additional significant figure is retained Part 1 (Chapters 1-4) 47 Dr A.I. Delis TUC 2010 .15678x103 in a floating point base-10 system Suppose only 4 1 = 0.029411765 decimal places to be stored 34 1 0 0.156.78 0.0294×10 ≤ m <1 b • Normalized to remove the leading zeroes. g Multiply the mantissa by 10 and lower the exponent by 1 p y 0.

1 ≤m<1 01≤ 1 for a base-2 system 0.I.4 • Floating point representation allows both fractions and very l large numbers t b expressed on th computer. Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 48 .1 ≤ m <1 b Therefore for base-10 system f ab 10 t 0. b to be d the t However.5 ≤m<1 See example 3. – Floating point numbers take up more room room. – Take longer to process than integer numbers. – Round-off errors are introduced because mantissa Round off holds only a finite number of significant figures.

t b1-t is called the machine epsilon epsilon. Delis TUC 2010 Part 1 (Chapters 1-4) 49 .I.g. irrational numbers) Dr A. • Limited range of quantities that may be represented g q y p (overflow and underflow may occur) • Fi it number of quantities can b represented within th Finite b f titi be t d ithi the range (precision is limited e.Significance of floating point representation • “Strange” behavior of the machine numbers 1+x 1 = 1 !!! E = For F x ≤ b1.

14159265358 to be stored on a base-10 system y g g g carrying 7 significant digits. Since number of significant figures is large enough. π=3. Dr A.00000065 If rounded π=3.Type of errors: Chopping Example: p π=3.141592 chopping error εt=0.141593 εt=0. because rounding adds chopping to the computational overhead. resulting chopping error is negligible.00000035 • Some machines use chopping.I. Delis TUC 2010 Part 1 (Chapters 1-4) 50 .

Types of errors: T T f Truncation error ti Truncation errors are th T ti those th t result f that lt from using an approximation in place of an exact mathematical procedure. Dr A.I. Delis TUC 2010 Part 1 (Chapters 1-4) 51 .

The T l 4 i Th Taylor series Chapter A mathematical formulation that used widely in numerical methods to predict a function value i approximate f hi f ti l in i t fashion. Why it is called in series? It’s build term by term. The higher the order of approximation applied the lower the applied. started with zero-order y . truncation error.I. Dr A. Delis TUC 2010 Taylor Series y Part 1 (Chapters 1-4) 52 . approximation.

• Any smooth function can be approximated as a polynomial.• Non-elementary functions such as trigonometric. and integrals are computed. and others are expressed in an approximate fashion using Taylor series when their pp g y values. y g . exponential. Delis TUC 2010 Part 1 (Chapters 1-4) 53 . Dr A.I. polynomial Taylor series provides a means to predict the value of a function at one point in terms of the function value and its derivatives at another point. derivatives.

Rn.nth order approximation f ′′ 2 ′( xi )( xi +1 − xi ) + f ( xi +1 ) ≅ f ( xi ) + f ( xi +1 − xi ) + … 2! f (n) ( xi +1 − xi ) n + Rn + n! n! (xi+1-xi)= h ( n +1) step size (define first) f (ε ) ( n +1) Rn = h (n + 1)! • R i d term. Delis TUC 2010 Part 1 (Chapters 1-4) 54 .I. accounts for all terms Reminder t t f ll t from (n+1) to infinity. Dr A.

Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 55 .I.

I. First order First-order approximation: f ( xi +1 ) ≅ f ( xi ) + f ' ( xi )( xi +1 − xi ) The additional term consist of a slope multiply the distance between x i and x i + 1 . Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 56 .Zero-order approximation: f ( xi +1 ) ≅ f ( xi ) Additional terms of the Taylor series are required to provide a better estimate.

.Second-order approximation: f ' ' (xi ) 2 f (xi+1) ≅ f (xi ) + f ' (xi )(xi+1 − xi ) + (xi+1 − x1) 2! and so on… d f ' ' (xi ) 2 f (xi+1) ≅ f (xi ) + f ' (xi )(xi+1 − xi ) + (xi+1 − xi ) 2! (3) (n) f (xi ) f (xi ) n 3 + (xi+1 − xi ) +.. Delis TUC 2010 Part 1 (Chapters 1-4) 57 .. + (xi+1 − xi ) + Rn 3! n! where Rn is the remainder term Dr A...I.....

..I.. Delis TUC 2010 Part 1 (Chapters 1-4) 58 . + h + Rn n! 3! Dr A. hence....Remainder term: f n+1 (ξ ) n+1 Rn = ( xi +1 − x1 ) (n + 1)! where ξ is a value lies between xi and xi +1 Simplifying h = ( x i + 1 − x i ) ... f ' ' ( xi ) 2 f ( x i +1 ) ≅ f ( x i ) + f ' ( x i ) h + h 2! (3) (n) f ( xi ) 3 f ( xi ) n + h + ..

• Need to determine f n+1(x).I. t ti is • O(h).• ε i not k is known exactly. to do this you need ( ) f'(x). (n+1)th order. the order of truncation error i hn+1. li l lies somewhere h between xi+1>ε >xi . there wouldn’t be any need to perform the Taylor series expansion expansion. • If we knew f(x). R=O(hn+1). Delis TUC 2010 Part 1 (Chapters 1-4) 59 . halving the step size will halve the error. halving the step size will quarter the error. • O(h2). • However. Dr A.

Example: To get the cos(x) for small x: x2 x4 x6 cos x = 1 − + − + 2! 4! 6! If x=0.5 ( ) cos(0. is no greater than the first omitted term. x8 ∴ 8! Dr A.0026041-0.125+0.I. Delis TUC 2010 for x = 0.0000127+ … =0.0000001 Part 1 (Chapters 1-4) 60 .5) =1-0.877582 From the supporting theory. for this series the error theory series.5 = 0.

Fig 4 2 4. Delis TUC 2007 Part 1 (Chapters 1-4) 61 .I.2 Dr A.

Delis TUC 2010 Part 1 (Chapters 1-4) 62 .I. Dr A.How to solve the derivatives of an equation given using Taylor series? We use an approximation using numerical differentiation with: a) F ) Forward divided diff d di id d difference b) Backward divided difference c) Centered divided difference They Th are d developed f l d from th T l series the Taylor i to approximate derivatives numerically.

Dr A.I. Delis TUC 2010 Part 1 (Chapters 1-4) 63 .a) Forward divided diff )F d di id d difference (1stt d i ti ) derivative) f ( xi +1 ) − f ( xi ) f ' ( xi ) = + O ( h) xi +1 − xi where h O (h) = f (2) ( xi )( xi +1 − xi ) 2! O (h ) is an truncation error.

Delis TUC 2010 f ( 3) ( xi )( xi +1 − xi ) 2 O (h 2 ) = 3! Part 1 (Chapters 1-4) 64 .b) Backward divided difference (1st derivative) ) ( ) f ( xi ) − f ( xi −1 ) f ' ( xi ) = xi − ( xi −1 ) c) Centered divided difference (1st derivative) f ( xi +1 ) − f ( xi −1 ) f ' ( xi ) = + O(h 2 ) 2( xi +1 − xi ) where h Dr A.I.

Delis TUC 2010 Part 1 (Chapters 1-4) 65 .6 Dr A.Fig 4 6 4.I.

Because a computer can hold a finite number of significant figures for a given number there number. Th i t t ti The error is determined by the precision of the computer (ε). may be an error (round-off error) associated with th fl ti ith the floating point representation.I.Error Propagation • fl(x) refers to the floating point (or computer) p representation of the real number x. Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 66 .

dropping the second and higher order terms f ( x) − f ( x fl ) ≅ f ′( x fl )( x − x fl ) Dr A.• Suppose that we have a function f(x) that is dependent on a single independent variable x. Delis TUC 2010 Part 1 (Chapters 1-4) 67 . fl(x) is an approximation of x and we would like to estimate the effect of discrepancy between x and fl(x) on the value of the function: Δf ( x fl ) = f ( x) − f ( x fl ) both f(x) and xfl are unknown Employ Taylor series to compute f(x) near f(x fl ).I.

I.Fig 4 7 4. Delis TUC 2007 Part 1 (Chapters 1-4) 68 .7 Dr A.

be the error associated with fl(x). we get fl ( x) − x = ε t x f fl ( x) = x(ε t + 1) Dr A. Delis TUC 2010 Part 1 (Chapters 1-4) 69 .I. epsilon upper boundary Rearranging. Then fl ( x) − x x = εt where ε t ≤ ε Machine epsilon.Also. the fractional relative error. let εt.

Delis TUC 2010 εt Part 1 (Chapters 1-4) 70 .I.• Case 1: Addition of x1 and x2 with associated errors εt1 and εt2 yields the following result: d i ld th f ll i lt fl(x1)=x1(1+εt1) fl(x2)=x2(1+εt2) fl(x1)+fl(x2)=εt1 x1+εt2 x2+x1+x2 fl ( x1 ) + fl ( x2 ) − ( x1 + x2 ) ε t1 x1 + ε t 2 x2 = = 100% x1 + x2 x1 + x2 •A large error could result from addition if x1 and x2 are A almost equal magnitude but opposite sign. therefore one should avoid subtracting nearly equal numbers. numbers Dr A.

). Dr A. x3. E Eti ≤E fl(xi)-E ≤ xi ≤ fl(xi)+E It f ll follows by addition that b dditi th t ∑ fl ( x ) − nE ≤ ∑ x ≤ ∑ fl ( x ) + nE i i i So that − nE ≤ ∑ xi − ∑ fl ( xi ) ≤ nE Therefore.• Generalization: Suppose the numbers fl(x1) fl(x2) fl(x3) …. approximations to x1. … . ).I. Delis TUC 2010 Part 1 (Chapters 1-4) 71 . x2. fl(xn) are ). the maximum possible error in the sum of fl(xi) is nE .xn and that in each case the maximum possible error is E.

• Case 2: Multiplication of x1 and x2 with associated errors et1 and et2 results in: fl ( x1 ) fl ( x2 ) = x1 (1 + ε t1 ) x2 (1 + ε t 2 ) fl ( x1 ) fl ( x2 ) = x1 x2 (ε t1ε t 2 + ε t1 + ε t 2 + 1) fl ( x1 ) fl ( x2 ) − x1 x2 = = ε t1ε t 2 + ε t1 + ε t 2 100% x1 x2 εt Dr A.I. Delis TUC 2010 Part 1 (Chapters 1-4) 72 .

• Refer to Table 4. The magnitude of error associated with a calculation is directly proportional to the number of multiplication steps.• Since εt1. εt2 are both small. the error g . the term εt1εt2 should be small relative to εt1+εt2. if 1000 calculations were done. Thus the magnitude of the error associated with one multiplication or division step should be εt1+εt2. is then approximately 1000ε. . Delis TUC 2010 Part 1 (Chapters 1-4) 73 .3 Dr A.I. εt1 ≤ε (upper bound) • Although error of one calculation may not be significant.

Dr A.• Overflow: Any number larger than the largest number that can be e pressed on a comp ter will res lt in an o erflo expressed computer ill result overflow. it is likely that many round-offs will be made. • Underflow (Hole) : Any positive number smaller than the smallest number that can be represented on a computer will result an underflow. Delis TUC 2010 Part 1 (Chapters 1-4) 74 . When accumulation is devastating and th solution i overwhelmed b th error. are called “stable” algorithms. i d t ti d the l ti is h l d by the such algorithms are called unstable. • Stable Algorithm: In extended calculations.I. so that a useful result is generated. Algorithms for which the cumulative effect of all such errors are limited. impacting the eventual output. Each of these plays the role of an input error for the remainder of the computation.

εt .4 x − 0. (x 0.14 x − 1. backward and centered difference approximations t estimate the first derivative.1x − 0. The derivative can be calculated directly as f ' ( x) = −0. Dr A.Try for yourself … Given Gi f ( x) = −0.25 3 2 and can be used to compute the exact value as f ' ( x) =-0. Delis TUC 2010 Part 1 (Chapters 1-4) 75 .5 x − 0.I.25.15 x − 0.9125. i ti to ti t th fi t d i ti b) Calculate the true percent relative error.0 x − 0.25 x + 1.9125. a) Use forward.2 4 3 2 at x =0.

HOMEWORK 1 Chapra and Canale (2006): Problems 3.1.3.3.6.7 Dr A.3.2.4.1.4.4. Delis TUC 2010 Part 1 (Chapters 1-4) 76 .2.10 Problems 4.I.4.7.3.6.4.

data . 4. and Speed of Computer Program Development Cost vs Software Cost Characteristics of the Numerical Method: 1.) Dr A. Cost. 6. 3. Number of Initial Guesses Rate of Convergence g Stability (of numerical algorithm) Accuracy and Precision Breadth of Application Special Requirements Programming Effort • Maintenance (of programming codes) • Ease of Application (user-friendly?) • Mathematical Behavior:(Ill or Well-) Conditioned (function.Trade-offs… • • • • Type of Mathematical Problem (Model) Type. 7. Delis TUC 2007 Part 1 (Chapters 1-4) 77 . 2.I.. Availability. 5.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.