Método Babilónico (WSQ10)

--Originally published at Regular Blog

babilonia

babylonian

En esta ocasión volvemos con los métodos matemáticos, ahora con el método babilónico para calcular raíces cuadradas. Este método es algo ortodoxo y , a mi parecer, poco práctico y muy tardado. Pero en esta ocasión nos ha servido para “echarle coco” a la situación…
Para más detalles del método babilónico consultar la siguiente página, en la cual me he apoyado: http://pensamiento-matematico.blogspot.mx/2013/05/metodo-babilonico-de-resolucion-de.html

En realidad no utilizamos herramientas muy novedosas, más bien innovamos un poco con las que ya contábamos.

Agradezco a Alexa Mercado por ayudarme en la realización de este código ❤

https://github.com/LourdesMnz99/TC1017/blob/master/Babylonian%20Method


Babylonian Method

--Originally published at Future Queen of C++

In theory, this was an easy WSQ, but when I tried the loop I had some issues doing the while. This was because I didn’t put the variables in a correct way. But when I saw the blog of a classmate I was able to see my mistake and correct it.


Babylonian Method

--Originally published at Valeria CT

I struggled a bit with this WSQ because of the lack of precision in decimals, I tried restricting the loop conditional, but it didn’t work. What I did was I rounded the numbers (multiplying them by 100000000 first) and then dividing them by 100000000 to get the original number but with a limited amount of decimals. This way the conditional == is valid.

Here’s my code: https://github.com/valeriact/tc1017/blob/master/wsq10-2.cpp

and the resources I used:

-Valeria


WSQ10 – Babylonian Method

--Originally published at Ernesto's Computing Works

En este trabajo escribí una función que calculara la raíz cuadrada de un numero usando el método de babylonian.  Se expresa de la siguiente forma:

x_{n+1}=x_{n}-{\frac {f(x_{n})}{f'(x_{n})}}=x_{n}-{\frac {x_{n}^{2}-S}{2x_{n}}}={\frac {1}{2}}\left(x_{n}+{\frac {S}{x_{n}}}\right)

El programa que hiciera debía hacer esto: recibir un numero y que al final desplegara como respuesta un numero con valor float, así que el usuario da un numero y el programa saca la raíz cuadrado y la despliega

Ya hemos hecho raiz cuadrada en este curso, pero usábamos la funciona sqrt del la librería math.h, pero esta vez tenemos que hacer que nuestro programa haga algo asi sin usar otra libreria:

{\displaystyle {\begin{aligned}{\begin{array}{rlll}x_{0}&=6\cdot 10^{2}&&=600.000\\[0.3em]x_{1}&={\frac {1}{2}}\left(x_{0}+{\frac {S}{x_{0}}}\right)&={\frac {1}{2}}\left(600.000+{\frac {125348}{600.000}}\right)&=404.457\\[0.3em]x_{2}&={\frac {1}{2}}\left(x_{1}+{\frac {S}{x_{1}}}\right)&={\frac {1}{2}}\left(404.457+{\frac {125348}{404.457}}\right)&=357.187\\[0.3em]x_{3}&={\frac {1}{2}}\left(x_{2}+{\frac {S}{x_{2}}}\right)&={\frac {1}{2}}\left(357.187+{\frac {125348}{357.187}}\right)&=354.059\\[0.3em]x_{4}&={\frac {1}{2}}\left(x_{3}+{\frac {S}{x_{3}}}\right)&={\frac {1}{2}}\left(354.059+{\frac {125348}{354.059}}\right)&=354.045\\[0.3em]x_{5}&={\frac {1}{2}}\left(x_{4}+{\frac {S}{x_{4}}}\right)&={\frac {1}{2}}\left(354.045+{\frac {125348}{354.045}}\right)&=354.045\end{array}}\end{aligned}}}

Empece haciendo el programa como siempre pero me trabe al momento de hacer la función, y la verdad ni estaba tan difícil pero por falta de tiempo tome como recurso el trabajo de un compañero de otro semestre anterior. No recuerdo el nombre de su blog pero me sirvió de mucho.

Screenshot 2017-10-26 21.01.39

En este programa  use por primera vez una variable double, que funciona igual que un valor float solo que el valor double es mucho mas preciso con los decimales y tiene mayor rango, cree una funciona realizando lo mismo de el proceso de babylonian y luego con un main hice que desplegara el valor de función iguala a otra variable.


WSQ10 – Babylonian Method

--Originally published at Solving problems with programming

At first this method seems to me so complicated, so i look after my friends and they help a lot with the babylonian method because some of friends have done this assignment by the day i asked for it and another have work with this algorithm some time ago.

I understand that babylonian method is like and square root but with an unique and larger method.

At the end I´ve end with the code on this link https://gist.github.com/jesuscmadrigal/65f2eb1758b25dfe6427e0206b67d292

Haga click para ver el pase de diapositivas.

WSQ10

--Originally published at Victor´s Spot

I believe that this activitie was very easy because I have a strong knowledge when it consists in a mathematic code, I enjoy doing these kind of tasks and for these particular case we had 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.”(Bauer,2017)WSQ10

To entertain I will share with you a little poem:

Calculating an squareroot

Maybe difficult

But not something you can´t do

So you don´t have to try to cut

You can download the code here: