1 / 143

ΑΡΙΘΜΗΤΙΚΗ ΑΝΑΛΥΣΗ

ΑΡΙΘΜΗΤΙΚΗ ΑΝΑΛΥΣΗ. Αναπαράσταση αριθμών στον υπολογιστή Σφάλματα Truncation error and Taylor series. Scientific computing is a discipline concerned with the development and

sroberge
Download Presentation

ΑΡΙΘΜΗΤΙΚΗ ΑΝΑΛΥΣΗ

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ΑΡΙΘΜΗΤΙΚΗ ΑΝΑΛΥΣΗ Αναπαράσταση αριθμών στον υπολογιστή Σφάλματα Truncation error and Taylor series

  2. Scientific computing is a discipline concerned with the development and study of numerical algorithms for solving mathematical problems that arise in various disciplines in science and engineering

  3. Numerical methods are an essential part of an engineer’s life • They allow to solve a much wider range of physical/engineering problems than analytical methods do. • Numerical methods are however only one part of the solution: a good physical understanding of the problem is essential. • Numerical methods are the elementary pieces of more complex codes and software used for scientific simulation. • Studying numerical methods allows one to - understand how more complex codes work - be able to modify an existing code or create a new one - understand the errors/limits introduced by the numerical simulation

  4. 2. Αναπαράσταση αριθμών στον Υπολογιστή

  5. Αριθμητικά Συστήματα & Μετατροπές Base 10 Base 2

  6. Decimal System (base 10) Binary System (base 2)

  7. Numbers that have a finite expansion in one numbering systemmay have an infinite expansion in another numbering system: • You can never represent 1.1 exactly in binary system.

  8. Convert Base 10 Integer to binary representation Converting a base-10 integer to binary representation.

  9. Fractional Decimal Number to Binary Converting a base-10 fraction to binary representation.

  10. Decimal Number to Binary Since and we have

  11. All Fractional Decimal Numbers Cannot be Represented Exactly Converting a base-10 fraction to approximate binary representation.

  12. Integer Representation 16-bit word • Range: -32,768 to 32,767 • Overflow: > 32,767 (cannot represent 43,000 students) • Underflow: < -32,768 (magnitude too large) 32-bit word • Range: -2,147,483,648 to 2,147,483,647 • 9 significant digits • Overflow: world population 6 billion • Underflow: budget deficit -$100 billion

  13. Floating Point Representation (decimal) • Floating Decimal Point : Scientific Form

  14. Floating-Point Arithmetic (cont.) • A computer number has three parts • the sign (+ or -) • the fraction part (called the mantissa) • the exponent part • There are three level of precision and these are the number of bits used for mantissa and exponent.

  15. The form is or Example: For

  16. Floating Point Format for Binary Numbers 1 is not stored as it is always given to be 1.

  17. Example 9 bit-hypothetical word • the first bit is used for the sign of the number, • the second bit for the sign of the exponent, • the next four bits for the mantissa, and • the next three bits for the exponent We have the representation as mantissa exponent Sign of the number Sign of the exponent

  18. Machine Epsilon Defined as the measure of accuracy and found by difference between 1 and the next number that can be represented Ten bit word • Sign of number • Sign of exponent • Next four bits for exponent • Next four bits for mantissa Next number

  19. Relative Error and Machine Epsilon The absolute relative true error in representing a number will be less then the machine epsilon Example 10 bit word (sign, sign of exponent, 4 for exponent, 4 for mantissa) Sign of the number exponent mantissa Sign of the exponent

  20. Subtracting two almost equal numbers

  21. IEEE-754 Floating Point Standard • Standardizes representation of floating point numbers on different computers in single and double precision. • Standardizes representation of floating point operations on different computers.

  22. IEEE-754 Format Single & Double Precision S Exponent8 Fraction23 S Exponent11 Fraction52 (continued) 32 bits for single precision Biased Exponent (e’) Sign (s) Mantissa (m) Double precision

  23. Example#1 Biased Exponent (e’) Sign (s) Mantissa (m)

  24. Example#2 Represent -5.5834x1010 as a single precision floating point number. Biased Exponent (e’) Sign (s) Mantissa (m)

  25. Exponent for 32 Bit IEEE-754 8 bits would represent Bias is 127; so subtract 127 from representation

  26. Exponent for Special Cases Actual range of and are reserved for special numbers Actual range of

  27. Special Exponents and Numbers all zeros all ones

  28. IEEE-754 Format The smallest number by magnitude Machine epsilon The largest number by magnitude

  29. Significant Digits • Significant digits are those digits that can be used with confidence. • Single-Precision: 7 Significant Digits • 1.175494… × 10-38 to 3.402823… × 1038 • Double-Precision: 15 Significant Digits • 2.2250738… × 10-308 to 1.7976931… × 10308

  30. Using Floating Point Numbers • Beware of meaningless precision! • In 1424, Jamshid Masud al-Kashi published  = 3.141 592 653 589 793 25… • …but noted that the error in computing the perimeter of a circle with a radius 600’000 times that of earth would be less than the thickness of a horse’s hair. • Donald E. Knuth : • Floating point arithmetic is by nature inexact, and it is not difficult to misuse it so that the computed answers consist almost entirely of “noise”. One of the principal problems of numerical analysis is to determine how accurate the results of certain numerical methods will be.

  31. Using Floating Point Numbers • Never use equality between two floating point numbers !!!!!!!! • Use a special method to compare them!!!!! (define an acceptable error for the specific problem)

  32. 3. Σφάλματα How much error is present in our calculation and is it tolerable?

  33. Σφάλματα (Errors) • Η λύση ενός προβλήματος με τη βοήθεια αριθμητικών μεθόδων διαφέρει πάντοτε από την ακριβή λύση λόγω της παρουσίας σφαλμάτων. Διάφορες πηγές μπορούν να προκαλέσουν σφάλματα στα αριθμητικά αποτελέσματα • Πηγές σφαλμάτων: • Μετρήσεις φυσικών ή χημικών συσκευών και μηχανισμών (δεδομένα που περιέχουν εγγενώς σφάλματα), ονομάζονται αρχικά σφάλματα. • Σφάλμα του μαθηματικού προβλήματος ή σφάλμα της μαθηματικής περιγραφής. Προέρχεται από τη μετατροπή του προβλήματος σε μαθηματικό πρόβλημα, περιέχοντας απλοποιήσεις ή και παραλείψεις. • Σφάλματα από προβλήματα κακής κατάστασης :αριθμητικά προβλήματα που είναι πολύ ευαίσθητα σε μικρές μεταβολές των δεδομένων.

  34. Accuracy and Precision • Accuracy refers to how closely a computed or measured value agrees with the true value, while precisionrefers to how closely individual computed or measured values agree with each other (Μέτρο της ικανότητας διάκρισης μεταξύ σχεδόν ίσων τιμών). a) inaccurate and imprecise b) accurate and imprecise c) inaccurate and precise d) accurate and precise

  35. Accuracy vs. Precision Inaccurate Accurate 1 2 Imprecise 3 4 Precise

  36. Four possible sources of errors ➡ Measurement error ➡ Modeling error ➡ Truncation error ➡ Round-off error

  37. A. Measurement error ➡ Any instrument has a limit on its precision, and an experimental result is always obtained with a tolerance: e.g. 20.2 ± 0.1 cm B. Modeling error ➡ Difference between the real system and the simplified description used. ➡ Example of the bridge: representing the elements as homogeneous or with a simplified geometry.

  38. C. Truncation error ➡ This error arises due to the discrete or iterative nature of the numerical methods used. ➡ For example, an iterative scheme can be developed to obtain the physical quantity G. - If the scheme is well-designed then G(n) approaches the true value of G when n→∞. - However, we always have to stop at a finite value of n=N. The truncation error is the difference between G(N) and G(∞). ➡ A truncation error also arises when approximating a continuous quantity by a discrete form or a derivative by a discrete limit:

  39. D. Round-off error • Computers can only perform numeric calculations out to a certain number of decimal places before introducing rounding errors • This error is intrinsic to the use of a computer. • A computer does not use the real number but finite-precision numbers (e.g. some decimals are discarded.) • The propagation of rounding errors from one floating point operation to the next is the most frequent source of numerical instabilities.

  40. Sources of Numerical Errors • Round off error (σφάλμα στρογγυλοποίησης) • Προκύπτει από την ανάγκη αναπαράστασης των αριθμών με πεπερασμένο πλήθος ψηφίων • Truncation error (σφάλμα αποκοπής) • Δημιουργείται από τον αλγόριθμο που χρησιμοποιείται και την προσέγγιση που επιλέγεται (κατά την αντικατάσταση μιας ακριβούς διαδικασίας υπολογισμού με μία προσεγγιστική)

  41. Round off Error • Caused by representing a number approximately

  42. Rounding errors are random

  43. Problems created by round off error • 28 Americans were killed on February 25, 1991 by an Iraqi Scud missile in Dhahran, Saudi Arabia. • The patriot defense system failed to track and intercept the Scud. Why?

  44. Problem with Patriot missile • Clock cycle of 1/10 seconds was represented in 24-bit fixed point register created an error of 9.5 x 10-8 seconds. • The battery was on for 100 consecutive hours, thus causing an inaccuracy of • The shift calculated in the ranging system of the missile was 687 meters. • The target was considered to be out of range at a distance greater than 137 meters.

  45. Example: quadrature of a circle

  46. A large collection of software bugs • Careless numerical computing does occasionally lead to disasters http://wwwzenger.informatik.tu-muenchen.de/persons/huckle/bugse.html

  47. Άσκηση (σε MATLAB)

  48. Why measure errors? 1) To determine the accuracy of numerical results. 2) To develop stopping criteria for iterative algorithms.

More Related