Babylonian Territory

--Originally published at richardctc201

Down in Babylonian Territory, I successfully implemented the Babylonian Method to find the square root of a number. Again, I received help from Alex ( the same guy I talked about in my most recent post).

The structure of this program is very similar from the GCD because this one also has two classes: the main class and a ‘Number’ class. In the number class, again, there are two methods: one called ‘setValue’, that assign a value to the objects created in the main class; and another called ‘squareRoot’, in this one there are performed the mathematical calculations. In the main class, there are created two objetcs: val1 and val2. Then it is called the method squareRoot for val1, passing as parameter val2. In this method, there are four variables declared: a, b, div, and ave. Variable a is assigned the value of val1, and b is the parameter. Then there is a for iteration to perform the process of the Babylonian method three times. The variable div gets the value of a/b, and ave gets the value of the average of b and div. Finally b gets the value of ave to perform the next iteration.

I tried the code assigning a the value 7, and b the value 4, and the output I get was 2.6457672, a very accurate square root of number 7.

The reasoning for doing this code was based in this link.

Here I also leave the link and screens of my GitHub account where you can see my code. Greetings from the Babylonian Territory!

Babylonian Territory

Babylonian Territory


Babylonian Territory

Babylonian Method

--Originally published at TC201 Winter 2016 Jorge

Here's my about the babylonian method.The basic idea of this method for finding square roots that if x is an overstimate to the square root of a non-negative real number S then s/x will be an underestimate and so the average of these two numbers may reasonably be expected to provide a better approximation.

This was as well a challenging WSQ even though I made it a year ago in Python. I keep struggling when passing that Python code to Java in an OOP way. But once again (why not), I had a look to other WSQs of my classmates from and that helped me finish this WSQ. Here you can see the screenshot I took to my code and right below it the link to my code in GitHub.

Babylonian Method

Check out my GitHub link here.

Babylonian Method

--Originally published at TC201 Winter 2016 Jorge

Here's my about the babylonian method.The basic idea of this method for finding square roots that if x is an overstimate to the square root of a non-negative real number S then s/x will be an underestimate and so the average of these two numbers may reasonably be expected to provide a better approximation.

This was as well a challenging WSQ even though I made it a year ago in Python. I keep struggling when passing that Python code to Java in an OOP way. But once again (why not), I had a look to other WSQs of my classmates from and that helped me finish this WSQ. Here you can see the screenshot I took to my code and right below it the link to my code in GitHub.

Babylonian Method

Check out my GitHub link here.

WSQ07 Babylonian Method!

--Originally published at Programación Orientada a Objetos

El método babilónico se centra en que cada lado de un cuadrado es la raíz cuadrada del área. Este método es usado desde hace muchísimos años gracias a la rapidez para sacar las raíces, funciona de esta manera:

Primero haces un rectángulo con el área del número que quieres sacar la raíz, después manteniendo la misma área, vas cambiando los lados hasta formar un cuadrado o aproximarse a uno. Por ejemplo si tienes el numero 32, primero buscas dos números que al multiplicarlos te den 32 como 8 x 4 = 32. Después se construye el rectángulo que tenga lados 8 y 4WSQ07 Babylonian Method! después se hace un cálculo que es (8 + 4)/2 = 6, entonces el 6 será otra medida de nuestro nuevo rectángulo, PERO ¿cual es la medida del otro lado? Ok, ahora dividiremos nuestro numero 32/6=5.33 ahora las medidas de nuestro rectángulo serán de 6 y 5.33 y así hasta que tengas la aproximación a la raíz.

Hice este método en programación orientada a objetos en Java y aquí esta mi código:

WSQ07 Babylonian Method!

Y aquí esta el link a mi código: https://github.com/itzeelyazmin/Eclipse_2/blob/master/Poo/src/Babylonian.java 


WSQ07 Babylonian Method!

WSQ07 – Babylonian Method

--Originally published at tc2016blog

So, here is my WSQ 07 for the square root calculation of a number.

This WSQ wasn’t hard because I had the previous algorithm from the Python class last semester, and now I made everything inside just the Main class.

WSQ07 – Babylonian Method

I used a constructor to initialize the value of Rooty and yeah, the findRoot methos just finds the root of that number.


WSQ07 – Babylonian Method

Hit me Baby(lonian) one more time

--Originally published at Ce qui est chouette

So, how did I do the Babylonian Method one, that’s the question, isn’t it?

What I did was: I reused the class “SuNumero” from the last WSQ – Euclid’s Method -and added, in a public float, the method that would be used for the Babylonian Method.

So, in essence, I implemented the method in a:

‘”Hey, Ser Object, what’s your square root?”, and it would reply “Oh why my square root is *this*, I got it using the Babylonian Method”, and it said…and I said…one thing led to another and there we were, leading the Bolshevik Revolution, I mean…coding, in Java. Yep.’ way.

“#abstraction”

Here are some screenshots of the playground, the added method, the console, and the Joker and the Thief of the night:

Hit me Baby(lonian) one more time Hit me Baby(lonian) one more time Hit me Baby(lonian) one more time

So, that was all. Things were learnt, java was written, all was lost, but war…war never changes.

Cheers.

-The about guy.


Hit me Baby(lonian) one more time