Now this is a function that gets the square root of a number that the user inputs and by using the babylonian method.
For the first run I used a number that we all now the root of, 4 and the function returned 2 and for the second run a tried 50.5 and returned that float number.
In this assignment you will write a function to calculate the square root of a number using the Babylonian method. You can search for that method, it will be easy to find.
What to Do
The function should receive a number and return floating point number. Obviously you should test your function, so create a main program that asks the user a value, calculates the square root and displays that.
This week we have this instructions: In this assignment you will write a function to calculate the square root of a number using the Babylonian method. The function should receive a number and return floating point number.
Last week the teacher gave us another problem to work on. As the title suggests, we had to create a function that would return the approximate square root of a number, using the Babylonian Method.
First I had to understand exactly how the method works, so I watched this video:
However, I still didn’t understand how I would know when it was accurate enough. My classmate Elu explained it to me, telling me that it should be when the difference between two successive answers gotten from the formula differed only by 0.0001 or less.
Having fully understood the mathematics, I proceeded to write my code:
In this assignment you will write a function to calculate the square root of a number using the Babylonian method.
Step 1: Make a guess.
Step 2: Divide your original number by your guess.
Step 3: Find the average of these numbers.
Step 4: Use this average as your next guess.
REPEAT THE PROCESS THREE TIMES.
What to Do
The function should receive a number and return floating point number. Obviously you should test your function, so create a main program that asks the user a value, calculates the square root and displays that.
In this assignment you will write a function to calculate the square root of a number using the Babylonian method. You can search for that method, it will be easy to find.
The function should receive a number and return floating point number. Obviously you should test your function, so create a main program that asks the user a value, calculates the square root and displays that.
Se debe de desarrollar una una función que obtenga la raíz cuadrada según el método Babilónico:
El método Babilónico para obtener la raíz cuadrada de un número es el siguiente: primero se divide el número entre si mismo, y se multiplica por si mismo. Si la multiplicación da el número original, se encontró la raiz. Si no, se divide el número original entre el nuevo obtenido anteriormente (a), se suma “a” de nuevo y se divide entre 2. De nueva cuenta se potencia al cuadrado y si se obtiene el número original se termina el ciclo, sino se repite hasta que se obtenga.
Para obtener el método Babilónico me basé en esta fuente: