mal519 introduction to computers and programming
play

MAL519 Introduction to Computers and Programming (3 Lecture hours - PowerPoint PPT Presentation

MAL519 Introduction to Computers and Programming (3 Lecture hours and 2 Lab hours per week ) Slot H Mon, Wed 1111:50AM and Thur 12-12:50 PM Venue MZ 163 Lab venue and timings yet to be decided ?? Collect a copy of Course Information


  1. MAL519 Introduction to Computers and Programming (3 Lecture hours and 2 Lab hours per week ) Slot H Mon, Wed 11–11:50AM and Thur 12-12:50 PM Venue MZ 163 Lab venue and timings yet to be decided ?? Collect a copy of Course Information Sheet. Lecture teacher: Dr. V. V. K. Srinivas Mobile number 9968185342.

  2. Examination and Evaluation Plan 1. Quiz-1 6 Marks(August) 2. Minor-1 20 Marks(1-4 Sept) 3. Quiz-2 7 Marks(Sept) 4. Minor-2 20 Marks(7-10 Oct) 5. Quiz-3 7 Marks(Oct) 6. Assignt 10 Marks(Nov) 7. Major 30 Marks(19-25Nov)

  3. Attendance Requirements 42 Lectures + 14 Tutorials = 56 Below 75 % of attendance i.e. Below 42 out of 56 will be penalized according to the institute rules.

  4. Basics of Numbers in computers Decimal number system is based on 10 digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. N = 57893.23965 = 5 x 10^4 + 7 x 10^3 + 8 x 10^2 + 9 x 10^1 + 3 x 10^0 + 2 x 10^(-1) + 3 x 10^(-2) + ..... + 5 x 10^(-5). It is like a polynomial in x=10. Binary number system is based on 2 digits 0 and 1. Computers usually stores the numbers in binary system. Octal number system is based on 8 digits 0,1,2,3,4,5,6 and 7.

  5. Significant digits Hexadecial number system is based on 16 digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. Whenever we employ a number in a computation we must have assurance that it can be used with confidence. Significant figures or Significant digits of a given number are those that can be used with confidence. number of certain digits + 1 estimated digit.

  6. Speedometer and Odometer Speedometer has 3 significant digits. 48Kmph -------------These 2 digits are certain. 48.8 or 48.9 ---------After the decimal 8 or 9 is not certain but this one digit is an estimated digit. Odometer (Measures the number of Kms run by the motar vehicle ) has 7 significant digits---- 86543.45. First 6 digits are certain and 7 th digit is estimated.

  7. Zeros are not always significant Zeros are necessary to locate a decimal point. The numbers 0.00006875, 0.0006875 and 0.006875 all have 4 significant digits. Trailing Zeros ( depending on whether they are known with confidence ) are to be used with scientific notation----8.95 X 10^4, 8.950 x 10^4 and 8.9500 x 10^4 have 3, 4 and 5 significant digits respectively.

  8. The Value of π Although quantities such as π , e and square root(7) represent specific quantities, they cannot be expressed exactly by a limited number of digits. For example π = 3. 141592653589793238462643... As of January 2010, the record was almost 2.7 trillion digits. This beats the previous record of 2,576,980,370,000 decimals, set by Daisuke Takahashi on the T2K-Tsukuba System, a supercomputer at the University of Tsukuba northeast of Tokyo. π is an irrational number, which means that its value cannot be expressed exactly as a fraction, the numerator and denominator of which are integers. Consequently, its decimal representation never ends or repeats.

  9. π truncated to 50 decimal places The decimal representation of π truncated to 50 decimal places is π = 3.14159265358979323846264338327950288419716939937510... Various online web sites provide π to many more digits. While the decimal representation of π has been computed to more than a trillion (10^12) digits, elementary applications, such as estimating the circumference of a circle, will rarely require more than a dozen decimal places. For example, the decimal representation of π truncated to 11 decimal places is good enough to estimate the circumference of any circle that fits inside the Earth with an error of less than one millimetre, and the decimal representation of π truncated to 39 decimal places is sufficient to estimate the circumference of any circle that fits in the observable universe with precision comparable to the radius of a hydrogen atom.

  10. Use of significant digits for numerical methods. We might decide that our approximation is acceptable if it is correct to certain number of significant figures. The concept of significant digits will have relevance to our definition of accuracy and precision.

  11. Accuracy and Precision Accuracy refers to how closely a computed value or approximation agrees with the true value. Precision refers to how closely individual computed values or approximations agree with each other.

  12. Errors Definitions true error = true value - approximation True fractional relative error = true error true value True percent relative error, ε t = true error true value × 100

  13. Error Definitions Why we calculate percentage relative errors ? Suppose while measuring the lengths of a bridge of 1 Km = 10000 cms and a rivet ( bolt ) of 10 cms we committed an error of 1 cm. True percent relative error for bridge = 100 x true error/ true value = 100/10000 = 0.01 % True percent relative error for rivet or bolt = 100 x true error/ true value = 100/10 = 10 %

  14. True Value is mostly unknown In actual situations the true value is rarely available. In real-world applications, we will obviously not know the true answer a priori. For these situations, an alternative is to normalize the error using the best available estimate of the true value, ie to the approximation itself, as in

  15. Errors Definitions Approximate fractional relative error = approximate error approximation percent relative error ε a = current app - previous appr × 100 current approx

  16. Stopping criterion or percent tolerance. The computations are repeated until | percent relative error | < percent tolerance. There is also a relationship between number of significant digits and the errors in the approximation. We can be asssured that our results are correct to atleast n significant digits when percent tolerance = 0.5 x 10^(2-n) %.

  17. Round off errors Round-off error is a side-effect of the way that numbers are stored and manipulated on a computer. Most commonly, when we use a computer to do arithmetic with real numbers we will want to make use of the computer's CPU's native hardware facilities for doing arithmetic. Doing arithmetic in hardware is by far the fastest method available. The trade-off for using the CPU's hardware for doing arithmetic with real numbers is that we have to use the CPU's native format for representing real numbers. On most modern CPUs, the native data type for doing real valued arithmetic is the IEEE 754 double precision floating point data type. This data type is a sequence of 64 bits divided into a sign bit, an 11 bit exponent, and a 52 bit mantissa. For our purposes, the most relevant fact about this structure is that it only allows us to represent a maximum of 16 decimal digits in a number.

  18. Multiplication Any digits beyond 16 are simply dropped.  The main problem with this digit limit is that it is very easy to exceed that limit. For example, consider the following multiplication problem: 12.003438125 * 14.459303453 = 173.561354328684345625  The problem with this result is that although both of the operands fit comforably in the 16 decimal digit limit, the result has 21 decimal digits . To fit the result into a standard double we will have to simply round off or

  19. Division discard the last 5 digits. This introduces a round- off error to our calculation.  Round-off errors get more severe when we do division. For example, if we want to do  57.983/102.54 = 0.565467134776672518041739808855... we see that doing a calculation with two five digit numbers produces a result with essentially an infinite number of decimal digits . Once again, that result will have to be rounded off to 16 decimal digits.

  20. Addition One of the most severe problems with round-off error occurs when we do simple addition involving two quantities with widely differing magnitudes . Here is an example:  1762.0345 + 0.002399 3825 = 1762.036899 3825  Note in this case that both of the operands have 8 decimal digits of precision, yet to fully represent the result requires 14 digits. If we were to arbitrarily round off the result to only 8 digits we would be in effect losing all but 2 of the original 8 digits from the second operand. This is a fairly severe round-off error.

  21. Propagating round-off errors  All of the examples shown above proves that round-off error is a problem when we do just one arithmetic operation. This gets compounded when we have to do calculations requiring many arithmetic operations. Here is a rather dramatic example to demonstrate how this can become a real problem. Using C++ program to compute the summation n = 1 to 1,00,00,000 of (1/n) =16.695311365859855

  22. Forward Sum and Reverse Sum Summing the terms from left to right and then also summing the terms from right to left. The results it returns are :  Forward sum: 15.4037  Reverse sum: 16.686 Neither of these are right, and the forward sum is clearly worse. The reason for the problems with the forward sum has to do with the nature of the additions being done.

  23. What is happening in the Forward Sum?  When we do the sum in the forward direction we construct a cummulative total and store it in the variable sum. After the first few hundred terms the sum has magnitude of about 10.0 or so. At the same time, the terms we are trying to add to the running total keep shrinking. This attempt to add ever smaller terms to a growing running total is precisely the scenario that makes round-off error worse: adding two numbers of very different magnitude.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend