I. Objective The objectives of this activity are: To be able to calculate the root of a number [Babylonian Method] using Octave To find the number of iterations To be input its tolerance to determine its number of iteration
II. Problem In order to be able to calculate the root of a number using Babylonian method, we must first make a program using octave that would make a function calculate the given number denoted by ‘Babylonian(x)’. We must also include in the program the number if iterations it will make.
Another problem also is we had to make another program that will calculate its root but its number of iterations will not be specified, only its tolerance will determine the number of iterations.
III. Theoretical Background The language in Octave is similar to C language which allows us to be familiar with the language. In the Babylonian method, we knew its formula was Xn+1 = ⅟2 ( Xn + S/ Xn ) . All we had to do was to make the program to input the S=square root of the number, and use the FOR loop to repeat the iterations. And WHILE loop to be used with the tolerance.
IV. Results/Codes and Sample Runs
The first program was to calculate the root by predefined number of iterations.
The second program was to find the root by using tolerance to determine its number of iterations. The tolerance value is 0.0001
On third program, value of tolerance was changed to .000001
V. Analysis
For the number of iterations to be defined, we needed to use the FOR loop followed by the equation until the loop ends. ‘for=1:10’ means that it repeats the loop 10 times starting from 1 up to 10. Where x is the initial guess and a is the number to be inputted by the user to find its root.
The Essay on Oxford Program 61623 Postings Make
July 9, 2002 Hello and welcome to the Oxford Program! Thank you for "enrolling" and I'm sincere when I say that I am anxious to start working with you. I am very enthusiastic about what I do - mainly because I can empathize with anyone going through worklife-related frustration and because I feel that I am very good at what I do. How the "process" works... The Oxford Program is sort of a group- ...
The second program used a different kind of loop, WHILE loop was used. First the tolerance and difference was declared. Where x was still the initial guess. While the difference was still bigger than the tolerance the loop would still continue until it comes to a point there the difference is lesser than the tolerance which stops the loop.
On the third program, the tolerance was changed from 0.0001 to 0.00001 , the only difference it made was that another iteration or loop was made.
VI. Conclusion
I conclude that to be able to find the root of a number using Babylonian method using Octave, we must be familiar the the C language and its loops.
The FOR loop was to specify the number of iterations while the WHILE loop determines its number of iterations depending on its given tolerance. By changing the tolerance number to a smaller value, the number of iterations increases.