Sei sulla pagina 1di 15

Finding

the square root--Numerical Approximation , Bisection method


Dr N K Srinivasan This tutorial is for middle school and high school students learning Algebra 1 . **It will teach you about numerical approximation through the example of finding the square root of a number . ** You will also learn about the bisection method-- a numerical method computer programmers use often. ** You will also become familiar with "iterative methods" --in which the same procedure is used over and over again to get better numerical results--that is greater

accuracy. ** You will also learn how to use the Heron's method for finding the square root of a number--also an iterative method, faster than bisection method.! Let us get started. Bisection method 1 Find the interval: Suppose you want to find the square root of 2. Well, this number , sqrt(2) is an irrational number and your calculator would give: sqrt(2) = 1.4142135...... How do we get this? First select two numbers such that their squares are either more than or less than 2.

I select 1.4 and 1.5. 1.4 x 1.4 = 1.96 < 2 1.5 x 1.5 = 2.25 > 2 I write this solution set in open interval : sqrt(2) = (1.4, 1.5) We can take the middle value of these two numbers ,that is (1.4 + 1.5)/2 = 1.45 as the solution : sqrt(2) is approximately 1.45. This is our first iteration. We repeat the same procedure again. Note that we have bisected, or divided in the middle the interval (1.4,1.5) . So, this method is called "bisection method". { It is also called Bolzano method.] Second iteration:

We can select the two numbers 1.4 and 1.45 for next bisection because: 1.4 x 1.4 = 1.96 < 2 1.45 x 1.45 = 2.1025 >2 [Reject the number 1.5 as a possible solution.] So our solution could be : sqrt(2) = (1.4, 1.45) and sqrt(2 ) is the middle value : sqrt(2) = (1.4 + 1.45)/2 = 1.425 [approximately] We are getting close to the calculator value of 1.412... but wait. Third iteration: Select the two numbers as 1.4 and 1.425 because 1.4 x1.4 = 1.96 < 2

and 1.425 x 1.425 = 2.030 > 2 We write the interval : sqrt (2) = (1.4, 1.425) We can take the value of sqrt(2) to be (1.4 + 1.425)/2 = 1.4125 Let us do one more iteration! Fourth Iteration: We select the two numbers as 1.4125 and 1.425: because 1.4125 x 1.4125 = 1.995 < 2 and 1.425 x 1.425 = 2.031 > 2 Yes, we are getting close to the value of sqrt(2): [1.4125 + 1.425]/2 = 1.4188 The error from 1.4142 is calculated as follows: % Error = (1.4142-1.4188)/1.4142 x 100

= 0.325% The error is less than 1%. Take the sqrt(2) as the midvalue of the interval (1.4125, 1.425): sqrt(2) = (1.4125 + 1.425)/2 = 1.41875 -------------------------------------

You may conclude that the bisection method is tedious and takes lot of computation to get fairly accurate values...You may have to iterate 5 to 10 times! But such calculations are easy to do with a computer: called "number crunching"...In

fact, computers are good at doing routine computations at a fast rate. So write a computer program for bisection method and feed to a computer or PC! Our aim in this tutorial is not to find square root of 2, but teach the bisection method and iteration procedure for numerical approximation.

Heron's method-- Heron of Alexandria , a Greek mathematician of first century AD, gave a simple 'iterative formula' for finding the square roots . You may be familiar with Heron's formula for the area of a triangle: A = sqrt[

s(s-a)(s-b)(s-c)] where a, b,and c are the sides of a trianlge and s is the semi-perimeter , s = (a+b+c)/2. The Heron formula or method for square roots is as follows: x' = (1/2) [ x + N/x] where N is the number whose square root we want and x is the initial guess for the root. Some math historians claim that Babylonians knew this method. x' is the better value for the square root. Again substitute x' for x in the right side and get the next value. To illustrate, let us take N = 2 and the initial guess x= 1.5

x' = [ 1.5 + 2/1.5]/2 = 2.8333/2 = 1.416 Now let us use this value of x for the next iteration: x' = [ 1.416 + 2/1.416]/2 = (1.416 + 1.4124]/2 x' = 1.4142 We already have a value for sqrt(2) accurate to four decimal places in just two iterations. Let us try one more iteration: x' = [1.4142 + 2/1.4142]/2 = 1.4142135 This result is pretty close to the value you get from your calculator: 1.4142135, correct to seven decimal places! in just three iterations. [Think a little louder! You will realize

that Heron's method is also a bisection method involving x and N/x which is x'.x'/x where x' is a better value, that is we take arithmetic mean of x and N/x.] [You will learn how to derive this Heron's formula in Calculus using Newton-Raphson method.] Heron's method is faster and easier and had been used for centuries before computers became available. Here is another example: Find the square root of 17 using heron's method: Take the first value as x= 4 x' = (4 + 17/4)/ 2 = 4.125 Second iteration:

x' = (4.125 + 17/4.125)/2 = 8.2462121/2 = 4.123106 The calculator gives: sqrt(17) = 4.1231056 Pretty fast method indeed!! Non-linear algebraic equation: Finding the square root of 2 is the same problem as solving the equation: x2 -2 = 0 Such an equation is called a "non-linear" equation because it contains the x squared term. Bisection method is the easiest method to solve such equations.

Using Linear interpolation


An easy and powerful method is to use linear interpolation between the intervals to find

the square root. sqrt(2) : (1.4,1.45) We find that 1.4 x 1.4 = 1.96 1.45 x 1.45 = 2.1025 The exact square root of 2 must lie between 1.4 and 1.45. We plot x2 against x; the slope of this straight line between 1.96 and 2.1025 becomes: m = (1.45 - 1.4)/ (2.1025 - 1.96) = 0.05/0.1425 = 0.3508 Using the formula: y-y1 = m (x-x1), x for x.x=2 is : x = 1.4 + 0.3508 (2 - 1.96) = 1.4 + 0.3508 x 0.04 = 1.4 + 0.14035

Therefore sqrt(2) = 1.414035 This result is accurate to three decimal places. [This method is the same as the secant method to solve non-linear equations.] -------------------------------------

--------------------------------------------

Try these problems: Problems: 1 Find the square root of 3 by bisection method. 2 Find the square root of 3 by using Heron's

formula.Compare the two methods: Which is faster?[less computation] 2 Find the cube root of 9 by bisection method. 3 Write a computer program for bisection method in any language of your choice and run through your PC to find sqrt(2). 4 Write a computer program for Heron's formula to find square roots. 5 Can you improve the bisection method? Think. Note: Your calculator uses a simple program of this kind [bisection method or perhaps, Heron's method ] to calculate square roots! ---------------------------------------

Potrebbero piacerti anche