SECTION 1: COMPUTER ARITHMETIC AND SOLVING LINEAR AND NON LINEAR EQUATIONS Structure 1.0 1.1 1.2 1.3 1.4 1.5 1.6
Computer Arithmetic and Solving Linear and Non-Linear Equations
Page Nos.
Introduction Objectives Round-off and Truncation Errors Solving Linear Algebraic Equations Solving Non-Linear Equations Summary Further Readings
1.0
INTRODUCTION
Numerical Methods are used for solving mathematical problems using computations. One of the key concepts used in developing computational solutions is the Taylor Series. You must go through the details of BCS054: Numerical Methods course prior to attempting lab sessions on numerical methods. This section includes three practical sessions. This section is based on Block 1 of BCS054. Therefore, you must go through the Block 1 before performing activities suggested in this section. You need to use a programming language to implement a numerical method. You may use C for the purpose of this course. In this section, we will be using Dev C++ compiler for demonstration of some of the programs relating to Numerical methods. This section demonstrates three mail concepts viz. Use of Floating point numbers and errors, solving of linear and non-linear equations. We will demonstrate one program as example for these topics.
1.1
OBJECTIVES
After performing the activities of this section, you should be able to: •
Write and run C programs for solving non-linear equations
•
Write and run C programs for solving linear equations
•
Appreciate the round of and truncation error and their removal in a C program.
1.2
ROUND OFF AND TRUNCATION ERRORS
The round off and truncation errors sometimes can play major problems while solving a problem. We demonstrate this concept with the help of following problem. Problem: Write a program to find if a given number is an Armstrong number. Test your program using three digits number 153 and 135. But first let us define what an Armstrong Number is? Let us consider the number 153. You separate the three digits of this number; they are 1, 5 and 3. Now, you take a cube 5