NUMERICAL ANALYSIS USING SCILAB: NUMERICAL STABILITY AND CONDITIONING

Similar documents
MODELING IN SCILAB: PAY ATTENTION TO THE RIGHT

DATA FITTING IN SCILAB

MODELING IN SCILAB: PAY ATTENTION TO THE RIGHT APPROACH PART 1

Mathematical preliminaries and error analysis

Computing Basics. 1 Sources of Error LECTURE NOTES ECO 613/614 FALL 2007 KAREN A. KOPECKY

Computational Methods. Sources of Errors

Numerical Computing: An Introduction

Truncation Errors. Applied Numerical Methods with MATLAB for Engineers and Scientists, 2nd ed., Steven C. Chapra, McGraw Hill, 2008, Ch. 4.

Discrete Optimization. Lecture Notes 2

Section Rational Functions and Inequalities. A rational function is a quotient of two polynomials. That is, is a rational function if

AM205: lecture 2. 1 These have been shifted to MD 323 for the rest of the semester.

Math 340 Fall 2014, Victor Matveev. Binary system, round-off errors, loss of significance, and double precision accuracy.

2 Computation with Floating-Point Numbers

Computer Arithmetic. 1. Floating-point representation of numbers (scientific notation) has four components, for example, 3.

CHAPTER 2 SENSITIVITY OF LINEAR SYSTEMS; EFFECTS OF ROUNDOFF ERRORS

New Mexico Tech Hyd 510

Floating point numbers in Scilab

2 Computation with Floating-Point Numbers

Uppsala University Department of Information technology. Hands-on 1: Ill-conditioning = x 2

CS321 Introduction To Numerical Methods

Honors Precalculus: Solving equations and inequalities graphically and algebraically. Page 1

Review Questions 26 CHAPTER 1. SCIENTIFIC COMPUTING

Floating-point representation

Module 2: Single Step Methods Lecture 4: The Euler Method. The Lecture Contains: The Euler Method. Euler's Method (Analytical Interpretations)

Limits. f(x) and lim. g(x) g(x)

You should be able to plot points on the coordinate axis. You should know that the the midpoint of the line segment joining (x, y 1 1

1) Complete problems 1-65 on pages You are encouraged to use the space provided.

2.1.1 Fixed-Point (or Integer) Arithmetic

STANDARDS OF LEARNING CONTENT REVIEW NOTES ALGEBRA II. 3 rd Nine Weeks,

Math Precalculus (12H/4H) Review. CHSN Review Project

Lecture notes on the simplex method September We will present an algorithm to solve linear programs of the form. maximize.

Lecture 25: Bezier Subdivision. And he took unto him all these, and divided them in the midst, and laid each piece one against another: Genesis 15:10

Scientific Computing: An Introductory Survey

MAT128A: Numerical Analysis Lecture Two: Finite Precision Arithmetic

MA 323 Geometric Modelling Course Notes: Day 10 Higher Order Polynomial Curves

Errors in Computation

College Algebra Exam File - Fall Test #1

MAT 003 Brian Killough s Instructor Notes Saint Leo University

Mathematics. Jaehyun Park. CS 97SI Stanford University. June 29, 2015

Homework 1 Introduction to Computational Finance Spring 2019

What Every Programmer Should Know About Floating-Point Arithmetic

x 16 d( x) 16 n( x) 36 d( x) zeros: x 2 36 = 0 x 2 = 36 x = ±6 Section Yes. Since 1 is a polynomial (of degree 0), P(x) =

Graphs and Linear Functions

10-2 Circles. Warm Up Lesson Presentation Lesson Quiz. Holt Algebra2 2

DOWNLOAD PDF BIG IDEAS MATH VERTICAL SHRINK OF A PARABOLA

CS 97SI: INTRODUCTION TO PROGRAMMING CONTESTS. Jaehyun Park

Introduction to numerical algorithms

International Journal of Emerging Technologies in Computational and Applied Sciences (IJETCAS)

Lesson 21: Comparing Linear and Exponential Functions Again

Voluntary State Curriculum Algebra II

Algebra 2 Semester 2 Final Exam Study Outline Semester 2 Final Exam Study Tips and Information

2 The Fractional Chromatic Gap

Lecture 15 Nyquist Criterion and Diagram

Dr. Relja Vulanovic Professor of Mathematics Kent State University at Stark c 2008

UNIT 1: NUMBER LINES, INTERVALS, AND SETS

Course Number 432/433 Title Algebra II (A & B) H Grade # of Days 120

Ohio Tutorials are designed specifically for the Ohio Learning Standards to prepare students for the Ohio State Tests and end-ofcourse

Scientific Computing: An Introductory Survey

COS 323: Computing for the Physical and Social Sciences

1

f xx (x, y) = 6 + 6x f xy (x, y) = 0 f yy (x, y) = y In general, the quantity that we re interested in is

Lesson 1: Arithmetic Review

GEOMETRY IN THREE DIMENSIONS

Linear programming II João Carlos Lourenço

Algebra 1 Semester 2 Final Review

Section 1.1 Graphs Graphs

(Refer Slide Time: 00:02:02)

Contents. I Basics 1. Copyright by SIAM. Unauthorized reproduction of this article is prohibited.

Section 3.1 Objective 1: Plot Points in the Rectangular Coordinate System Video Length 12:35

CS 372: Computational Geometry Lecture 10 Linear Programming in Fixed Dimension

MAC 1105 Fall Term 2018

Middle School Math Course 2

A-SSE.1.1, A-SSE.1.2-

Pre-Calculus Summer Assignment

Introduction to Rational Functions Group Activity 5 Business Project Week #8

Most nonzero floating-point numbers are normalized. This means they can be expressed as. x = ±(1 + f) 2 e. 0 f < 1

AMTH142 Lecture 10. Scilab Graphs Floating Point Arithmetic

Curve and Surface Basics

Example 1: Given below is the graph of the quadratic function f. Use the function and its graph to find the following: Outputs

Curriculum Map: Mathematics

EC121 Mathematical Techniques A Revision Notes

REVIEW FOR THE FIRST SEMESTER EXAM

Graphing and Equations

Calculus Course Overview

Algebra I Notes Linear Equations and Inequalities in Two Variables Unit 04c

Floating-Point Arithmetic

Floating-Point Numbers in Digital Computers

New Syllabus Mathematics Textbook 1 (6th Edition)

PRESCOTT UNIFIED SCHOOL DISTRICT District Instructional Guide Revised 6/3/15

r the COR d e s 3 A lg e b r a New York Common Core Pathways

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. What is scientific computing?

Floating-Point Numbers in Digital Computers

Chapter 15 Introduction to Linear Programming

Unit Maps: Grade 8 Math

Contents 20. Trigonometric Formulas, Identities, and Equations

correlated to the Michigan High School Mathematics Content Expectations

Fall 2017: Numerical Methods I Assignment 1 (due Sep. 21, 2017)

Math 3 Coordinate Geometry Part 2 Graphing Solutions

2.1 Basics of Functions and Their Graphs

( ) = Y ˆ. Calibration Definition A model is calibrated if its predictions are right on average: ave(response Predicted value) = Predicted value.

Transcription:

powered by NUMERICAL ANALYSIS USING SCILAB: NUMERICAL STABILITY AND CONDITIONING In this Scilab tutorial we provide a collection of implemented examples on numerical stability and conditioning. Level This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. www.openeering.com

Step 1: The purpose of this tutorial The purpose of this tutorial is to provide a collection of Scilab examples that are typically part of numerical analysis courses. Here we provide some classical examples on numerical stability and conditioning. An introduction to NUMERICAL ANALYSIS USING SCILAB (numerical stability and conditioning) Step 2: Roadmap In this tutorial we provide the definitions of well-conditioned problem and stable algorithm and some related examples. These examples are useful to understand how much attention we have to pay when selecting a numerical solution method for a given problem. Descriptions Steps Condition of problems 3 Condition examples 4-6 Stability of algorithms 7 Stability example 8-11 Conclusions and remarks 12-13 Numerical stability and condition www.openeering.com page 2/12

Step 3: Conditioning of a problem Numerical stability and conditioning are two concepts that should not be confused. A problem is called well-conditioned if a small perturbation of the input data (relative error), leads to small variations of the results (relative error), i.e. of the same magnitude order. On the other hand, an ill-conditioned problem strongly amplifies the input relative error in the output dataset. Denoting by the problem under consideration, if represents the input data and the output results, it is possible to define the condition number of the problem through the following inequality: ( ) where is a given norm which is able to measure the involved quantities. The condition number bounds the propagation of the input relative error in the output results, it is closely related to the maximum accuracy that can be attained in the solution. Whenever or, the condition number is defined as ( ). Conditioning refers to the numerical problem and there is no connection with the rounding error and the solution strategy. The numerical solution strategy should take into account the kind of problem we are trying to solve. A graphical comparison is shown on the right. (Well-conditioned versus ill-conditioned problem) As an example, from the previous tutorial we have the following inequality: ( ) ( ) ( ( ) ( )) That is: ( ) { } ( ( ) ( )) where we have defined is the condition number relative to the input ; is the condition number relative to the input y. From this inequality, when the condition numbers and grows up to infinity and hence the relative error on the result can be arbitrarily huge. Numerical stability and condition www.openeering.com page 3/12

Step 4: Example: Intersection of two straight lines In this example we consider the intersection of two straight lines given by the equations: and and The intersection point is ( ). Now, if we change the coefficient of the second straight line from to, the new solution becomes ( ). If we analyze the relative error of the system, we can see that the input relative error is approximately, while the relative errors on the solution are for the variable and for respectively. These values can be considered too high when compared to the order of magnitude of the input error. This is due to the fact that the two straight lines and are almost parallel (illconditioned). (Example of an ill-conditioned problem) Now, let s consider the system where to the line, is replaced by the orthogonal line. Using the previous perturbation, the solution now moves from ( ) to ( ). In this case we have the same relative input error, but the relative errors on the solution are for the variable and for, which can be considered small (same order of magnitude of the input). This is due to the fact that the two straight lines and are almost orthogonal (well-conditioned). The Scilab script is reported in the function stabline.sce. (Example of a well-conditioned problem) Numerical stability and condition www.openeering.com page 4/12

Step 5: Zeros of polynomials In this example we consider the problem of finding the real zeros of the polynomial ( ) ( )( )( )( )( )( ) and of ( ) and ( ), which are obtained changing the coefficient of first with and then with. As we may notice in the figure on the right, in ( ) and ( ) some roots are moved from real to imaginary. The Scilab script is reported in the function stabpoly.sce. (Example of stability for zeros of a polynomial) (Roots of the three polynomials) Numerical stability and condition www.openeering.com page 5/12

Step 6: Exercise #1 Let s consider the following polynomial ( ) ( ) which has 7 unitary roots for. Plot, in a complex plane, the roots of ( ) for different values of. Hint: Use the Scilab function logspace to distribute the value of in a log space subdivision between 10-8 and 1. The function logspace(d1,d2, [n]) distributes n points between 10 d1 and 10 d2. (Results on roots perturbation with varying in [10-8,1] ) The Scilab script with the solution is reported in the function ex1.sce. Numerical stability and condition www.openeering.com page 6/12

Step 7: Numerical stability To solve a given problem we use a certain algorithm and its numerical implementation. Sometimes many algebraically equivalent solution strategies are available, but numerically they can lead to different results. This is due to computer s arithmetic, which can propagate errors in a more or less relevant way (see the Openeering tutorial on numerical errors). Algorithms that do not magnify these errors are said to be numerically stable. On the other hand, if an algorithm is numerically unstable, at a given point, the errors do not remain bounded and tend to grow up in an uncontrolled way corrupting completely the final result. Hence, even when a problem is well-conditioned, if we try to solve it with an unstable algorithm, the obtained results will be meaningless. (Stable and unstable algorithm with respect to a solution obtained using an exact analytical procedure with an infinite number of digits) The following examples refer to a comparison between stable and unstable algorithms for two given problems. Numerical stability and condition www.openeering.com page 7/12

Step 8: Example of integral computation In the next two steps, we compare two algorithms solving the following integral: ( ) Both algorithms are based on the following theoretical considerations: ; ; (the integrand) Numerical stability and condition www.openeering.com page 8/12

Step 9: Example of integral computation (unstable formulation) The first strategy is to develop an algorithm based on the following recursive formula: For we have: ( ) ; For we can used integration by parts having ( [ ] ) The developed program starts from, where. To perform the error analysis we denote by the approximate value of the integral at step with respect to the exact value and making an error. Hence, it is possible to write the following recursive formula for the error ( ) ( ) ( ) and, with respect to the first error, is ( ) (Absolute value of ) As a consequence, even if is small, the error grows up to infinity as a factorial. Numerical stability and condition www.openeering.com page 9/12

Step 10: Example of integral computation (stable formulation) The second strategy is to develop an algorithm based on the following recursive formula: For we set: ; For we rewrite the previous recursive formula in terms of as follows: ( ) The developed program starts from and computes as the last integral. To perform the error analysis we denote by the approximate value of the integral at step with respect to the exact value and making an error. Hence, it is possible to write the following recursive formula for the error ( ) ( ) ( ) giving. Hence can be expressed in terms of as ( ) (Value of. The code for this plot is in intdemo.sce) As a consequence, even if is big, the error decreases to zero, since we have a factorial as denominator. Numerical stability and condition www.openeering.com page 10/12

Step 11: Exercise #2 Considering the stable formulation, plot the relative error for from for different values of in the range [ ]. starting The relative error on is computed as where depends on and. (Relative error of the approximation of depending on. Note that the values are visible only until N=17, after that limit the values are less then %eps and are not visible in a logarithmic scale) Numerical stability and condition www.openeering.com page 11/12

Step 12: Concluding remarks and References 1. Scilab Web Page: Available: www.scilab.org. In this tutorial we have collected a series of numerical examples written in Scilab for the study of numerical stability. 2. Openeering: www.openeering.com. 3. J. Higham, accuracy and Stability of Numerical Algorithms, SIAM 4. Atkinson, An Introduction to Numerical Analysis, Wiley Step 13: Software content To report a bugs or suggest improvements please contact Openeering team at the web site www.openeering.com. -------------- Main directory -------------- stabline.sce : Stability for line intersection stabpoly.sce : Stability for polynomial intdemo.sce : Integral computation example ex1.sce : Solution of exercise #1 ex2.sce : Solution of exercise #2 license.txt : The license file Thank you for your attention, Silvia Poles and Manolo Venturin Numerical stability and condition www.openeering.com page 12/12